1
- cmake_minimum_required (VERSION 3.21 )
1
+ cmake_minimum_required (VERSION 3.25 FATAL_ERROR )
2
2
option (BUILD_FORTRAN_EXAMPLES "Whether to build fortran examples" ON )
3
3
set (CMAKE_C_COMPILER icx )
4
4
set (CMAKE_CXX_COMPILER icpx )
5
- set (_languages C CXX )
6
-
7
5
if (BUILD_FORTRAN_EXAMPLES )
8
- set (_languages ${_languages} Fortran )
9
6
set (CMAKE_Fortran_COMPILER ifx )
10
7
endif ()
11
8
12
- enable_testing ()
13
-
14
- project (GPUOptGuide
15
- LANGUAGES ${_languages}
16
- DESCRIPTION "Code examples from Intel GPU Optimization guide" )
17
-
9
+ project (GPUOptGuide )
18
10
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH )
19
11
12
+ include (CheckLanguage )
13
+ enable_testing ()
14
+
20
15
find_package (IntelSYCL REQUIRED )
21
16
17
+ if (BUILD_FOTRAN_EXAMPLES )
18
+ check_language (Fortran )
19
+ if (CMAKE_Fortran_COMPILER )
20
+ enable_language (Fortran )
21
+ else ()
22
+ message (FATAL_ERROR "No Fortran support detected, but Fortran tests were requested. Install oneAPI HPC Toolkit." )
23
+ endif ()
24
+ endif ()
25
+
22
26
set (MKL_THREADING tbb_thread )
23
- set (MKL_INTERFACE "ilp64" )
24
27
set (DPCPP_COMPILER ON )
25
-
26
- set (MKL_VERSION_2024 FALSE )
27
- find_package (MKL QUIET )
28
- if (MKL_FOUND )
29
- if (MKL_VERSION VERSION_GREATER_EQUAL "2024.0.0" )
30
- set (MKL_VERSION_2024 TRUE )
31
- endif ()
32
- endif ()
33
28
find_package (MKL REQUIRED )
34
29
35
30
string (CONCAT WARNING_CXX_FLAGS_STR
@@ -44,116 +39,155 @@ string(CONCAT WARNING_CXX_FLAGS_STR
44
39
string (REPLACE " " ";" COMMON_CXX_FLAGS "${WARNING_CXX_FLAGS_STR} " )
45
40
46
41
function (add_example_with_mkl name )
47
- set (_sources ${name} .cpp )
48
- add_executable (${name} ${_sources} )
49
- add_sycl_to_target (TARGET ${name} SOURCES ${_sources} )
50
- target_compile_options (${name} PRIVATE ${COMMON_CXX_FLAGS} )
51
- if (MKL_VERSION_2024 )
52
- target_link_libraries (${name} PUBLIC MKL::MKL_SYCL )
42
+ cmake_parse_arguments (FUNC_SRC "" "" "SOURCES" ${ARGN} )
43
+ if (FUNC_SRC_SOURCES )
44
+ set (_src ${FUNC_SRC_SOURCES} )
53
45
else ()
54
- target_link_libraries ( ${name} PUBLIC MKL::MKL_DPCPP )
46
+ set ( _src ${name} .cpp )
55
47
endif ()
48
+ add_executable (${name} ${_src} )
49
+ add_sycl_to_target (TARGET ${name} SOURCES ${_src} )
50
+ target_compile_options (${name} PRIVATE ${COMMON_CXX_FLAGS} )
51
+ target_compile_options (${name} PRIVATE -fiopenmp -fopenmp-targets=spir64 -qmkl )
52
+ target_link_libraries (${name} PRIVATE MKL::MKL_DPCPP )
53
+ target_link_options (${name} PRIVATE -fiopenmp -fopenmp-targets=spir64 -qmkl -lOpenCL )
56
54
add_test (NAME ${name} COMMAND ${name} ${ARGN} )
57
55
endfunction (add_example_with_mkl )
58
56
59
57
function (add_fortran_example_with_mkl name )
60
58
if (CMAKE_Fortran_COMPILER )
61
- set (_sources ${name} .f )
62
- add_executable (${name} ${_sources } )
63
- add_sycl_to_target (TARGET ${name} SOURCES ${_sources } )
59
+ set (_src ${name} .f )
60
+ add_executable (${name} ${_src } )
61
+ add_sycl_to_target (TARGET ${name} SOURCES ${_src } )
64
62
target_compile_options (${name} PRIVATE -warn all )
65
- target_compile_options (${name} PRIVATE -fpp -free -DMKL_ILP64 -i8 )
63
+ target_compile_options (${name} PRIVATE -fiopenmp -fopenmp-targets=spir64 -qmkl -fpp -free )
66
64
set_target_properties (${name} PROPERTIES LINKER_LANGUAGE Fortran )
67
- if (MKL_VERSION_2024 )
68
- target_link_libraries (${name} PUBLIC MKL::MKL_SYCL )
69
- else ()
70
- target_link_libraries (${name} PUBLIC MKL::MKL_DPCPP )
71
- endif ()
65
+ target_link_libraries (${name} PUBLIC MKL::MKL_DPCPP )
66
+ target_link_options (${name} PRIVATE -fiopenmp -fopenmp-targets=spir64 -qmkl -lOpenCL )
72
67
add_test (NAME ${name} COMMAND ${name} ${ARGN} )
73
68
endif ()
74
69
endfunction (add_fortran_example_with_mkl )
75
70
71
+ function (add_fortran_example_with_mkl_i8 name )
72
+ if (CMAKE_Fortran_COMPILER )
73
+ set (_src ${name} .f )
74
+ add_executable (${name} ${_src} )
75
+ add_sycl_to_target (TARGET ${name} SOURCES ${_src} )
76
+ target_compile_options (${name} PRIVATE -warn all )
77
+ target_compile_options (${name} PRIVATE -fiopenmp -fopenmp-targets=spir64 -qmkl -fpp -free -DMKL_ILP64 -i8 )
78
+ set_target_properties (${name} PROPERTIES LINKER_LANGUAGE Fortran )
79
+ target_link_libraries (${name} PUBLIC MKL::MKL_DPCPP )
80
+ target_link_options (${name} PRIVATE -fiopenmp -fopenmp-targets=spir64 -qmkl -lOpenCL )
81
+ add_test (NAME ${name} COMMAND ${name} ${ARGN} )
82
+ endif ()
83
+ endfunction (add_fortran_example_with_mkl_i8 )
84
+
76
85
function (add_example name )
77
- set (_sources ${name} .cpp )
78
- add_executable (${name} ${_sources} )
79
- add_sycl_to_target (TARGET ${name} SOURCES ${_sources} )
86
+ cmake_parse_arguments (FUNC_SRC "" "" "SOURCES" ${ARGN} )
87
+ if (FUNC_SRC_SOURCES )
88
+ set (_src ${FUNC_SRC_SOURCES} )
89
+ else ()
90
+ set (_src ${name} .cpp )
91
+ endif ()
92
+ add_executable (${name} ${_src} )
93
+ add_sycl_to_target (TARGET ${name} SOURCES ${_src} )
80
94
target_compile_options (${name} PRIVATE ${COMMON_CXX_FLAGS} )
81
95
target_link_options (${name} PRIVATE -fsycl-device-code-split=per_kernel )
82
96
add_test (NAME ${name} COMMAND ${name} ${ARGN} )
83
97
endfunction (add_example )
84
98
85
99
function (add_openmp_example name )
86
- set (_sources ${name} .cpp )
87
- add_executable (${name} ${_sources} )
100
+ set (_src ${name} .cpp )
101
+ add_executable (${name} ${_src} )
102
+ add_sycl_to_target (TARGET ${name} SOURCES ${_src} )
88
103
target_compile_options (${name} PRIVATE ${COMMON_CXX_FLAGS} )
89
104
add_test (NAME ${name} COMMAND ${name} ${ARGN} )
90
105
endfunction (add_openmp_example )
91
106
92
107
function (add_fortran_example name )
93
108
if (CMAKE_Fortran_COMPILER )
94
- set (_sources ${name} .f90 )
95
- add_executable (${name} ${_sources } )
96
- add_sycl_to_target (TARGET ${name} SOURCES ${_sources } )
109
+ set (_src ${name} .f90 )
110
+ add_executable (${name} ${_src } )
111
+ add_sycl_to_target (TARGET ${name} SOURCES ${_src } )
97
112
target_compile_options (${name} PRIVATE -warn all )
113
+ target_compile_options (${name} PRIVATE -fiopenmp -fopenmp-targets=spir64 )
98
114
set_target_properties (${name} PROPERTIES LINKER_LANGUAGE Fortran )
115
+ target_link_options (${name} PRIVATE -fiopenmp -fopenmp-targets=spir64 )
99
116
add_test (NAME ${name} COMMAND ${name} ${ARGN} )
100
117
endif ()
101
118
endfunction (add_fortran_example )
102
119
103
120
function (add_fixed_fortran_example name )
104
121
if (CMAKE_Fortran_COMPILER )
105
- set (_sources ${name} .f )
106
- add_executable (${name} ${_sources} )
122
+ set (_src ${name} .f )
123
+ add_executable (${name} ${_src} )
124
+ add_sycl_to_target (TARGET ${name} SOURCES ${_src} )
107
125
target_compile_options (${name} PRIVATE -warn all )
126
+ target_compile_options (${name} PRIVATE -fiopenmp -fopenmp-targets=spir64 )
108
127
set_target_properties (${name} PROPERTIES LINKER_LANGUAGE Fortran )
109
128
add_test (NAME ${name} COMMAND ${name} ${ARGN} )
110
129
endif ()
111
130
endfunction (add_fixed_fortran_example )
112
131
113
132
function (add_mpi_example name )
114
133
if (MPI_FOUND )
115
- set (_sources ${name} .cpp )
116
- add_executable (${name} ${_sources} )
117
- add_sycl_to_target (TARGET ${name} SOURCES ${_sources} )
134
+ set (_src ${name} .cpp )
135
+ add_executable (${name} ${_src} )
136
+ add_sycl_to_target (TARGET ${name} SOURCES ${_src} )
137
+ target_compile_options (${name} PRIVATE -O3 -fiopenmp -fopenmp-targets=spir64 )
138
+ target_link_options (${name} PRIVATE -O3 -fiopenmp -fopenmp-targets=spir64 )
118
139
target_link_libraries (${name} PRIVATE MPI::MPI_CXX )
119
140
add_test (NAME ${name} COMMAND ${name} ${ARGN} )
120
141
endif ()
121
142
endfunction (add_mpi_example )
122
143
144
+ function (add_example_with_mkl_mpi name )
145
+ if (MPI_FOUND )
146
+ set (_src ${name} .cpp )
147
+ add_executable (${name} ${_src} )
148
+ add_sycl_to_target (TARGET ${name} SOURCES ${_src} )
149
+ target_compile_options (${name} PRIVATE ${COMMON_CXX_FLAGS} )
150
+ if (NOT MKL_ROOT )
151
+ set (MKL_ROOT $ENV{MKLROOT} CACHE PATH "Folder contains MKL" )
152
+ endif (NOT MKL_ROOT )
153
+ target_compile_options (${name} PRIVATE -fiopenmp -fopenmp-targets=spir64 -fsycl -DMKL_LP64 -I "${MKLROOT} /include" )
154
+ target_link_options (${name} PRIVATE -fiopenmp -fopenmp-targets=spir64 -fsycl -L${MKLROOT}/lib -lmkl_sycl_blas -lmkl_intel_lp64 -lmkl_tbb_thread -lmkl_core -lsycl -lpthread -lm -ldl )
155
+ target_link_libraries (${name} PRIVATE MPI::MPI_CXX )
156
+ add_test (NAME ${name} COMMAND ${name} ${ARGN} )
157
+ endif ()
158
+ endfunction (add_example_with_mkl_mpi )
159
+
123
160
include_directories (${CMAKE_CURRENT_SOURCE_DIR} )
124
161
125
162
add_subdirectory (atomics )
126
- add_subdirectory (matrix )
163
+ add_subdirectory (buffer-accessors )
164
+ add_subdirectory (buffers )
165
+ add_subdirectory (composite-explicit-scaling )
166
+ add_subdirectory (conditionals )
127
167
add_subdirectory (exec-model )
128
- add_subdirectory (explicit-scaling )
168
+ add_subdirectory (flat )
169
+ add_subdirectory (fp-computations )
170
+ add_subdirectory (grf-mode-selection )
129
171
add_subdirectory (io-kernel )
130
172
add_subdirectory (jitting )
131
173
add_subdirectory (kernels )
132
- add_subdirectory (memory-movement )
133
- add_subdirectory (restrict )
134
- add_subdirectory (slm )
135
- add_subdirectory (usm )
136
- add_subdirectory (sub-group )
137
- add_subdirectory (buffers )
138
- add_subdirectory (buffer-accessors )
139
- add_subdirectory (reduction )
140
- add_subdirectory (conditionals )
174
+ add_subdirectory (libraries-fcorr )
141
175
add_subdirectory (libraries-kernel )
142
176
add_subdirectory (libraries-stdlib )
143
- add_subdirectory (libraries-fcorr )
144
- add_subdirectory (multiple-queue-submission )
177
+ add_subdirectory (matrix )
178
+ add_subdirectory (memory-movement )
179
+ add_subdirectory (MPI )
145
180
add_subdirectory (multiple-devices )
146
181
add_subdirectory (multiple-kernel-execution )
147
- add_subdirectory (work-group-size )
148
- add_subdirectory (registers )
182
+ add_subdirectory (multiple-queue-submission )
149
183
add_subdirectory (OpenMP )
150
184
add_subdirectory (optimize-data-transfers )
151
- add_subdirectory (MPI )
152
- add_subdirectory (grf-mode-selection )
153
- add_subdirectory (fp-computations )
154
- add_subdirectory (host-device-memory )
155
- add_subdirectory (joint-matrix )
156
- add_subdirectory (local-global-sync )
157
- # add_subdirectory(memory-sharing-with-media )
158
- add_subdirectory (redundant-queues )
159
- add_subdirectory (implicit-scaling )
185
+ add_subdirectory (porting-registers )
186
+ add_subdirectory (prefetch )
187
+ add_subdirectory (reduction )
188
+ add_subdirectory (registers )
189
+ add_subdirectory (restrict )
190
+ add_subdirectory (slm )
191
+ add_subdirectory (sub-group )
192
+ add_subdirectory (usm )
193
+ add_subdirectory (work-group-size )
0 commit comments