Skip to content

Kernels which write to W2 fields may not be thread-safe #185

@tommbendall

Description

@tommbendall

Through developing #179, I found that changing the coordinate space could break bit-reproducibility for some tests that use threading. Although this was eventually fixed in the development of #179, it made me aware that several kernels are not safe for threading.

These kernels all WRITE to W2 fields, but include a check along the lines of:

! only do calculation if not already done
if (du_inc(map_w2(df)) == 0) then
  ... <do calculation>
end if

This is to prevent both columns trying to write to the same face (and is an optimisation in that it reduces duplication of computations). This is not safe for threading because there is no guarantee which thread will column will write to the face first. We seem to get away with this at the moment because our current tests ensure that both columns perform the same calculation to the bit level.

The solution is to use the face_selector objects to ensure that each face is only written to by a specified column.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions