Skip to content

gas_optical_depths_minor_kernel contains a race condition #23

@stijnh

Description

@stijnh

The implementation of gas_optical_depths_minor_kernel has a synchronization bug.

}
}
scalings[threadIdx.z][threadIdx.y] = scaling;
}
__syncthreads();
scaling = scalings[threadIdx.z][threadIdx.y];
const int gpt_start = minor_limits_gpt[2*imnr]-1;

This kernel writes to shared memory, calls __syncthreads, and then reads from shared memory again. However, some threads might already start the next iteration and overwrite shared memory before other threads could read shared memory from the previous iteration.

Verification shows that thus bug indeed sometimes occurs.

The solution would be to have another __syncthreads on L593 after reading scalings

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions