-
I have some code in which I use some per worker data by creating a vector and indexing in to it with __cilkrts_get_worker_number() which I know is not the best practice, but I have found it a useful one in some cases. Is there a way I can tell cilksan to not worry about a specific line of code, or a specific memory address or variable so that I don't get a bunch of warnings about these lines which are not what I am looking for when I am looking for bugs. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Cilksan has an API you can use by including the Cilksan fake locksCilksan includes an API for fake locks, which direct Cilksan to treat memory accesses as if they are protected by mutex lock. Cilksan fake locks are fake, in that they do not actually protect memory accesses with a mutex lock or provide any atomicity guarantee. Instead, they merely direct Cilksan to treat code as if it is protected by a lock. Cilksan will therefore not report races on code if logically parallel accesses are protected by the same fake lock. The API for Cilksan fake locks is based on that for ordinary mutex locks. Here's a simple C++ example: double wls_sum[__cilkrts_get_nworkers()];
Cilksan_fake_mutex fake_lock;
cilk_for (int i = 0; i < n; ++i) {
__cilksan_acquire_lock(&fake_lock);
wls_sum[__cilkrts_get_worker_number()] += A[i];
__cilksan_release_lock(&fake_lock);
} The API also provides double wls_sum[__cilkrts_get_nworkers()];
Cilksan_fake_mutex fake_lock;
cilk_for (int i = 0; i < n; ++i) {
Cilksan_fake_lock_guard guad(&fake_lock);
wls_sum[__cilkrts_get_worker_number()] += A[i];
} Cilksan fake locks have zero cost when your code is not compiled with Cilksan. Cilksan disable/enable checkingThe Cilksan API also provides the functions Hope that helps. Please let us know if you have more questions or run into issues. |
Beta Was this translation helpful? Give feedback.
-
This worked perfectly, |
Beta Was this translation helpful? Give feedback.
Cilksan has an API you can use by including the
cilk/cilksan.h
header into your code. Depending on what exactly you want to do, the API provides a couple of options.Cilksan fake locks
Cilksan includes an API for fake locks, which direct Cilksan to treat memory accesses as if they are protected by mutex lock. Cilksan fake locks are fake, in that they do not actually protect memory accesses with a mutex lock or provide any atomicity guarantee. Instead, they merely direct Cilksan to treat code as if it is protected by a lock. Cilksan will therefore not report races on code if logically parallel accesses are protected by the same fake lock.
The API for Cilksan fake locks is based on that for…