Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Commit

Permalink
dev detection disable pretty print by default
Browse files Browse the repository at this point in the history
  • Loading branch information
S74nk0 committed Mar 3, 2017
1 parent 7486594 commit 02bc7c5
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 15 deletions.
10 changes: 7 additions & 3 deletions AMDOpenCLDeviceDetection/main.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#include "AMDOpenCLDeviceDetection.h"

int main() {
int main(int argc, char* argv[]) {
AMDOpenCLDeviceDetection AMDOpenCLDeviceDetection;
if (AMDOpenCLDeviceDetection.QueryDevices()) {
//AMDOpenCLDeviceDetection.PrintDevicesJson();
AMDOpenCLDeviceDetection.PrintDevicesJsonDirty();
if (argc < 2) {
AMDOpenCLDeviceDetection.PrintDevicesJsonDirty();
}
else {
AMDOpenCLDeviceDetection.PrintDevicesJson();
}
}
return 0;
}
Expand Down
56 changes: 47 additions & 9 deletions CudaDeviceDetection/CudaDetection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ void CudaDetection::PrintDevicesJson() {
cout << endl << "]" << endl;
}

void CudaDetection::print(CudaDevice &dev) {
cout << "DeviceID : " << dev.DeviceID << endl;
cout << "DeviceName : " << dev.DeviceName << endl;
cout << "SMVersionString : " << dev.SMVersionString << endl;
cout << "UUID : " << dev.UUID << endl;
cout << "DeviceGlobalMemory : " << dev.DeviceGlobalMemory << endl;
cout << "pciDeviceId : " << dev.pciDeviceId << endl;
cout << "pciSubSystemId : " << dev.pciSubSystemId << endl << endl;
}
//void CudaDetection::print(CudaDevice &dev) {
// cout << "DeviceID : " << dev.DeviceID << endl;
// cout << "DeviceName : " << dev.DeviceName << endl;
// cout << "SMVersionString : " << dev.SMVersionString << endl;
// cout << "UUID : " << dev.UUID << endl;
// cout << "DeviceGlobalMemory : " << dev.DeviceGlobalMemory << endl;
// cout << "pciDeviceId : " << dev.pciDeviceId << endl;
// cout << "pciSubSystemId : " << dev.pciSubSystemId << endl << endl;
//}

void CudaDetection::json_print(CudaDevice &dev) {
cout << "\t{" << endl;
Expand All @@ -129,4 +129,42 @@ void CudaDetection::json_print(CudaDevice &dev) {
cout << "\t\t\"pciSubSystemId\" : " << dev.pciSubSystemId << "," << endl; // num
cout << "\t\t\"SMX\" : " << dev.SMX << endl; // num
cout << "\t}";
}

// non human readable print
void CudaDetection::PrintDevicesJson_d() {
cout << "[";
for (int i = 0; i < _cudaDevices.size() - 1; ++i) {
json_print_d(_cudaDevices[i]);
cout << ",";
}
json_print_d(_cudaDevices[_cudaDevices.size() - 1]);
cout << "]" << endl;
}

//void CudaDetection::print_d(CudaDevice &dev) {
// cout << "DeviceID : " << dev.DeviceID ;
// cout << "DeviceName : " << dev.DeviceName ;
// cout << "SMVersionString : " << dev.SMVersionString ;
// cout << "UUID : " << dev.UUID ;
// cout << "DeviceGlobalMemory : " << dev.DeviceGlobalMemory ;
// cout << "pciDeviceId : " << dev.pciDeviceId ;
// cout << "pciSubSystemId : " << dev.pciSubSystemId ;
//}

void CudaDetection::json_print_d(CudaDevice &dev) {
cout << "{";
cout << "\"DeviceID\" : " << dev.DeviceID << ","; // num
cout << "\"VendorID\" : " << dev.VendorID << ","; // num
cout << "\"VendorName\" : \"" << dev.VendorName << "\","; // string
cout << "\"DeviceName\" : \"" << dev.DeviceName << "\","; // string
cout << "\"SMVersionString\" : \"" << dev.SMVersionString << "\","; // string
cout << "\"SM_major\" : " << dev.SM_major << ","; // num
cout << "\"SM_minor\" : " << dev.SM_minor << ","; // num
cout << "\"UUID\" : \"" << dev.UUID << "\","; // string
cout << "\"DeviceGlobalMemory\" : " << dev.DeviceGlobalMemory << ","; // num
cout << "\"pciDeviceId\" : " << dev.pciDeviceId << ","; // num
cout << "\"pciSubSystemId\" : " << dev.pciSubSystemId << ","; // num
cout << "\"SMX\" : " << dev.SMX; // num
cout << "}";
}
6 changes: 5 additions & 1 deletion CudaDeviceDetection/CudaDetection.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ class CudaDetection

bool QueryDevices();
void PrintDevicesJson();
void PrintDevicesJson_d();

private:

void print(CudaDevice &dev);
//void print(CudaDevice &dev);
void json_print(CudaDevice &dev);

//void print_d(CudaDevice &dev);
void json_print_d(CudaDevice &dev);

std::vector<std::string> _errorMsgs;
std::vector<CudaDevice> _cudaDevices;

Expand Down
9 changes: 7 additions & 2 deletions CudaDeviceDetection/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
// TODO maybe add nvml.dll check
//#include <Windows.h>

int main() {
int main(int argc, char* argv[]) {
CudaDetection detection;
if (detection.QueryDevices()) {
detection.PrintDevicesJson();
if (argc < 2) {
detection.PrintDevicesJson_d();
}
else {
detection.PrintDevicesJson();
}
}
return 0;
}

0 comments on commit 02bc7c5

Please sign in to comment.