pnnl / lamellar-runtime

Lamellar is an asynchronous tasking runtime for HPC systems developed in RUST
Other
43 stars 5 forks source link

Lint check for array-length-get-in-loop-init-leads-to-deadlock issue #31

Open JosephCottam opened 1 year ago

JosephCottam commented 1 year ago

Issue: Use of local_data().len() Fix: Replace with num_elems_local() Reason: They return the same value, but local_data (sometimes) grabs a lock that might not be released as quickly as expected (e.g., during loop initialization the lock is kept for the lifetime of the loop, not just the lifetime of the initialization).

While developing a benchmark using a LocalLockArray, the "issue" version was used in a loop init that also included an array put (e.g., for i in 0...array.local_data().len() {array.put(i, ...)}). Switching the loop init to 0...array.num_elems_local() fixed the problem. The issue only comes up for LocalLockArray, but the change is valid on all array types.

Can we make a clippy check (or similar) for this?