forked from kokkos/kokkos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
469 lines (432 loc) · 12.7 KB
/
CMakeLists.txt
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
#Leave these here for now - I don't need transitive deps anyway
KOKKOS_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
KOKKOS_INCLUDE_DIRECTORIES(REQUIRED_DURING_INSTALLATION_TESTING ${CMAKE_CURRENT_SOURCE_DIR})
KOKKOS_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../src )
KOKKOS_INCLUDE_DIRECTORIES(${KOKKOS_SOURCE_DIR}/core/unit_test/category_files)
SET(ALGORITHM UnitTestMain.cpp)
foreach(Tag Threads;Serial;OpenMP;Cuda;HPX;HIP;SYCL;OpenMPTarget)
string(TOUPPER ${Tag} DEVICE)
string(TOLOWER ${Tag} dir)
if(Kokkos_ENABLE_${DEVICE})
set(dir ${CMAKE_CURRENT_BINARY_DIR}/${dir})
file(MAKE_DIRECTORY ${dir})
# ------------------------------------------
# Sort
# ------------------------------------------
# Each of these inputs is an .hpp file.
# Generate a .cpp file for each one that runs it on the current backend (Tag),
# and add this .cpp file to the sources for UnitTest_RandomAndSort.
set(ALGO_SORT_SOURCES)
foreach(SOURCE_Input
TestSort
TestSortByKey
TestSortCustomComp
TestBinSortA
TestBinSortB
TestNestedSort
)
set(file ${dir}/${SOURCE_Input}.cpp)
# Write to a temporary intermediate file and call configure_file to avoid
# updating timestamps triggering unnecessary rebuilds on subsequent cmake runs.
file(WRITE ${dir}/dummy.cpp
"#include <Test${Tag}_Category.hpp>\n"
"#include <${SOURCE_Input}.hpp>\n"
)
configure_file(${dir}/dummy.cpp ${file})
list(APPEND ALGO_SORT_SOURCES ${file})
endforeach()
# ------------------------------------------
# Random
# ------------------------------------------
# do as above
set(ALGO_RANDOM_SOURCES)
foreach(SOURCE_Input
TestRandom
)
set(file ${dir}/${SOURCE_Input}.cpp)
file(WRITE ${dir}/dummy.cpp
"#include <Test${Tag}_Category.hpp>\n"
"#include <${SOURCE_Input}.hpp>\n"
)
configure_file(${dir}/dummy.cpp ${file})
list(APPEND ALGO_RANDOM_SOURCES ${file})
endforeach()
endif()
endforeach()
# ------------------------------------------
# std set A
# ------------------------------------------
set(STDALGO_SOURCES_A)
foreach(Name
StdReducers
StdAlgorithmsConstraints
RandomAccessIterator
)
list(APPEND STDALGO_SOURCES_A Test${Name}.cpp)
endforeach()
# ------------------------------------------
# std set B
# ------------------------------------------
set(STDALGO_SOURCES_B)
foreach(Name
StdAlgorithmsCommon
StdAlgorithmsMinMaxElementOps
)
list(APPEND STDALGO_SOURCES_B Test${Name}.cpp)
endforeach()
# ------------------------------------------
# std set C
# ------------------------------------------
set(STDALGO_SOURCES_C)
foreach(Name
StdAlgorithmsCommon
StdAlgorithmsLexicographicalCompare
StdAlgorithmsForEach
StdAlgorithmsFind
StdAlgorithmsFindFirstOf
StdAlgorithmsFindEnd
StdAlgorithmsCount
StdAlgorithmsEqual
StdAlgorithmsAllAnyNoneOf
StdAlgorithmsAdjacentFind
StdAlgorithmsSearch
StdAlgorithmsSearch_n
StdAlgorithmsMismatch
StdAlgorithmsMoveBackward
)
list(APPEND STDALGO_SOURCES_C Test${Name}.cpp)
endforeach()
# ------------------------------------------
# std set D
# ------------------------------------------
set(STDALGO_SOURCES_D)
foreach(Name
StdAlgorithmsCommon
StdAlgorithmsModOps
StdAlgorithmsModSeqOps
StdAlgorithmsReplace
StdAlgorithmsReplaceIf
StdAlgorithmsReplaceCopy
StdAlgorithmsReplaceCopyIf
StdAlgorithmsCopyIf
StdAlgorithmsUnique
StdAlgorithmsUniqueCopy
StdAlgorithmsRemove
StdAlgorithmsRemoveIf
StdAlgorithmsRemoveCopy
StdAlgorithmsRemoveCopyIf
StdAlgorithmsRotate
StdAlgorithmsRotateCopy
StdAlgorithmsReverse
StdAlgorithmsShiftLeft
StdAlgorithmsShiftRight
)
list(APPEND STDALGO_SOURCES_D Test${Name}.cpp)
endforeach()
# ------------------------------------------
# std set E
# ------------------------------------------
set(STDALGO_SOURCES_E)
foreach(Name
StdAlgorithmsCommon
StdAlgorithmsIsSorted
StdAlgorithmsIsSortedUntil
StdAlgorithmsPartitioningOps
StdAlgorithmsPartitionCopy
StdAlgorithmsNumerics
StdAlgorithmsAdjacentDifference
StdAlgorithmsExclusiveScan
StdAlgorithmsInclusiveScan
StdAlgorithmsTransformUnaryOp
StdAlgorithmsTransformExclusiveScan
StdAlgorithmsTransformInclusiveScan
)
list(APPEND STDALGO_SOURCES_E Test${Name}.cpp)
endforeach()
# ------------------------------------------
# std team Q
# ------------------------------------------
set(STDALGO_TEAM_SOURCES_Q)
foreach(Name
StdAlgorithmsCommon
StdAlgorithmsTeamInclusiveScan
StdAlgorithmsTeamTransformInclusiveScan
)
list(APPEND STDALGO_TEAM_SOURCES_Q Test${Name}.cpp)
endforeach()
# ------------------------------------------
# std team P
# ------------------------------------------
set(STDALGO_TEAM_SOURCES_P)
foreach(Name
StdAlgorithmsCommon
StdAlgorithmsTeamExclusiveScan
StdAlgorithmsTeamTransformExclusiveScan
)
list(APPEND STDALGO_TEAM_SOURCES_P Test${Name}.cpp)
endforeach()
# ------------------------------------------
# std team M
# ------------------------------------------
set(STDALGO_TEAM_SOURCES_M)
foreach(Name
StdAlgorithmsCommon
StdAlgorithmsTeamTransformUnaryOp
StdAlgorithmsTeamTransformBinaryOp
StdAlgorithmsTeamGenerate
StdAlgorithmsTeamGenerate_n
StdAlgorithmsTeamSwapRanges
)
list(APPEND STDALGO_TEAM_SOURCES_M Test${Name}.cpp)
endforeach()
# ------------------------------------------
# std team L
# ------------------------------------------
set(STDALGO_TEAM_SOURCES_L)
foreach(Name
StdAlgorithmsCommon
StdAlgorithmsTeamIsSorted
StdAlgorithmsTeamIsSortedUntil
StdAlgorithmsTeamIsPartitioned
StdAlgorithmsTeamPartitionCopy
StdAlgorithmsTeamPartitionPoint
)
list(APPEND STDALGO_TEAM_SOURCES_L Test${Name}.cpp)
endforeach()
# ------------------------------------------
# std team I
# ------------------------------------------
set(STDALGO_TEAM_SOURCES_I)
foreach(Name
StdAlgorithmsCommon
StdAlgorithmsTeamUnique
StdAlgorithmsTeamAdjacentDifference
StdAlgorithmsTeamReduce
StdAlgorithmsTeamTransformReduce
)
list(APPEND STDALGO_TEAM_SOURCES_I Test${Name}.cpp)
endforeach()
# ------------------------------------------
# std team H
# ------------------------------------------
set(STDALGO_TEAM_SOURCES_H)
foreach(Name
StdAlgorithmsCommon
StdAlgorithmsTeamCopy
StdAlgorithmsTeamCopy_n
StdAlgorithmsTeamCopyBackward
StdAlgorithmsTeamCopyIf
StdAlgorithmsTeamUniqueCopy
StdAlgorithmsTeamRemove
StdAlgorithmsTeamRemoveIf
StdAlgorithmsTeamRemoveCopy
StdAlgorithmsTeamRemoveCopyIf
)
list(APPEND STDALGO_TEAM_SOURCES_H Test${Name}.cpp)
endforeach()
# ------------------------------------------
# std team G
# ------------------------------------------
set(STDALGO_TEAM_SOURCES_G)
foreach(Name
StdAlgorithmsCommon
StdAlgorithmsTeamMove
StdAlgorithmsTeamMoveBackward
StdAlgorithmsTeamShiftLeft
StdAlgorithmsTeamShiftRight
)
list(APPEND STDALGO_TEAM_SOURCES_G Test${Name}.cpp)
endforeach()
# ------------------------------------------
# std team F
# ------------------------------------------
set(STDALGO_TEAM_SOURCES_F)
foreach(Name
StdAlgorithmsCommon
StdAlgorithmsTeamReverse
StdAlgorithmsTeamReverseCopy
StdAlgorithmsTeamRotate
StdAlgorithmsTeamRotateCopy
)
list(APPEND STDALGO_TEAM_SOURCES_F Test${Name}.cpp)
endforeach()
# ------------------------------------------
# std team E
# ------------------------------------------
set(STDALGO_TEAM_SOURCES_E)
foreach(Name
StdAlgorithmsCommon
StdAlgorithmsTeamFill
StdAlgorithmsTeamFill_n
StdAlgorithmsTeamReplace
StdAlgorithmsTeamReplaceIf
StdAlgorithmsTeamReplaceCopy
StdAlgorithmsTeamReplaceCopyIf
)
list(APPEND STDALGO_TEAM_SOURCES_E Test${Name}.cpp)
endforeach()
# ------------------------------------------
# std team D
# ------------------------------------------
set(STDALGO_TEAM_SOURCES_D)
foreach(Name
StdAlgorithmsCommon
StdAlgorithmsTeamMinElement
StdAlgorithmsTeamMaxElement
StdAlgorithmsTeamMinMaxElement
)
list(APPEND STDALGO_TEAM_SOURCES_D Test${Name}.cpp)
endforeach()
# ------------------------------------------
# std team C
# ------------------------------------------
set(STDALGO_TEAM_SOURCES_C)
foreach(Name
StdAlgorithmsCommon
StdAlgorithmsTeamFind
StdAlgorithmsTeamFindIf
StdAlgorithmsTeamFindIfNot
StdAlgorithmsTeamAllOf
StdAlgorithmsTeamAnyOf
StdAlgorithmsTeamNoneOf
StdAlgorithmsTeamSearchN
)
list(APPEND STDALGO_TEAM_SOURCES_C Test${Name}.cpp)
endforeach()
# ------------------------------------------
# std team B
# ------------------------------------------
set(STDALGO_TEAM_SOURCES_B)
foreach(Name
StdAlgorithmsCommon
StdAlgorithmsTeamEqual
StdAlgorithmsTeamSearch
StdAlgorithmsTeamFindEnd
StdAlgorithmsTeamFindFirstOf
)
list(APPEND STDALGO_TEAM_SOURCES_B Test${Name}.cpp)
endforeach()
# ------------------------------------------
# std team A
# ------------------------------------------
set(STDALGO_TEAM_SOURCES_A)
foreach(Name
StdAlgorithmsCommon
StdAlgorithmsTeamAdjacentFind
StdAlgorithmsTeamCount
StdAlgorithmsTeamCountIf
StdAlgorithmsTeamForEach
StdAlgorithmsTeamForEachN
StdAlgorithmsTeamLexicographicalCompare
StdAlgorithmsTeamMismatch
)
list(APPEND STDALGO_TEAM_SOURCES_A Test${Name}.cpp)
endforeach()
# FIXME_OPENMPTARGET - remove sort test as it leads to ICE with clang/16 and above at compile time.
if(KOKKOS_ENABLE_OPENMPTARGET AND KOKKOS_CXX_COMPILER_ID STREQUAL "Clang" AND KOKKOS_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0.0)
list(REMOVE_ITEM ALGO_SORT_SOURCES
TestSort.cpp
)
endif()
# FIXME_OPENMPTARGET remove tests for OpenMPTarget because in these cases
# the impl needs to use either Kokkos or tailored reducers
# which results in runtime memory errors.
if(KOKKOS_ENABLE_OPENMPTARGET)
list(REMOVE_ITEM STDALGO_TEAM_SOURCES_L
TestStdAlgorithmsTeamIsPartitioned.cpp
TestStdAlgorithmsTeamPartitionPoint.cpp
TestStdAlgorithmsTeamPartitionCopy.cpp
)
endif()
# FIXME_OPENMPTARGET need to remove tests for OpenMPTarget because
# in these cases the impl needs to use either Kokkos or
# tailored reducers which results in runtime memory errors.
if(KOKKOS_ENABLE_OPENMPTARGET)
list(REMOVE_ITEM STDALGO_TEAM_SOURCES_C
TestStdAlgorithmsTeamFind.cpp
TestStdAlgorithmsTeamFindIf.cpp
TestStdAlgorithmsTeamFindIfNot.cpp
TestStdAlgorithmsTeamAllOf.cpp
TestStdAlgorithmsTeamAnyOf.cpp
TestStdAlgorithmsTeamNoneOf.cpp
TestStdAlgorithmsTeamSearchN.cpp
)
endif()
# FIXME_OPENMPTARGET This test causes internal compiler errors as of 09/01/22
# when compiling for Intel's Xe-HP GPUs.
# FRIZZI: 04/26/2023: not sure if the compilation error is still applicable
# but we conservatively leave this guard on
if(NOT (KOKKOS_ENABLE_OPENMPTARGET AND KOKKOS_CXX_COMPILER_ID STREQUAL IntelLLVM))
KOKKOS_ADD_EXECUTABLE_AND_TEST(
UnitTest_Sort
SOURCES
UnitTestMain.cpp
TestStdAlgorithmsCommon.cpp
${ALGO_SORT_SOURCES}
)
KOKKOS_ADD_EXECUTABLE_AND_TEST(
UnitTest_Random
SOURCES
UnitTestMain.cpp
${ALGO_RANDOM_SOURCES}
)
endif()
# FIXME_OPENMPTARGET: These tests cause internal compiler errors as of 09/01/22
# when compiling for Intel's Xe-HP GPUs.
if(KOKKOS_ENABLE_OPENMPTARGET AND KOKKOS_CXX_COMPILER_ID STREQUAL IntelLLVM)
list(REMOVE_ITEM STDALGO_SOURCES_D
TestStdAlgorithmsCopyIf.cpp
TestStdAlgorithmsRemoveCopy.cpp
TestStdAlgorithmsUnique.cpp
TestStdAlgorithmsUniqueCopy.cpp
)
list(REMOVE_ITEM STDALGO_SOURCES_E
TestStdAlgorithmsExclusiveScan.cpp
TestStdAlgorithmsInclusiveScan.cpp
)
endif()
# FIXME_OPENMPTARGET remove tests for OpenMPTarget
# causing failures for various reasons
if(KOKKOS_ENABLE_OPENMPTARGET)
# the following use either Kokkos or tailored reducers
# which results in runtime memory errors.
list(REMOVE_ITEM STDALGO_TEAM_SOURCES_B
TestStdAlgorithmsTeamFindEnd.cpp
TestStdAlgorithmsTeamFindFirstOf.cpp
TestStdAlgorithmsTeamSearch.cpp
)
list(REMOVE_ITEM STDALGO_TEAM_SOURCES_A
TestStdAlgorithmsTeamAdjacentFind.cpp
TestStdAlgorithmsTeamLexicographicalCompare.cpp
TestStdAlgorithmsTeamMismatch.cpp
)
# this causes an illegal memory access if team_members_have_matching_result
# is called
list(REMOVE_ITEM STDALGO_TEAM_SOURCES_M
TestStdAlgorithmsTeamTransformBinaryOp.cpp
)
endif()
foreach(ID A;B;C;D;E)
KOKKOS_ADD_EXECUTABLE_AND_TEST(
AlgorithmsUnitTest_StdSet_${ID}
SOURCES
UnitTestMain.cpp
${STDALGO_SOURCES_${ID}}
)
endforeach()
foreach(ID A;B;C;D;E;F;G;H;I;L;M;P;Q)
KOKKOS_ADD_EXECUTABLE_AND_TEST(
AlgorithmsUnitTest_StdSet_Team_${ID}
SOURCES
UnitTestMain.cpp
${STDALGO_TEAM_SOURCES_${ID}}
)
endforeach()
# FIXME_OPENMPTARGET This test causes internal compiler errors as of 09/01/22
# when compiling for Intel's Xe-HP GPUs.
if(NOT (KOKKOS_ENABLE_OPENMPTARGET AND KOKKOS_CXX_COMPILER_ID STREQUAL IntelLLVM))
KOKKOS_ADD_EXECUTABLE(
AlgorithmsUnitTest_StdAlgoCompileOnly
SOURCES TestStdAlgorithmsCompileOnly.cpp
)
endif()