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.