Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race condition in par_lr_interp.c if matrix is too small? #1182

Open
craffael opened this issue Nov 13, 2024 · 0 comments
Open

Race condition in par_lr_interp.c if matrix is too small? #1182

craffael opened this issue Nov 13, 2024 · 0 comments

Comments

@craffael
Copy link

here the start and end for the current thread are computed:

start = (n_fine / num_threads) * my_thread_num;
if (my_thread_num == num_threads - 1)
{ stop = n_fine; }
else
{ stop = (n_fine / num_threads) * (my_thread_num + 1); }

But this calculation is questionable when n_fine < num_threads, in which case all threads are running with start=stop=0. I have not studied the whole code, but it definitely leads to a write race condition on the following lines:

#pragma omp barrier
#endif
P_diag_i[stop] = jj_counter;
P_offd_i[stop] = jj_counter_offd;
fine_to_coarse_offset[my_thread_num] = coarse_counter;
diag_offset[my_thread_num] = jj_counter;
offd_offset[my_thread_num] = jj_counter_offd;

(e.g. all threads may write to P_diag_i[0] at the same time)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant