Remove SAVE attribute from work arrays in batch_interpolate_2d and
batch_interpolate_3d. The persistent work arrays caused GPU memory
errors (cuStreamSynchronize: illegal memory access) on the second
iteration when using GCC with nvptx offload target.
The fix allocates work arrays fresh on each call and properly manages
their GPU memory lifetime with enter/exit data directives. This ensures
clean GPU memory state between calls, avoiding stale mappings that
caused the memory corruption.
Also adds !$acc wait after exit data delete operations in destroy
subroutines to ensure proper synchronization before host memory is
freed.
This fixes the memory error that occurred when running test_batch_splines
with GCC OpenACC (GPU mode): Test 1 (Meiss) passed but Test 2 (Albert)
failed with illegal memory access. With this fix, all tests pass.
Summary
Problem
When using GCC with OpenACC nvptx offload target, the batch spline tests failed with:
The error occurred on the second iteration (Test 2: Albert field batching) while Test 1 (Meiss field batching) passed. The root cause was persistent (SAVE) work arrays that maintained stale GPU memory mappings between calls.
Solution
Changed work arrays from persistent (SAVE) to local allocation on each call. This ensures:
Testing
With this fix, all batch spline tests pass with GCC OpenACC GPU backend: