Issue with static global variables in TensorDeviceCuda
@ggael
Submitted by Gael GuennebaudAssigned to Nobody
Link to original bugzilla bug (#1475)
Version: 3.4 (development)
Description
Reported by Sun Chenggen:
I found a bug in TensorDeviceCuda.h
In line 40~41 m_deviceProperties and m_devicePropInitialized are defined as global static variable, which would generate different copies in different translation unit, if you call initializeDeviceProp() in one translation unit and use GpuDevice in another, you will find m_deviceProperties is still zero.
I think the two variables should be inline instead of static, may be implement like below:
inline cudaDeviceProp*& getDeviceProerties(){
static cudaDeviceProp* deviceProperties;
return deviceProperties;
}
inline bool& getDevicePropInitialized(){
static bool devicePropInitialized = false;
return devicePropInitialized;
}