Fix for hipEnvVar test for titan machine
This commit is contained in:
@@ -53,6 +53,7 @@ int getDevicePCIBusNum(int deviceID){
|
||||
|
||||
int main() {
|
||||
unsetenv("HIP_VISIBLE_DEVICES");
|
||||
unsetenv("CUDA_VISIBLE_DEVICES");
|
||||
//collect the device pci bus ID for all devices
|
||||
int totalDeviceNum = getDeviceNumber();
|
||||
std::cout << "The total number of available devices is " << totalDeviceNum<< std::endl
|
||||
@@ -68,6 +69,7 @@ int main() {
|
||||
//query the returned device pci bus number, check if match the database
|
||||
for (int i = 0; i < totalDeviceNum ; i++) {
|
||||
setenv("HIP_VISIBLE_DEVICES",(char*)std::to_string(i).c_str(),1);
|
||||
setenv("CUDA_VISIBLE_DEVICES",(char*)std::to_string(i).c_str(),1);
|
||||
//cout<<"HIP_VISIBLE_DEVICES is "<<i<<" data in vector is "<<devPCINum[i]<<endl;
|
||||
//std::cout <<"Returned pci number is"<< getDevicePCIBusNum(0) << std::endl;
|
||||
if (devPCINum[i] != getDevicePCIBusNum(0)) {
|
||||
@@ -81,21 +83,26 @@ int main() {
|
||||
|
||||
//check when set an invalid device number
|
||||
setenv("HIP_VISIBLE_DEVICES","1000,0,1",1);
|
||||
setenv("CUDA_VISIBLE_DEVICES","1000,0,1",1);
|
||||
assert(getDeviceNumber() == 0);
|
||||
|
||||
if(totalDeviceNum > 2){
|
||||
setenv("HIP_VISIBLE_DEVICES","0,1,1000,2",1);
|
||||
setenv("CUDA_VISIBLE_DEVICES","0,1,1000,2",1);
|
||||
assert(getDeviceNumber() == 2);
|
||||
|
||||
setenv("HIP_VISIBLE_DEVICES","0,1,2",1);
|
||||
setenv("CUDA_VISIBLE_DEVICES","0,1,2",1);
|
||||
assert(getDeviceNumber() == 3);
|
||||
// test if CUDA_VISIBLE_DEVICES will be accepted by the runtime
|
||||
unsetenv("HIP_VISIBLE_DEVICES");
|
||||
unsetenv("CUDA_VISIBLE_DEVICES");
|
||||
setenv("CUDA_VISIBLE_DEVICES","0,1,2",1);
|
||||
assert(getDeviceNumber() == 3);
|
||||
}
|
||||
|
||||
setenv("HIP_VISIBLE_DEVICES","-100,0,1",1);
|
||||
setenv("CUDA_VISIBLE_DEVICES","-100,0,1",1);
|
||||
assert(getDeviceNumber() == 0);
|
||||
|
||||
std::cout << "PASSED" << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user