Similar to the linked question
I am confronted with the "atomicCAS" & "atomicExch" identifiers not found errors. I searched online for solutions but still cannot solve my problem.
I also changed Code Generation to compute_20, sm_20 in project configuration:
"Configuration Properties -> CUDA C/C++ -> Device -> Code Generation"
When I tried to "edit" this item, I found "Inherited values: compute_10,sm_10".
Moreover, when I tried to right-click the function "atomicCAS" or "atomicExch" and select from the menu "Go To Definition (F12)", I found that it points to "$(CudaToolkitIncludeDir)\sm_11_atomic_functions.h(191)".
1. How to get over the inherited compute_10, sm_10 values ?
2. Why does it use atomic functions from sm_11_atomic_functions.h instead of sm_20_atomic_functions?
3. Or anyone can helps to describe in detail how to solve this problem.
Thank you very much.
Update:
Let's take a look at the following code for example.
struct Lock {
int *mutex;
Lock( void ) {
HANDLE_ERROR( cudaMalloc( (void**)&mutex, sizeof(int) ) );
HANDLE_ERROR( cudaMemset( mutex, 0, sizeof(int) ) );
}
~Lock( void ) {
cudaFree( mutex );
}
__device__ void lock( void ) {
#if __CUDA_ARCH__ >= 200
while( atomicCAS( mutex, 0, 1 ) != 0 );
#endif
}
__device__ void unlock( void ) {
#if __CUDA_ARCH__ >= 200
atomicExch( mutex, 0 );
#endif
}
};
I got a message: A definition for the symbol '__CUDA_ARCH__
' could not be located.