Merge pull request #110 from sunway513/fix_hipEnvVar_test

Fix hipEnvVar test
Этот коммит содержится в:
Ben Sander
2017-07-27 13:03:43 -05:00
коммит произвёл GitHub
родитель 526fcb1223 ed0d6cf745
Коммит 9cede50942
3 изменённых файлов: 41 добавлений и 36 удалений
поставляемый
+1 -1
Просмотреть файл
@@ -119,7 +119,7 @@ def docker_build_inside_image( def build_image, String inside_args, String platf
cd ${build_dir_rel}
make install -j\$(nproc)
make build_tests -j\$(nproc)
ctest -E hipEnvVarDriver
make test
"""
// If unit tests output a junit or xunit file in the future, jenkins can parse that file
// to display test results on the dashboard
+7 -8
Просмотреть файл
@@ -109,15 +109,14 @@ int main(int argc, char **argv)
std::cout << devCount << std::endl;
}
if (retDevInfo) {
hipSetDevice(device);
hipDeviceProp_t devProp;
hipDevice_t deviceT;
hipDeviceGet(&deviceT, device);
hipGetDeviceProperties(&devProp, device);
if (devProp.major < 1) {
printf("%d does not support HIP\n", device);
return -1;
}
std::cout << devProp.pciBusID << std::endl;
char pciBusId[100];
memset(pciBusId,0,100);
hipDeviceGetPCIBusId(pciBusId,100,deviceT);
cout<<pciBusId<<endl;
}
exit(0);
}
+33 -27
Просмотреть файл
@@ -28,59 +28,64 @@ THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include <assert.h>
#include <string>
#include "hip/hip_runtime.h"
#include <chrono>
#include <thread>
using namespace std;
int getDeviceNumber(){
FILE *in;
char buff[512];
string str;
if(!(in = popen("./hipEnvVar -c", "r"))){
return 1;
FILE *in;
char buff[512];
string str;
std::this_thread::sleep_for(std::chrono::milliseconds(10));
if(!(in = popen("./directed_tests/hipEnvVar -c", "r"))){
return 1;
}
while(fgets(buff, 512, in)!=NULL){
cout << buff;
}
fgets(buff, sizeof(buff), in);
pclose(in);
return atoi(buff);
}
// Query the current device ID remotely to hipEnvVar
int getDevicePCIBusNumRemote(int deviceID){
void getDevicePCIBusNumRemote(int deviceID, char* pciBusID){
FILE *in;
char buff[512];
string str = "./hipEnvVar -d ";
string str = "./directed_tests/hipEnvVar -d ";
str += std::to_string(deviceID);
std::this_thread::sleep_for(std::chrono::milliseconds(10));
if(!(in = popen(str.c_str(), "r"))){
return 1;
exit(1);
}
while(fgets(pciBusID, 100, in)!=NULL){
cout << pciBusID;
}
fgets(buff, sizeof(buff), in);
pclose(in);
return atoi(buff);
}
// Query the current device ID locally
int getDevicePCIBusNum(int deviceID){
hipSetDevice(deviceID);
hipDeviceProp_t devProp;
// Query the current device ID locally on AMD path
void getDevicePCIBusNum(int deviceID, char* pciBusID){
hipDevice_t deviceT;
hipDeviceGet(&deviceT, deviceID);
hipGetDeviceProperties(&devProp, deviceID);
if (devProp.major < 1) {
printf("%d does not support HIP\n", deviceID);
return -1;
}
return devProp.pciBusID;
memset(pciBusID,0,100);
hipDeviceGetPCIBusId(pciBusID,100,deviceT);
}
int main() {
unsetenv("HIP_VISIBLE_DEVICES");
unsetenv("CUDA_VISIBLE_DEVICES");
std::vector<std::string> devPCINum;
char pciBusID[100];
//collect the device pci bus ID for all devices
int totalDeviceNum = getDeviceNumber();
std::cout << "The total number of available devices is " << totalDeviceNum<< std::endl
<<"Valid index range is 0 - "<<totalDeviceNum-1<<std::endl;
std::vector<int> devPCINum;
for (int i = 0; i < totalDeviceNum ; i++) {
devPCINum.push_back(getDevicePCIBusNum(i));
getDevicePCIBusNum(i, pciBusID);
devPCINum.push_back(pciBusID);
std::cout <<"The collected device PCI Bus ID of Device "<<i<<" is "
<< getDevicePCIBusNum(i) << std::endl;
<< devPCINum.back() << std::endl;
}
//select each of the available devices to be the target device,
@@ -88,9 +93,10 @@ int main() {
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);
if (devPCINum[i] != getDevicePCIBusNumRemote(0)) {
getDevicePCIBusNumRemote(0, pciBusID);
if (devPCINum[i] == pciBusID) {
std::cout << "The returned PciBusID is not correct"<< std::endl;
std::cout << "Expected "<< devPCINum[i] << ", but get " << getDevicePCIBusNum(i) << endl;
std::cout << "Expected "<< devPCINum[i] << ", but get " << pciBusID << endl;
exit(-1);
} else {
continue;