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 · 1 comment · May be fixed by #1188
Open

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

craffael opened this issue Nov 13, 2024 · 1 comment · May be fixed by #1188

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)

@victorapm victorapm linked a pull request Dec 4, 2024 that will close this issue
@victorapm
Copy link
Contributor

@craffael thanks for bringing this up. We are working on a PR to fix this issue

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

Successfully merging a pull request may close this issue.

2 participants