-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathmain.cpp
More file actions
150 lines (129 loc) · 6.06 KB
/
main.cpp
File metadata and controls
150 lines (129 loc) · 6.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
// Copyright (c) 2021-2026 Ben Ashbaugh
//
// SPDX-License-Identifier: MIT
*/
#include <stdio.h>
#include <vector>
#include <popl/popl.hpp>
#include <CL/cl_ext.h>
#include <CL/opencl.hpp>
#include "util.hpp"
static void PrintDeviceType(
const char* label,
cl_device_type type )
{
printf("%s%s%s%s%s%s\n",
label,
( type & CL_DEVICE_TYPE_DEFAULT ) ? "DEFAULT " : "",
( type & CL_DEVICE_TYPE_CPU ) ? "CPU " : "",
( type & CL_DEVICE_TYPE_GPU ) ? "GPU " : "",
( type & CL_DEVICE_TYPE_ACCELERATOR ) ? "ACCELERATOR " : "",
( type & CL_DEVICE_TYPE_CUSTOM ) ? "CUSTOM " : "");
}
static void PrintQueueProperties(
cl_command_queue_properties props )
{
if (props & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE ) printf("\t\t\tCL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE\n");
if (props & CL_QUEUE_PROFILING_ENABLE ) printf("\t\t\tCL_QUEUE_PROFILING_ENABLE\n");
#ifdef CL_VERSION_2_0
if (props & CL_QUEUE_ON_DEVICE ) printf("\t\t\tCL_QUEUE_ON_DEVICE\n");
if (props & CL_QUEUE_ON_DEVICE_DEFAULT ) printf("\t\t\tCL_QUEUE_ON_DEVICE_DEFAULT\n");
#endif
}
static void PrintQueueCapabilities(
cl_command_queue_capabilities_intel caps )
{
if (caps == CL_QUEUE_DEFAULT_CAPABILITIES_INTEL) {
printf("\t\t\tDEFAULT\n");
} else {
if (caps & CL_QUEUE_CAPABILITY_CREATE_SINGLE_QUEUE_EVENTS_INTEL ) printf("\t\t\tCREATE_SINGLE_QUEUE_EVENTS_INTEL\n");
if (caps & CL_QUEUE_CAPABILITY_CREATE_CROSS_QUEUE_EVENTS_INTEL ) printf("\t\t\tCREATE_CROSS_QUEUE_EVENTS_INTEL\n");
if (caps & CL_QUEUE_CAPABILITY_SINGLE_QUEUE_EVENT_WAIT_LIST_INTEL ) printf("\t\t\tSINGLE_QUEUE_EVENT_WAIT_LIST_INTEL\n");
if (caps & CL_QUEUE_CAPABILITY_CROSS_QUEUE_EVENT_WAIT_LIST_INTEL ) printf("\t\t\tCROSS_QUEUE_EVENT_WAIT_LIST_INTEL\n");
if (caps & CL_QUEUE_CAPABILITY_TRANSFER_BUFFER_INTEL ) printf("\t\t\tTRANSFER_BUFFER_INTEL\n");
if (caps & CL_QUEUE_CAPABILITY_TRANSFER_BUFFER_RECT_INTEL ) printf("\t\t\tTRANSFER_BUFFER_RECT_INTEL\n");
if (caps & CL_QUEUE_CAPABILITY_MAP_BUFFER_INTEL ) printf("\t\t\tMAP_BUFFER_INTEL\n");
if (caps & CL_QUEUE_CAPABILITY_FILL_BUFFER_INTEL ) printf("\t\t\tFILL_BUFFER_INTEL\n");
if (caps & CL_QUEUE_CAPABILITY_TRANSFER_IMAGE_INTEL ) printf("\t\t\tTRANSFER_IMAGE_INTEL\n");
if (caps & CL_QUEUE_CAPABILITY_MAP_IMAGE_INTEL ) printf("\t\t\tMAP_IMAGE_INTEL\n");
if (caps & CL_QUEUE_CAPABILITY_FILL_IMAGE_INTEL ) printf("\t\t\tFILL_IMAGE_INTEL\n");
if (caps & CL_QUEUE_CAPABILITY_TRANSFER_BUFFER_IMAGE_INTEL ) printf("\t\t\tTRANSFER_BUFFER_IMAGE_INTEL\n");
if (caps & CL_QUEUE_CAPABILITY_TRANSFER_IMAGE_BUFFER_INTEL ) printf("\t\t\tTRANSFER_IMAGE_BUFFER_INTEL\n");
if (caps & CL_QUEUE_CAPABILITY_MARKER_INTEL ) printf("\t\t\tMARKER_INTEL\n");
if (caps & CL_QUEUE_CAPABILITY_BARRIER_INTEL ) printf("\t\t\tBARRIER_INTEL\n");
if (caps & CL_QUEUE_CAPABILITY_KERNEL_INTEL ) printf("\t\t\tKERNEL_INTEL\n");
}
}
static void PrintPlatformInfoSummary(
cl::Platform platform )
{
printf("\tName: %s\n", platform.getInfo<CL_PLATFORM_NAME>().c_str() );
printf("\tVendor: %s\n", platform.getInfo<CL_PLATFORM_VENDOR>().c_str() );
printf("\tPlatform Version: %s\n", platform.getInfo<CL_PLATFORM_VERSION>().c_str() );
}
static void PrintDeviceInfoSummary(
const std::vector<cl::Device>& devices )
{
size_t i = 0;
for( i = 0; i < devices.size(); i++ )
{
printf("Device[%d]:\n", (int)i );
cl_device_type deviceType = devices[i].getInfo<CL_DEVICE_TYPE>();
PrintDeviceType("\tType: ", deviceType);
printf("\tName: %s\n", devices[i].getInfo<CL_DEVICE_NAME>().c_str() );
printf("\tVendor: %s\n", devices[i].getInfo<CL_DEVICE_VENDOR>().c_str() );
printf("\tDevice Version: %s\n", devices[i].getInfo<CL_DEVICE_VERSION>().c_str() );
printf("\tDriver Version: %s\n", devices[i].getInfo<CL_DRIVER_VERSION>().c_str() );
if (checkDeviceForExtension(devices[i], "cl_intel_command_queue_families")) {
cl_int test;
std::vector<cl_queue_family_properties_intel> qfprops =
devices[i].getInfo<CL_DEVICE_QUEUE_FAMILY_PROPERTIES_INTEL>(&test);
for ( size_t q = 0; q < qfprops.size(); q++ ) {
printf("\tQueue Family %i:\n", (int)q);
printf("\t\tName: %s\n", qfprops[q].name);
printf("\t\tCount: %u\n", qfprops[q].count);
printf("\t\tProperties:\n");
PrintQueueProperties(qfprops[q].properties);
printf("\t\tCapabilities:\n");
PrintQueueCapabilities(qfprops[q].capabilities);
}
} else {
printf("\tThis device does not support cl_intel_command_queue_families.\n");
}
}
}
int main(
int argc,
char** argv )
{
{
popl::OptionParser op("Supported Options");
bool printUsage = false;
try {
op.parse(argc, argv);
} catch (std::exception& e) {
fprintf(stderr, "Error: %s\n\n", e.what());
printUsage = true;
}
if (printUsage || !op.unknown_options().empty() || !op.non_option_args().empty()) {
fprintf(stderr,
"Usage: enumqueuefamilies [options]\n"
"%s", op.help().c_str());
return -1;
}
}
std::vector<cl::Platform> platforms;
cl::Platform::get(&platforms);
for( auto& platform : platforms )
{
printf( "Platform:\n" );
PrintPlatformInfoSummary( platform );
std::vector<cl::Device> devices;
platform.getDevices(CL_DEVICE_TYPE_ALL, &devices);
PrintDeviceInfoSummary( devices );
printf( "\n" );
}
printf( "Done.\n" );
return 0;
}