To unsubscribe from the SUNDIALS-USERS list: write to: mailto:SUNDIALS-USERS-...@LISTSERV.LLNL.GOV
Hi Jerred,
If you are creating the serial N_Vectors within the OpenMP loop such that they are private to a thread (along with the SUNContext and CVODE memory) then you should not have any thread-safety issues. E.g., expanding on the second approach in the documentation section you cited
// Create, Solve, Destroy
#pragma omp parallel for
for (int i = 0; i < num_problems; i++) {
int retval = 0;
void* cvode_mem;
SUNContext
sunctx;
N_Vector y;
sunctx = SUNContext_Create(...);
y = N_VNew_Serial(neq, sunctx);
cvode_mem = CVodeCreate(..., sunctx);
retval = CVodeInit(cvode_mem, ...);
// set optional cvode inputs...
CVode(cvode_mem, ...);
// get optional cvode outputs...
CVodeFree(&cvode_mem);
N_VDestroy(y);
SUNContext_Free(&sunctx);
}
The OpenMP N_Vector simply parallelizes the loops within the N_Vector operations using OpenMP, so it will not solve a thread-safety problem.
Cody