-
Notifications
You must be signed in to change notification settings - Fork 248
/
Copy pathoclc_extensions.cpp
180 lines (138 loc) · 7.6 KB
/
oclc_extensions.cpp
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/*
* Copyright (C) 2018-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/compiler_interface/oclc_extensions.h"
#include "shared/source/compiler_interface/oclc_extensions_extra.h"
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/helpers/compiler_product_helper.h"
#include "shared/source/helpers/hw_info.h"
#include "shared/source/helpers/string.h"
#include <sstream>
#include <string>
namespace NEO {
void getOpenclCFeaturesList(const HardwareInfo &hwInfo, OpenClCFeaturesContainer &openclCFeatures, const CompilerProductHelper &compilerProductHelper, const ReleaseHelper *releaseHelper) {
cl_name_version openClCFeature;
openClCFeature.version = CL_MAKE_VERSION(3, 0, 0);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_int64");
openclCFeatures.push_back(openClCFeature);
if (hwInfo.capabilityTable.supportsImages) {
openclCFeatures.reserve(3);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_3d_image_writes");
openclCFeatures.push_back(openClCFeature);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_images");
openclCFeatures.push_back(openClCFeature);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_read_write_images");
openclCFeatures.push_back(openClCFeature);
}
if (hwInfo.capabilityTable.supportsOcl21Features) {
openclCFeatures.reserve(8);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_atomic_order_acq_rel");
openclCFeatures.push_back(openClCFeature);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_atomic_order_seq_cst");
openclCFeatures.push_back(openClCFeature);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_atomic_scope_all_devices");
openclCFeatures.push_back(openClCFeature);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_atomic_scope_device");
openclCFeatures.push_back(openClCFeature);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_generic_address_space");
openclCFeatures.push_back(openClCFeature);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_program_scope_global_variables");
openclCFeatures.push_back(openClCFeature);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_work_group_collective_functions");
openclCFeatures.push_back(openClCFeature);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_subgroups");
openclCFeatures.push_back(openClCFeature);
if (hwInfo.capabilityTable.supportsFloatAtomics) {
openclCFeatures.reserve(8);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_ext_fp32_global_atomic_add");
openclCFeatures.push_back(openClCFeature);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_ext_fp32_local_atomic_add");
openclCFeatures.push_back(openClCFeature);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_ext_fp32_global_atomic_min_max");
openclCFeatures.push_back(openClCFeature);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_ext_fp32_local_atomic_min_max");
openclCFeatures.push_back(openClCFeature);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_ext_fp16_global_atomic_load_store");
openclCFeatures.push_back(openClCFeature);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_ext_fp16_local_atomic_load_store");
openclCFeatures.push_back(openClCFeature);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_ext_fp16_global_atomic_min_max");
openclCFeatures.push_back(openClCFeature);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_ext_fp16_local_atomic_min_max");
openclCFeatures.push_back(openClCFeature);
}
}
auto forcePipeSupport = debugManager.flags.ForcePipeSupport.get();
if ((hwInfo.capabilityTable.supportsPipes && (forcePipeSupport == -1)) ||
(forcePipeSupport == 1)) {
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_pipes");
openclCFeatures.push_back(openClCFeature);
}
auto forceFp64Support = debugManager.flags.OverrideDefaultFP64Settings.get();
if ((hwInfo.capabilityTable.ftrSupportsFP64 && (forceFp64Support == -1)) ||
(forceFp64Support == 1)) {
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_fp64");
openclCFeatures.push_back(openClCFeature);
if (hwInfo.capabilityTable.supportsOcl21Features && hwInfo.capabilityTable.supportsFloatAtomics) {
openclCFeatures.reserve(4);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_ext_fp64_global_atomic_add");
openclCFeatures.push_back(openClCFeature);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_ext_fp64_local_atomic_add");
openclCFeatures.push_back(openClCFeature);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_ext_fp64_global_atomic_min_max");
openclCFeatures.push_back(openClCFeature);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_ext_fp64_local_atomic_min_max");
openclCFeatures.push_back(openClCFeature);
}
}
if (compilerProductHelper.isDotIntegerProductExtensionSupported()) {
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_integer_dot_product_input_4x8bit");
openclCFeatures.push_back(openClCFeature);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_integer_dot_product_input_4x8bit_packed");
openclCFeatures.push_back(openClCFeature);
}
getOpenclCFeaturesListExtra(releaseHelper, openclCFeatures);
}
std::string convertEnabledExtensionsToCompilerInternalOptions(const char *enabledExtensions,
OpenClCFeaturesContainer &openclCFeatures) {
std::string extensionsList = enabledExtensions;
extensionsList.reserve(1500);
extensionsList = " -cl-ext=-all,";
std::istringstream extensionsStringStream(enabledExtensions);
std::string extension;
while (extensionsStringStream >> extension) {
extensionsList.append("+");
extensionsList.append(extension);
extensionsList.append(",");
}
for (auto &feature : openclCFeatures) {
extensionsList.append("+");
extensionsList.append(feature.name);
extensionsList.append(",");
}
extensionsList[extensionsList.size() - 1] = ' ';
return extensionsList;
}
std::string getOclVersionCompilerInternalOption(unsigned int oclVersion) {
switch (oclVersion) {
case 30:
return "-ocl-version=300 ";
case 21:
return "-ocl-version=210 ";
default:
return "-ocl-version=120 ";
}
}
cl_version getOclCExtensionVersion(std::string name, cl_version defaultVer) {
if (name.compare("cl_khr_integer_dot_product") == 0) {
return CL_MAKE_VERSION(2u, 0, 0);
} else if (name.compare("cl_khr_external_memory") == 0) {
return CL_MAKE_VERSION(0, 9u, 1u);
} else {
return defaultVer;
}
}
} // namespace NEO