-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Display Device Information | ||
* | ||
* Script to print out some information about the OpenCL devices | ||
* and platforms available on your system | ||
* | ||
* History: C++ version written by Tom Deakin, 2012 | ||
* Updated by Tom Deakin, August 2013 | ||
*/ | ||
|
||
#define __CL_ENABLE_EXCEPTIONS | ||
|
||
#include "cl.hpp" | ||
#include <iostream> | ||
#include <vector> | ||
|
||
int main(void) | ||
{ | ||
|
||
try | ||
{ | ||
// Discover number of platforms | ||
std::vector<cl::Platform> platforms; | ||
cl::Platform::get(&platforms); | ||
std::cout << "\nNumber of OpenCL plaforms: " << platforms.size() << std::endl; | ||
|
||
// Investigate each platform | ||
std::cout << "\n-------------------------" << std::endl; | ||
for (cl::Platform& plat : platforms) | ||
{ | ||
std::string s; | ||
plat.getInfo(CL_PLATFORM_NAME, &s); | ||
std::cout << "Platform: " << s << std::endl; | ||
|
||
plat.getInfo(CL_PLATFORM_VENDOR, &s); | ||
std::cout << "\tVendor: " << s << std::endl; | ||
|
||
plat.getInfo(CL_PLATFORM_VERSION, &s); | ||
std::cout << "\tVersion: " << s << std::endl; | ||
|
||
// Discover number of devices | ||
std::vector<cl::Device> devices; | ||
plat.getDevices(CL_DEVICE_TYPE_ALL, &devices); | ||
std::cout << "\n\tNumber of devices: " << devices.size() << std::endl; | ||
|
||
// Investigate each device | ||
for (cl::Device& dev : devices) | ||
{ | ||
std::cout << "\t-------------------------" << std::endl; | ||
|
||
dev.getInfo(CL_DEVICE_NAME, &s); | ||
std::cout << "\t\tName: " << s << std::endl; | ||
|
||
int i; | ||
dev.getInfo(CL_DEVICE_MAX_COMPUTE_UNITS, &i); | ||
std::cout << "\t\tMax. Compute Units: " << i << std::endl; | ||
|
||
size_t size; | ||
dev.getInfo(CL_DEVICE_LOCAL_MEM_SIZE, &size); | ||
std::cout << "\t\tLocal Memory Size: " << size/1024 << " KB" << std::endl; | ||
|
||
dev.getInfo(CL_DEVICE_GLOBAL_MEM_SIZE, &size); | ||
std::cout << "\t\tGlobal Memory Size: " << size/(1024*1024) << " MB" << std::endl; | ||
|
||
dev.getInfo(CL_DEVICE_MAX_MEM_ALLOC_SIZE, &size); | ||
std::cout << "\t\tMax Alloc Size: " << size/(1024*1024) << " MB" << std::endl; | ||
|
||
dev.getInfo(CL_DEVICE_MAX_WORK_GROUP_SIZE, &size); | ||
std::cout << "\t\tMax Work-group Size: " << size << std::endl; | ||
|
||
std::vector<size_t> d; | ||
dev.getInfo(CL_DEVICE_MAX_WORK_ITEM_SIZES, &d); | ||
std::cout << "\t\tMax Work-item Dims: ("; | ||
for (size_t& st : d) | ||
std::cout << st << " "; | ||
std::cout << "\x08)" << std::endl; | ||
|
||
std::cout << "\t-------------------------" << std::endl; | ||
|
||
} | ||
|
||
std::cout << "\n-------------------------\n"; | ||
} | ||
|
||
} | ||
catch (cl::Error err) | ||
{ | ||
std::cout << "OpenCL Error: " << err.what() << " returned " << err.err() << std::endl; | ||
std::cout << "Check cl.h for error codes." << std::endl; | ||
exit(-1); | ||
} | ||
|
||
return 0; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
CC=g++ | ||
|
||
CPP_COMMON = ../../Cpp_common | ||
|
||
CCFLAGS=-std=c++11 -std=gnu++11 | ||
|
||
INC = -I $(CPP_COMMON) | ||
|
||
LIBS = -lOpenCL | ||
|
||
# Check our platform and make sure we define the APPLE variable | ||
# and set up the right compiler flags and libraries | ||
PLATFORM = $(shell uname -s) | ||
ifeq ($(PLATFORM), Darwin) | ||
CCFLAGS += -DAPPLE | ||
LIBS = -framework OpenCL | ||
endif | ||
|
||
DeviceInfo: DeviceInfo.cpp | ||
$(CC) $^ $(INC) $(CCFLAGS) $(LIBS) -o $@ | ||
|
||
|
||
clean: | ||
rm -f DeviceInfo |