How to cache VI ref in recursive chain?

I am writing a recursive VI - a VI that calls itself.
The VI generates an image by recursively subdividing the image rectangle until it finds a rectangle small enough to work on.
(It's a mandelbrot image generator, if you must know... :-)
It calls itself by opening a VI reference to itself (using OPEN VI REFERENCE), calling that via CALL BY REF, and then closing the reference.
These calls might get to a level of 20 or 25 deep.
It works. 100 %.
In thinking that I could speed it up a bit, I tried to cache the VI reference. I was thinking that each OPEN VI REF was having to do a whole bunch of stuff. If I could just open the reference once, and store it, then I wouldn't have to do all that stuff every time.
So I tried that. I opened the reference ONCE, and stored it in a global variable. When I need to recursively call myself, I used that reference.
No Go.
The recursive call returns an error message:
Error 1042 occurred at Call By Reference Node
in Calc Mandel Rectangle.vi
->Calc Mandel Rectangle.vi
->Get Mandelbrot Image.vi
->Mandelbrot Test.vi
Possible reason(s):
LabVIEW: Attempted recursive call.
Notice that the error occurs on the SECOND level down, not the first.
My hypothesis is that a ref to a VI running at level 1 is DIFFERENT from a ref to the same VI called from itself (running at level 2).
I compared the global ref to a local one, and it said they were different.
When you generate the ref each time, it accounts for this, but when you stash the ref before the first call, it is only valid for the first level.
I have tried opening the reference with OPTIONS = 8, which is supposed to mean prepare for recursive call, but that makes no difference.
I'm on LV7.1, OS X.
QUESTIONS:
1... Is there a way to stash a VI ref so that it applies to any level?
2... Does the OPEN VI REF function take enough time to worry about?
3... Is there something I am missing in this approach?
Message Edited by CoastalMaineBird on 01-24-2006 12:36 PM
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com
Blog for (mostly LabVIEW) programmers: Tips And Tricks

1. No. each level of recursion must open a separate VI reference to work with a new instance of the VI.
OK, that's what I surmised by observation. Since the error message came from TWO levels deep, it seems that the first level was OK, but it choked when trying to go deeper.
2. The VI is already in memory so the time penalty is less severe to reinstanciate it than to open it from file.
This is true if you DO NOT CLOSE it. Normally I'm in the habit of closing the ref when I'm done with it. In this case, I would subdivide a rectangle into 4 quadrants, open a ref, call myself 4 times, and close the ref. If I omit the CLOSE part, the time penalty is substantially reduced (probably because the next OPEN REF re-uses the same info).
However if you recursively call the VI in a loop, you can open a VI reference outside the loop and reuse it in the the loop, closing it afterwards outside the loop.
Yes, I was doing that. But the CLOSE function apparently causes the next OPEN REF to have to do all the work over again.
Usually when the user doesn't notice, I don't worry about time optimization.
Sensible, but when a C version produces a picture in about 1/100 the time, I would call that noticable. And I am trying to produce a QuickTime movie of these images, so I'd like to generate them as fast as possible.
3. Recursion in LabVIEW is not very efficient.
I am coming to realize that. I have used it to delete a disk folder hierarchy, and to traverse a VI and its children, and its children's children, etc., but I wasn't concerned with speed in either case. Now I am.
There is always a way to code your VI in such a way that it doesn't use recursion by building a data stack (data for each level in an array stored in a shift register of your loop).
I will look into that. This project was intended to introduce my apprentice programmer to the idea of recursion, and it's an elegant use of it in theory. However in practice, it's dog slow.
Thanks for your thoughts.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com
Blog for (mostly LabVIEW) programmers: Tips And Tricks

Similar Messages

  • How the cache.invoke() works?

    Hi, I am trying to play with the coherence 3.4.2 to find out how the cache.invoke() works. I modified the SimpleCacheExplorer.java coming as the example code as following:
    1) I defined a distributed cache as following:
    <?xml version="1.0"?>
    <!DOCTYPE cache-config SYSTEM "cache-config.dtd">
    <cache-config>
    <caching-scheme-mapping>
    <!--
    Caches with any name will be created as default replicated.
    -->
    <cache-mapping>
    <cache-name>*</cache-name>
    <scheme-name>default-dist</scheme-name>
    </cache-mapping>
    </caching-scheme-mapping>
    <caching-schemes>
    <!--
    Default Replicated caching scheme.
    -->
    <distributed-scheme>
    <scheme-name>default-dist</scheme-name>
    <service-name>DistributedCache</service-name>
    <backing-map-scheme>
    <class-scheme>
    <scheme-ref>default-backing-map</scheme-ref>
    </class-scheme>
    </backing-map-scheme>
    </distributed-scheme>
    <!--
    Default backing map scheme definition used by all
    The caches that do not require any eviction policies
    -->
    <class-scheme>
    <scheme-name>default-backing-map</scheme-name>
    <class-name>com.tangosol.util.SafeHashMap</class-name>
    </class-scheme>
    </caching-schemes>
    </cache-config>
    2) I modified the SimpleCacheExplorer.java as following:
    class MyProcessor extends com.tangosol.util.processor.AbstractProcessor
    private static final long serialVersionURD = 8004040647128795431L;
    private String cacheName = null;
    public MyProcessor(String cacheName)
    this.cacheName = cacheName;
    public Object process(Entry entry)
    NamedCache cache = CacheFactory.getCache(cacheName);
    cache.clear();
    return null;
    public class SimpleCacheExplorer {
    * Entry point.
    * @param asArg command line arguments
    public static void main(String[] asArg)
    throws Exception
              NamedCache cache = CacheFactory.getCache("Test");
              cache.put("1", "one");
         cache.invoke("1", new MyProcessor("Test"));
         System.out.println("cache size = " + cache.size());
    3) Then I got the following exception:
    com.tangosol.util.AssertionException: poll() is a blocking call and cannot be called on the Service thread
    Is there a way I can do the cache clear in the invocation way?
    Thanks

    The EntryProcessors operate against a particular Entry and usually executes on the node where the entry is stored. What you can do is to remove the particular entry this entryprocessor is aimed at by calling entry.remove()
    Here is a modified entry processor that removes an entry.
    class MyProcessor extends com.tangosol.util.processor.AbstractProcessor
      private static final long serialVersionURD = 8004040647128795431L;
      public MyProcessor() {}
      public Object process(Entry entry)
        if (entry.isPresent())
           entry.remove(false);
      return null;
    }Getting a hold of the CacheFactory while executing an EntryProcessor is a re-entrant call in to the DistributedCacheService which is rendering the exception.
    More on re-entrancy restrictions and recommendations in this whitepaper: [Coherence Planning: From Proof of Concept to Production|http://www.oracle.com/technology/products/coherence/pdf/Oracle_Coherence_Planning_WP.pdf]

  • How to find out which meta process chain a local chain is involved in

    Hello experts,
    i would like to know how a local process chain is started by a meta chain. I have a local chain running every day. It is involved in a meta chain. How can i find out the meta chain in which the local chain is involved.
    I appreciate every help i get.
    Thank you all in advance.
    Kind regards,
    Ali

    Hi everybody,
    the question is answered.
    Thanks and regards.
    Ali

  • How can I configure ReFS to NOT fail read operations when a checksum error is detected (on non-Storage-Spaces volumes where data integrity streams are enabled)?

    According to William Stanek, in his Windows Server 2012 R2 Inside Out: Configuration, Storage & Essentials book, this is apparently possible: (pg. 615 - here it is on Google Books: https://books.google.ca/books?id=0IyfBAAAQBAJ&pg=PT819&lpg=PT819&dq=read+operation )
        Integrity can be enabled when the system is not running on Storage Spaces. When
        integrity is enabled and ReFS detects a checksum mismatch, ReFS logs an event and
        fails the read operation by default. If you don’t want the read operation to fail, you
        can configure ReFS to continue with the read operation. A related event will be logged
        regardless.
    So then how do I configure it to do that???
    (And just to make it super-clear, I'm NOT using Storage Spaces, so there is no redundancy via mirroring/parity, and I'm not expecting any file repair - just detection of corruption. It's just a basic volume formatted with ReFS and
    with integrity streams enabled, via format E: /fs:ReFS /i:enabled
    For those who want more details, here's the situation: 
    I try to perform a read operation on a file with corrupted data (purposely done for testing using a low-level disk editor), I get a the following error message:
    And an event ID 133 from ReFSv1 gets logged in the System log:
    Clicking "Try Again" just brings up the same message, and clicking "Skip" skips the operation entirely.
    This is indeed the correct default behaviour.
    What I want instead is for the read operation to be allowed to complete, with corrupt data and all, and ONLY for the event to be logged. And according to William Stanek, this is supposed to be configurable somewhere - and after hours of searching, I haven't
    been able to find anything.

    Hi Tommy,
    >>How can I configure ReFS to NOT fail read operations when a checksum error is detected
    We can use PowerShell command Set-FileIntegrity to configure this. The specific parameter for controlling this behavior is
    -Enforce <Boolean>which indicates whether to enable blocking access to a file if integrity streams do not match the data.  
    Regarding this point, the following article can be referred to as reference.
    Set-FileIntegrity
    https://technet.microsoft.com/en-us/library/jj218351.aspx
    Best regards,
    Frank Shen
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

  • Plz help.  How disable caching SQLJ statement  on WebLogic server 10.3?

    Plz help.
    How disable caching statement by SQLJ on WebLogic server?
    what the actual problem:
    1. create or replace view vtest as select object_name from dba_objects where rownum<200
    2. test.sqlj
      #sql dx testIterator = {
         select object_name from vtest
       int cnt=0;
       while( testIterator.next() ){
         cnt++;
       System.out.println("Count: "+cnt);
    3. Restart WebLogic and deploy project
    4. Run test on server, in log file
    "*Count: 199*"
    5. create or replace view vtest as select object_name from dba_objects where rownum<10
    6. Run test on server, in log file
    "*Count: 199*"
    7. Restart WebLogic
    8. Run test on server, in log file
    "*Count: 9*"

    Hi bud,
    Have you tried using WLST for what you are trying to achieve?
    Please take a look at the following links:
    http://docs.oracle.com/cd/E11035_01/wls100/config_scripting/domains.html
    http://docs.oracle.com/cd/E13222_01/wls/docs91/config_scripting/domains.html
    http://docs.oracle.com/cd/E13179_01/common/docs21/interm/config.html
    Hope this helps.
    Thanks,
    Cris

  • How to stop a process in process chain

    Can anyboday help , How to stop a process in process chain .
    Thanks
    PP

    Hi Phani
    In RSPC, Open the Meta Chain, In Process Chain Manu bar,
    Select the option "Remove From Schedule"
    Hope this will help you
    Regards
    Saravanan.ar

  • HOW TO cache user clicks on links with attributes such as "_blank" ?

    HOW TO cache user clicks on links with attributes such as "_blank" in Adobe AIR with JS or MXML or AS3 for creating new costume browser window (AIR) ?

    >This feature is indeed new to 8.5.
    Can you explain a bit more on what is possible in version 8.5? How easy it is to attach events to different sections of the 3D model? How easy it is to handle such events? I assume the events will fire even if the user rotates the 3D model via the camera control, right? Any limitations on the 3D model or what types of events are supported? If you have LV documentation describing this feature then that would be *very* helpful!
    Thanks for your reply
    MZ2

  • How to Cache a Web Template in RRI scenario

    Hi,
    We have used RRI functionality to one of our requirements where in user can look at Territory wise info first and can drill down to any specific territory for Dealer wise info. We have used Control Query to cache Dealer info based on all the territories. However, when user drills down from Territory to Dealer, system is not using the cache alreay created by the control query and resulting into slow response time.
    Any thoughts on how to cache the Dealer info in this scenario? Any valuable input is appreciated.

    Hi Arun,
    web template have a variable, that is Profit Center
    Now user wants to give on web, only Region = Europe, not Profit Center. (Region is an attribute of PC)
    Then he wants to have for each Profitcenters in Europa (let say 50 PCs) a seperate printout.
    Now he should call the report 50 times for each profit center should click on Print Button...
    Cheers

  • How to cache the objects MANUALLY?

    hello
    some o-r mapping tools can cache the objects that have been queried,then next time these objects are required,it don't need to access the database again,it can also monitor the database updating.
    i wonder how i can implement such "cache" function MANUALLY? because i DON'T want to use ANY o-r mapping tools. i only use the jdbc to query database,then generate the object.
    who can give me some clue?? or articles? or sample codes??
    thank you!!!!!

    no you don't understand me,what i want to know is the
    mechanism of the cache,and how to implement it myself
    without using the o-r mapping tools.
    the dao pattern can encapsulate the database
    access,but it can NOT cache the object .First you need to define how the caching occurs.
    - Can the data in the database change without going through your code?
    - Are there multiple copies of your app running at the same time. If yes then what happens if one is updated?
    - How many of these can there be and what impact will this have on memory?
    - etc.
    You also need to identify the 'identity' of an object.
    A simple strategy....
    - Some layer requests an object using the 'identity'.
    - The database layer code looks in a hash for the 'identity'. If it finds it it returns it.
    - If it doesn't find it it uses a DAO to load it, then puts it in the hash, then returns it.

  • How to create info area for process chains?

    How to create info area for process chains?

    Hi,
    If I understand your question clearly, you want to assign display componets.
    once you have created you chain you assign the components by clicking CTRL+F11
    Regards,
    Namrata

  • How to cach enter button pressing in java 2D API

    hi guys,
    how to cach enter button pressing in java 2D API
    thanks
    siva

    thats input handling -> Belongs to AWT.
    Tip-> register an KeyListener and search for KeyEvent.VK_ENTER
    lg Clemens

  • How can i get the "Do recursive listing.vi" with teh sub-vi, because my is lost???

    How can i get the "Do recursive listing.vi" with the sub-vi, because my is lost???
    THX

    I think you must be using LV 8.x...
    Do a LabVIEW repair to get it back or else, use the attached one.
    - Partha
    LabVIEW - Wires that catch bugs!
    Attachments:
    Recursive File List.vi ‏33 KB

  • How to cache a content item like a Static HTML Page from UCM to Coherence/C

    Hi All,
    How to cache a content item like a Static HTML Page from UCM to Coherence/Coherence Web?
    Thanks

    Hi,
    Could you explain your use case in more detail?
    It does not look like proper use of coherence to cache static content - it more suited for dynamic content like user session etc.
    Adam

  • How to return a ref cursor from this dbms_sql?

    Hi,
    Can anyone show me how to return a ref cursor from this dbms_sql based procedure? I see 11g has a dbms_sql.to_refcursor(cursor_handle). How can this be done is 10g?
    Thx.
    CREATE OR REPLACE PROCEDURE Sample_Get_t
    p_sample_id sample.sample_id%TYPE,
    p_contract_id sample.contr_id%TYPE
    IS
    cursor_handle INT;
    sql_stmnt varchar2(500);
    rows_processed NUMBER;
    BEGIN
    sql_stmnt :=
    'SELECT
    sample_id,
    contr_id,
    rcpt_id
    FROM
    sample s
    WHERE
    s.contr_id = :1
    and s.sample_id = :2
    ORDER BY
    sample_id';
    cursor_handle := dbms_sql.open_cursor;
    dbms_sql.parse(cursor_handle, sql_stmnt, dbms_sql.native);
    dbms_sql.bind_variable(cursor_handle, ':1', p_contract_id);
    dbms_sql.bind_variable(cursor_handle, ':2', p_sample_id);
    rows_processed := dbms_sql.execute(cursor_handle);
    dbms_sql.close_cursor(cursor_handle);
    END Sample_Get_t;

    In 10 this cannot be done with dbms_sql (to my knowledge). There are a couple of other options.
    1) open the ref cursor for the dynamic statement using bind variables (or SYS_CONTEXT variables, which i prefer since they are much easier to deal with when you are dynamically adding predicates).
    declare
       wRefCursor  SYS_REFCURSOR;
    begin
       open wRefCursor for 'select * from all_objects where owner = :Logged_in_user' using user;
    end;
    /or using the context (the context will bind for you)
    declare
       wRefCursor  SYS_REFCURSOR;
    begin
       open wRefCursor for 'select * from all_objects where owner = SYS_CONTEXT(''CONTEXT_NAME'', ''VARIABLE_NAME'') ';
    end;
    /Be aware that contexts ALWAYS return varchar values, so if you are comparing to a number you should wrap it in TO_NUMBER, a date, TO_DATE and so on....
    2) change the DBMS_SQL to do an insert into a global temporary table and return the ref cursor which select's * from GTT;
    3) upgrade to Oracle 11 :)

  • The coherence cluster supports created how much cache?

    Hi,
    I have runing Oracle Coherence GE 3.6.1 in cluster.
    The coherence cluster supports created how much cache? cache type is Distributed Cache.
    Cache over-population will affect the performance of the cluster?
    Thank you!

    Do a test, the code is as follows:
    cache code
         public final long removeLike(String regex) {
              long l1 = System.currentTimeMillis();
    long result = 0;
    Set<String> setKeys = nc.keySet(new LikeFilter(new KeyExtractor(), regex + "%", (char)0, false));
    long l2 = System.currentTimeMillis();
    System.out.println("removeLike , execute time :" + (l2 - l1));
    return result;
    public final boolean removeStartWith(String prefix) {
    long l1 = System.currentTimeMillis();
    int i = 0;
    try {
    Set<String> keys = nc.keySet();
    Iterator<String> iter = keys.iterator();
    String v = "";
    while (iter.hasNext()) {
    v = iter.next();
    if (v.startsWith(prefix)) {
    ++i;
    long l2 = System.currentTimeMillis();
    System.out.println("removeStartWith , execute time :" + (l2 - l1));
    return true;
    } catch (Exception e) {
    LOG.error(e.getMessage(), e);
    return false;
    The above 2 methods are computational search KEY time, not to delete operation
    test code
         @BeforeClass
    public static void init() {
    try {
    cache = CacheFactory.getCache("testCache");
    } catch (CacheException e) {
    e.printStackTrace();
    cache.clear();
    for (int i = 0; i < 100000; i++) {
    cache.add("test-" + i,i);
    for (int i = 0; i < 100000; i++) {
    cache.add("hello-" + i,i);
    @Test
    public void testReadByDefaultKey1() {
    cache.removeLike("test");
    @Test
    public void testReadByDefaultKey2() {
    cache.removeStartWith("test");
    The test results show that the:
    removeLike , execute time : 637
    removeStartWith , execute time :125
    Circulating KEY faster than using likeFilter quickly.

Maybe you are looking for

  • How to speicfy the Oracle SQL type VARCHAR2 in XI data type

    Hi Gurus, I am trying to execute an Oracle stored procedure from XI which has parameters of type VARCHAR2. How to specify these data types in data type in XI? I am getting the below message when I execute the stored procedure from XI with data types

  • Can I set up wireless internet and a wireless printer at the same time?

    I have an AirPort Express configured already which allows wireless access to the internet (as it is connected to my broadband router) but can I also configure it to allow wireless printer sharing at the same time? I would appreciate an answer on this

  • Tables for Tax amount

    In which Table does the amount of CST, Excise..etc. goes at the time of billing.

  • Autocad error "...This file is already in use by another application.

    I get this error message when I try to publish and Autocad dwg file to a pdf.  The files are not in use.  I have changed the save as name.  I have closed everything, rebooted and tried publishing again, to no avail.

  • Lost import software

    I had to download a driver to wireless network and lost the software to import photos from the card reader on my C7250 Photosmart.  Can't download the complete package because my internet is too slow.  the driver took 3 hours.  How do I reload the so