af_sync required before af_release_array?

27 views
Skip to first unread message

Aaron Hsu

unread,
Jun 17, 2023, 10:50:59 AM6/17/23
to ArrayFire Users
I have an inner loop that is doing repeated af_assign_gen calls to a set of ranges. It looks something like this:

af_array result;
af_array idx[range];
af_array val[range];

for (int i = 0; i < range; i++) {
        af_index_t *idxs;
        af_array out, tgt, idx64;

        tgt = result;
               
        af_cast(&idx64, idx[i], s64);
        af_create_indexers(&idxs);
        af_set_array_indexer(idxs, idx64, 0);               
        af_assign_gen(&out, tgt, 1, idxs, val[i]);
       
        af_sync(-1);

        af_release_array(tgt);
               
        result = out;
               
        af_release_array(idx64);
        af_release_indexers(idxs);
}

The code is in something much more complex than this, but the fundamental result that I've discovered is that the af_sync(-1) is necessary for the program to run. For some reason, I get some sort of access violation error in af_release_array() if I don't first sync. 

Is there a reason for this? I'm not sure what is going on, but I would ideally like to not have to sync every time that I need to run an assignment like this. I also need to make sure that I don't leave tgt dangling, though. 


Umar Arshad

unread,
Jun 21, 2023, 2:25:55 PM6/21/23
to ArrayFire Users
Hi Dr. Hsu,

You shouldn't need the af_sync in the example above. Does this example fail on your system? Can you give me more info about the system you are using(i.e. OS, backend, compiler, device)?

Best,

Umar Arshad

Aaron Hsu

unread,
Nov 10, 2023, 7:12:02 AM11/10/23
to ArrayFire Users
An update to this issue: I have removed the code that seemed to require this and nothing like it has reared its head again, so I'm going to call this one a non-issue at the moment. 
--
You received this message because you are subscribed to the Google Groups "ArrayFire Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to arrayfire-use...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages