ASL 0.1.7
Advanced Simulation Library
Loading...
Searching...
No Matches
asl-hardware.cc
Go to the documentation of this file.
1/*
2 * Advanced Simulation Library <http://asl.org.il>
3 *
4 * Copyright 2015 Avtech Scientific <http://avtechscientific.com>
5 *
6 *
7 * This file is part of Advanced Simulation Library (ASL).
8 *
9 * ASL is free software: you can redistribute it and/or modify it
10 * under the terms of the GNU Affero General Public License as
11 * published by the Free Software Foundation, version 3 of the License.
12 *
13 * ASL is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with ASL. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23
29#include "acl/aclHardware.h"
30#include "aslUtilities.h"
31
32using namespace acl;
33using namespace std;
34using namespace asl;
35
36string typeToString(unsigned int t)
37{
38 string s;
39 switch (t)
40 {
41 case CL_DEVICE_TYPE_CPU : s="CPU"; break;
42 case CL_DEVICE_TYPE_GPU : s="GPU"; break;
43 case CL_DEVICE_TYPE_ACCELERATOR : s="ACCELERATOR"; break;
44 case CL_DEVICE_TYPE_DEFAULT : s="DEFAULT"; break;
45// case CL_DEVICE_TYPE_CUSTOM : s="CUSTOM"; break; //in opencl 1.1 is undefined
46 default: s="type is unknown";
47 }
48 return s;
49}
50
52{
53
54 cout << "\t\ttype: " << typeToString(getDeviceType(queue)) << endl;
55 cout << "\t\tnumber of compute units: " << getNComputeUnits(queue) << endl;
56 cout << "\t\talignment: " << getAlignment(queue) << endl;
57 cout << "\t\tlocal memory type: "
58 << (getLocalMemoryType(queue) == CL_LOCAL ? "CL_LOCAL" : "CL_GLOBAL") << endl;
59 cout << "\t\tlocal memory size: " << getLocalMemorySize(queue) << endl;
60 cout << "\t\tmax item size: " << getMaxItemSize(queue) << endl;
61 cout << "\t\tvector width float: " << getVectorWidth(queue, TYPE_FLOAT) << endl;
62 cout << "\t\tvector width double: " << getVectorWidth(queue, TYPE_DOUBLE) << endl;
63 cout << "\t\textension CL_KHR_FP64: "
65 cout << "\t\textension CL_KHR_INT64_EXTENDED_ATOMICS: "
67 cout << "\t\tsupported OpenCL version: " << getDeviceVersion(queue) << endl;
68 cout << "\t\tOpenCL driver version: "<< getDriverVersion(queue) << endl;
69}
70
71
72int main()
73{
74
75 // Have a look at the available platforms and their devices
80 CommandQueue queue;
81
82 cl_int status = 0;
84 errorMessage(status, "Platform::get()");
85
86 if (platforms.size() > 0)
87 {
88 for (unsigned int i = 0; i < platforms.size(); ++i)
89 {
90 status = platforms[i].getDevices(CL_DEVICE_TYPE_ALL, &devices);
91 errorMessage(status, "Platform::getDevices()");
92 cout << "Platform: " << platforms[i].getInfo<CL_PLATFORM_VENDOR>()
93 << "\nNumber of devices: " << devices.size() << endl;
94
97 cps[2] = 0;
98
99 for (unsigned int j = 0; j < devices.size(); ++j)
100 {
101 // Create an OpenCL context for the current device
103 errorMessage(status, "Context::Context()");
104
105 // Create an OpenCL command queue for current context and device
107 errorMessage(status, "CommandQueue::CommandQueue()");
108
109 cout << "\t" << devices[j].getInfo<CL_DEVICE_NAME>() << endl;
110 printHardwareInfo(queue);
111 cout << endl;
112 }
113 cout << endl;
114 }
115 }
116
117 return 0;
118}
void printHardwareInfo(const CommandQueue &queue)
string typeToString(unsigned int t)
int main()
CommandQueue interface for cl_command_queue.
Definition cl.hpp:5355
Class interface for cl_context.
Definition cl.hpp:2343
static cl_int get(VECTOR_CLASS< Platform > *platforms)
Gets a list of available platforms.
Definition cl.hpp:2211
SPDataWrapperACLData generateDataContainerACL_SP(const Block &b, unsigned int n=1)
generates pointer to ACL Data field with n components
void errorMessage(cl_int status, const char *errorMessage)
Prints errorMessage and exits depending on the status.
size_t getMaxItemSize(const CommandQueue &queue)
cl_uint getVectorWidth(const CommandQueue &queue, const TypeID typeID)
cl_device_type getDeviceType(const CommandQueue &queue)
bool extensionAvailable(const CommandQueue &queue, const Extension extension)
cl_uint getNComputeUnits(const CommandQueue &queue)
unsigned int getAlignment(const CommandQueue &queue)
cl_ulong getLocalMemorySize(const CommandQueue &queue)
cl_device_local_mem_type getLocalMemoryType(const CommandQueue &queue)
Advanced Computational Language.
Definition acl.h:41
std::shared_ptr< cl::CommandQueue > CommandQueue
Definition acl.h:51
std::string getDriverVersion(const CommandQueue &queue)
@ CL_KHR_FP64
Definition aclTypes.h:31
@ CL_KHR_INT64_EXTENDED_ATOMICS
Definition aclTypes.h:33
@ TYPE_DOUBLE
Definition aclTypes.h:43
@ TYPE_FLOAT
Definition aclTypes.h:42
std::string getDeviceVersion(const CommandQueue &queue)
Advanced Simulation Library.
Definition aslDataInc.h:31
STL namespace.