-
Notifications
You must be signed in to change notification settings - Fork 17
/
CMakeLists.txt
1329 lines (1222 loc) · 54.6 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
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#
# Copyright (c) 2010-2024 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
#
cmake_minimum_required (VERSION 3.21)
project (PARSEC C)
include(CMakeDependentOption)
include(CMakePushCheckState)
include(GNUInstallDirs)
# The current version number
# This uses the numbering scheme from libtool -version_number c:r:a
# see http://www.sourceware.org/autobook/autobook/autobook_61.html
# with PARSEC_VERSION_MAJOR=c-a
# PARSEC_VERSION_MINOR=a
# PARSEC_VERSION_RELEASE=YYMM
# When making a backward compatible addition to the API
# PARSEC_VERSION_MAJOR does not change
# PARSEC_VERSION_MINOR increases by 1
# When making a backward incompabilte change to an API (or exposed structure)
# PARSEC_VERSION_MAJOR increases by 1
# PARSEC_VERSION_MINOR resets to 0
# Unlike strict libtool numbering, PARSEC_VERSION_RELEASE is an monotonous
# increasing number that corresponds to the software version release number
# and never resets to 0, where
# YY is the last 2 digits of the release year,
# MM is the 2 digits of the release month,
# (e.g., for a release tagged v20.02 made in the second month
# of february 2020, PARSEC_VERSION_RELEASE=2002)
set (PARSEC_VERSION_MAJOR 4)
set (PARSEC_VERSION_MINOR 0)
set (PARSEC_VERSION_RELEASE 0) # Devel master have no release number
#set (PARSEC_VERSION_RELEASE 2411) # Set and uncomment for a release
# Set the following values for a release
#set(GIT_COMMIT_TAG v24.11)
# Configure the installation paths
set(PARSEC_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR})
set(PARSEC_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR})
set(PARSEC_INSTALL_BINDIR ${CMAKE_INSTALL_BINDIR})
set(PARSEC_INSTALL_LIBEXECDIR ${CMAKE_INSTALL_LIBEXECDIR})
set(PARSEC_INSTALL_DATADIR ${CMAKE_INSTALL_DATADIR})
set(PARSEC_INSTALL_CMAKEDIR ${CMAKE_INSTALL_DATADIR}/cmake/parsec)
# CMake Policies Tuning
if(POLICY CMP0074)
# CMP0074: Starting with CMake 3.12, all FIND_<something> use <something>_ROOT in the search path
# in addition to the specified paths
cmake_policy(SET CMP0074 NEW)
endif(POLICY CMP0074)
if(POLICY CMP0088)
# CMP0088: New in version 3.14: FindBISON runs bison in CMAKE_CURRENT_BINARY_DIR when executing.
cmake_policy(SET CMP0088 NEW)
endif(POLICY CMP0088)
if(POLICY CMP0094)
# CMP0094: Starting with CMake 3.16, all FIND_Python will use the first matching version instead of
# of searching for the largest available version number (which defeats our selection logic)
cmake_policy(SET CMP0094 NEW)
endif(POLICY CMP0094)
if(POLICY CMP0098)
# CMP0098: New in version 3.17, FindFLEX runs flex in directory CMAKE_CURRENT_BINARY_DIR when executing.
cmake_policy(SET CMP0098 NEW)
endif(POLICY CMP0098)
if(POLICY CMP0144)
# CMP0144: find_package uses upper-case <PACKAGENAME>_ROOT variables in addition to <PackageName>_ROOT
cmake_policy(SET CMP0144 NEW)
endif(POLICY CMP0144)
set(CMAKE_NO_SYSTEM_FROM_IMPORTED True)
# On OSX only find the Apple frameworks is nothing else is available.
# Without this option the default is to provide the XCode installed version
# completely disregarding the versions installed by Mac Ports or Brew.
set(CMAKE_FIND_FRAMEWORK LAST)
# Find the latest version first if multiple are available
SET(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL)
SET(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC)
# CTest system
set(DART_TESTING_TIMEOUT 120)
enable_testing()
include(CTest)
#####
# ccmake tunable parameters
#####
## Check for the support of additional languages and capabilities
option(SUPPORT_FORTRAN
"Enable support for Fortran bindings (default ON)" ON)
# In CMake 3.12, enable_language OPTIONAL has no effect and will still
# enable the language for a compiler that does not work/is not present
# causing all sort of problems downstream. For now use CheckLanguage before.
include(CheckLanguage)
if( SUPPORT_FORTRAN )
check_language(Fortran)
if(CMAKE_Fortran_COMPILER)
enable_language(Fortran OPTIONAL)
endif()
endif( SUPPORT_FORTRAN )
option(SUPPORT_CXX
"Enable support for CXX bindings (default ON)" ON)
if( SUPPORT_CXX )
check_language(CXX)
if(CMAKE_CXX_COMPILER)
enable_language(CXX OPTIONAL)
endif()
endif( SUPPORT_CXX )
option(SUPPORT_C11
"Enable support for C11 capabilities. Might not work with OpenMP support due to an OpenMP compilers restriction (default ON)." ON)
if(SUPPORT_C11)
set(SUPPORT_C11 OFF) # disable until we conirm the compiler supports it
foreach( item IN LISTS CMAKE_C_COMPILE_FEATURES )
if( item STREQUAL "c_std_11")
message(STATUS "Compiler support for C11 detected and enabled")
set(CMAKE_C_STANDARD 11)
set(SUPPORT_C11 ON)
break()
endif()
endforeach()
else(SUPPORT_C11)
set(CMAKE_C_STANDARD 99)
endif(SUPPORT_C11)
set(CMAKE_C_STANDARD_REQUIRED ON)
## Selectively compile only parts of the framework
option(BUILD_TOOLS
"Build the helper tools such as the pre-compilers, profiling manipulation and so on" ON)
mark_as_advanced(BUILD_TOOLS)
option(BUILD_PARSEC
"Compile the PaRSEC framework" ON)
mark_as_advanced(BUILD_PARSEC)
### Misc options
option(BUILD_SHARED_LIBS
"Build shared libraries" ON)
option(BUILD_64bits
"Build 64 bits mode" ON)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are None, Debug, Release, RelWithDebInfo and MinSizeRel." FORCE)
endif(NOT CMAKE_BUILD_TYPE)
option(PARSEC_WANT_HOME_CONFIG_FILES
"Should the runtime check for the parameter configuration file in the user home (\$HOME/.parsec/mca-params.conf)" ON)
option(MPI_HWLOC_COMPAT_CHECK
"Run the MPI + HWLOC compatibility check. If OFF assume the check succeeds (default ON)." ON)
mark_as_advanced(MPI_HWLOC_COMPAT_CHECK)
### PaRSEC runtime configuration parameters
set(PARSEC_MAX_LOCAL_COUNT 20 CACHE STRING "Number of local variables for tasks (default 20)")
set(PARSEC_MAX_PARAM_COUNT 20 CACHE STRING "Number of parameters for tasks (default 20)")
set(PARSEC_MAX_DEP_IN_COUNT 10 CACHE STRING "Number of input flows for each task (default 10)")
set(PARSEC_MAX_DEP_OUT_COUNT 10 CACHE STRING "Number of output flows for each task (default 10)")
### PaRSEC PP options
set(PARSEC_PTGPP_FLAGS "--noline" CACHE STRING "Additional parsec-ptgpp precompiling flags (separate flags with ';')" )
mark_as_advanced(PARSEC_PTGPP_FLAGS)
option(PARSEC_WITH_DEVEL_HEADERS "Install additional headers in include/parsec allowing external compilation." ON)
## Multicore scheduler parameters
option(PARSEC_SCHED_DEPS_MASK
"Use a complete bitmask to track the dependencies, instead of a counter -- increase the debugging features, but limits to a maximum of 30 input dependencies" ON)
mark_as_advanced(PARSEC_SCHED_DEPS_MASK)
### Distributed engine parameters
mark_as_advanced(PARSEC_DIST_THREAD PARSEC_DIST_PRIORITIES)
option(PARSEC_DIST_WITH_MPI
"Build PaRSEC for distributed memory with MPI backend (conflicts all other backends)" ON)
if(PARSEC_DIST_WITH_MPI AND 0)
message(FATAL_ERROR "PARSEC_DIST_WITH_MPI and PARSEC_DIST_WITH_OTHER are mutually exclusive, please select only one")
endif()
option(PARSEC_DIST_THREAD
"Use an extra thread to progress the data movements" ON)
option(PARSEC_DIST_PRIORITIES
"Favor the communications that unlock the most prioritary tasks" ON)
option(PARSEC_DIST_COLLECTIVES
"Use optimized asynchronous operations where collective communication pattern is detected" ON)
set (PARSEC_DIST_SHORT_LIMIT 1 CACHE STRING
"Use the short protocol (no flow control) for messages smaller than the limit in KB. Performs better if smaller than the MTU.")
### GPU engine parameters
option(PARSEC_GPU_ALLOC_PER_TILE
"Tile based allocation engine for GPU memory (instead of internal management
of a complete allocation)" OFF)
mark_as_advanced(PARSEC_GPU_ALLOC_PER_TILE)
option(PARSEC_GPU_WITH_CUDA
"Enable GPU support using CUDA kernels" ON)
option(PARSEC_GPU_WITH_HIP
"Enable GPU support using HIP kernels" ON)
option(PARSEC_GPU_WITH_LEVEL_ZERO
"Enable GPU support using LEVEL_ZERO kernels" ON)
option(PARSEC_GPU_WITH_OPENCL
"Enable GPU support using OpenCL kernels" OFF)
mark_as_advanced(PARSEC_GPU_WITH_OPENCL) # Hide this as it is not supported yet
if(PARSEC_GPU_WITH_OPENCL)
message(WARNING "Open CL is not supported yet, ignored.")
endif()
### Debug options
if( "Debug" STREQUAL CMAKE_BUILD_TYPE )
set(PARSEC_DEBUG ON)
else()
set(PARSEC_DEBUG OFF)
endif()
option(PARSEC_DEBUG_PARANOID
"Enable extra paranoid checks (may impact performance)." OFF)
option(PARSEC_DEBUG_NOISIER
"Enable chatterbox-like verbose debugging (may impact performance)." OFF)
option(PARSEC_DEBUG_HISTORY
"Keep a summarized history of critical events in memory that can be dumped in gdb when deadlock occur." OFF)
option(PARSEC_DEBUG_MEM_ADDR
"Enable the memory access checker, if the compiler supports it." OFF)
option(PARSEC_DEBUG_MEM_LEAK
"Enable only the memory leak checker, if the compiler supports it." OFF)
option(PARSEC_DEBUG_MEM_RACE
"Enable the memory thread-race checker, if the compiler supports it. This option is incompatible with the memory address and leak checker in many compilers." OFF)
### Simulating Options
option(PARSEC_SIM
"Enable the computation of the critical path, through simulation" OFF)
if( PARSEC_SIM AND PARSEC_DIST_WITH_MPI )
message(FATAL_ERROR "PARSEC_SIM cannot be enabled with PARSEC_DIST_WITH_MPI, please select only one")
endif()
### Profiling options
option(PARSEC_PROF_TRACE
"Enable the generation of the profiling information during
execution" OFF)
set(PARSEC_PROF_TRACE_SYSTEM "PaRSEC Binary Tracing Format" CACHE STRING "Select the profiling system, if PARSEC_PROF_TRACE is ON")
#This enforces that only valid values are available in ccmake or cmake-gui
set_property(CACHE PARSEC_PROF_TRACE_SYSTEM PROPERTY STRINGS "OTF2" "PaRSEC Binary Tracing Format")
option(PARSEC_PROF_TRACE_PTG_INTERNAL_INIT
"Generate Profiling traces for the internal_init tasks in the PTG interface (expert mode only)" OFF)
mark_as_advanced(PARSEC_PROF_TRACE_PTG_INTERNAL_INIT) #This is available in export mode only
option(PARSEC_PROF_TRACE_ACTIVE_ARENA_SET
"Enable the profiling of active arena set to track memory usage of parsec handles" OFF)
mark_as_advanced(PARSEC_PROF_TRACE_ACTIVE_ARENA_SET)
option(PARSEC_PROF_TAU
"Experimental usage of TAU profiling framework" ON)
option(PARSEC_PROF_RUSAGE_EU
"Print the rusage per execution unit for each progress" OFF)
option(PARSEC_PROF_TRACE_SCHEDULING_EVENTS
"Enable the tracing of fine-grained scheduling details during execution" OFF)
mark_as_advanced(PARSEC_PROF_TRACE_SCHEDULING_EVENTS)
option(PARSEC_PROF_GRAPHER
"Enable the generation of the dot graph representation during execution" OFF)
option(PARSEC_PROF_DRY_RUN
"Disable calls to the actual bodies and do not move the data between nodes; unfold the dependencies only" OFF)
option(PARSEC_PROF_DRY_BODY
"Disable calls to the actual bodies; no computation is performed" OFF)
option(PARSEC_PROF_DRY_DEP
"Disable calls to the actual data transport; remote dependencies are notified, but no data movement takes place" OFF)
option(PARSEC_PROFILING_USE_MMAP
"Use MMAP to create the profile files" ON)
mark_as_advanced(PARSEC_PROFILING_USE_MMAP)
option(PARSEC_PROFILING_USE_HELPER_THREAD
"Use a Helper Thread to create the profile files" ON)
mark_as_advanced(PARSEC_PROFILING_USE_HELPER_THREAD)
### Instrumentation Options
option(PARSEC_PROF_PINS
"Enable the use of the PaRSEC callback instrumentation system (requires PARSEC_PROF_TRACE)" ON)
# if( PARSEC_PROF_PINS AND NOT PARSEC_PROF_TRACE )
# message(WARNING "PINS Instrumentation System requires to enable PARSEC_PROF_TRACE. Forcing profiling system on.")
# SET(PARSEC_PROF_TRACE ON CACHE BOOL "Enable the generation of the profiling information during execution" FORCE)
# endif( PARSEC_PROF_PINS AND NOT PARSEC_PROF_TRACE )
# cmake modules setup
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules)
include (CMakeDetermineSystem)
include (CheckCCompilerFlag)
include (CheckCSourceCompiles)
include (CheckFunctionExists)
include (CheckSymbolExists)
include (CheckIncludeFiles)
include (CheckFortranCompilerFlag)
include (CheckCXXCompilerFlag)
#
# check the capabilities of the system we are building for
#
# Check for PAPI::SDE
if( PARSEC_PROF_TRACE )
if(CMAKE_SYSTEM_NAME MATCHES "Windows" OR
CMAKE_SYSTEM_NAME MATCHES "MSYS" OR
CMAKE_SYSTEM_NAME MATCHES "MINGW64")
set(PARSEC_PAPI_SDE OFF)
else()
find_package(SDE)
if( TARGET PAPI::SDE )
set(PARSEC_PAPI_SDE ON)
else( TARGET PAPI::SDE )
set(PARSEC_PAPI_SDE OFF)
endif( TARGET PAPI::SDE )
endif()
else( PARSEC_PROF_TRACE )
unset(PARSEC_PAPI_SDE)
unset(PARSEC_PAPI_SDE CACHE)
endif( PARSEC_PROF_TRACE )
# Check for compiler tools
find_package(BISON 3)
find_package(FLEX 2.6)
set(PARSEC_HAVE_RECENT_LEX 0)
set(PARSEC_PREGEN_FLEX_BISON_ARCHIVE ${PROJECT_SOURCE_DIR}/contrib/pregen_flex_bison.tar CACHE PATH "Where to store version-controlled archive of pregenerated .l.c and .y.[ch] files")
if(FLEX_FOUND AND BISON_FOUND)
# add inactive rule to generate in the pregen_flex_bison dir
set(PARSEC_PREGEN_FLEX_BISON_DIR ${PROJECT_BINARY_DIR}/contrib/pregen_flex_bison CACHE PATH "Where to stage the pre-generated .l.c and .y.[ch] files")
add_custom_target(parsec_pregen_flex_bison
WORKING_DIRECTORY ${PARSEC_PREGEN_FLEX_BISON_DIR}
COMMAND ${CMAKE_COMMAND} -Dsrcdir=${PROJECT_SOURCE_DIR} -Dbuilddir=${PROJECT_BINARY_DIR} -Darchive=${PARSEC_PREGEN_FLEX_BISON_ARCHIVE} -P ${PROJECT_SOURCE_DIR}/cmake_modules/pregen_flex_bison.cmake)
endif()
# check for the CPU we build for
message(STATUS "Building for target ${CMAKE_SYSTEM_PROCESSOR}")
string(REGEX MATCH "(i.86-*)|(athlon-*)|(pentium-*)" _mach_x86 ${CMAKE_SYSTEM_PROCESSOR})
if (_mach_x86)
message(STATUS "Found target for X86")
set(PARSEC_ARCH_X86 1)
endif (_mach_x86)
string(REGEX MATCH "(x86_64-*)|(X86_64-*)|(AMD64-*)|(amd64-*)" _mach_x86_64 ${CMAKE_SYSTEM_PROCESSOR})
if (_mach_x86_64)
message(STATUS "Found target X86_64")
set(PARSEC_ARCH_X86_64 1)
endif (_mach_x86_64)
string(REGEX MATCH "(ppc-*)|(powerpc-*)" _mach_ppc ${CMAKE_SYSTEM_PROCESSOR})
if (_mach_ppc)
message(STATUS "Found target for PPC")
set(PARSEC_ARCH_PPC 1)
endif (_mach_ppc)
include (ParsecCompilerFlags)
# threads and atomics
include (cmake_modules/CheckAtomicIntrinsic.cmake)
if(PARSEC_DEBUG_MEM_RACE OR PARSEC_DEBUG_MEM_ADDR OR PARSEC_DEBUG_MEM_LEAK)
# Don't redetect cached values
if(NOT PARSEC_SANITIZE_COMPILE_OPTIONS OR NOT PARSEC_SANITIZE_LINK_OPTIONS)
if(PARSEC_DEBUG_MEM_LEAK)
cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_LIBRARIES "-fsanitize=leak")
check_c_compiler_flag("-fsanitize=leak" PARSEC_HAVE_DEBUG_MEM_LEAK)
if(PARSEC_HAVE_DEBUG_MEM_LEAK)
list(APPEND PARSEC_SANITIZE_COMPILE_OPTIONS "-fsanitize=leak")
list(APPEND PARSEC_SANITIZE_LINK_OPTIONS "-fsanitize=leak")
else()
message(WARNING "PARSEC_DEBUG_MEM_LEAK requested, but not supported by the compiler. Memory leaks will not be reported.")
endif()
cmake_pop_check_state()
endif()
if(PARSEC_DEBUG_MEM_ADDR)
cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_LIBRARIES "-fsanitize=address")
check_c_compiler_flag("-fsanitize=address" PARSEC_HAVE_DEBUG_MEM_ADDR)
if(PARSEC_HAVE_DEBUG_MEM_ADDR)
list(APPEND PARSEC_SANITIZE_COMPILE_OPTIONS "-fsanitize=address")
list(APPEND PARSEC_SANITIZE_LINK_OPTIONS "-fsanitize=address")
else()
message(WARNING "PARSEC_DEBUG_MEM_ADDR requested, but not supported by the compiler. Out of bound accesses will not be reported.")
endif()
cmake_pop_check_state()
endif()
if(PARSEC_DEBUG_MEM_RACE)
cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_LIBRARIES "-fsanitize=thread")
check_c_compiler_flag("-fsanitize=thread" PARSEC_HAVE_DEBUG_MEM_RACE)
if(PARSEC_HAVE_DEBUG_MEM_RACE)
list(APPEND PARSEC_SANITIZE_COMPILE_OPTIONS "-fsanitize=thread")
list(APPEND PARSEC_SANITIZE_LINK_OPTIONS "-fsanitize=thread")
else()
message(WARNING "PARSEC_DEBUG_MEM_RACE requested, but not supported by the compiler. Data races will not be reported.")
endif()
cmake_pop_check_state()
endif()
set(PARSEC_SANITIZE_COMPILE_OPTIONS "${PARSEC_SANITIZE_COMPILE_OPTIONS}" CACHE STRING "Memory sanitizer compile options")
set(PARSEC_SANITIZE_LINK_OPTIONS "${PARSEC_SANITIZE_LINK_OPTIONS}" CACHE STRING "Memory sanitizer link options")
endif(NOT PARSEC_SANITIZE_COMPILE_OPTIONS OR NOT PARSEC_SANITIZE_LINK_OPTIONS)
endif(PARSEC_DEBUG_MEM_RACE OR PARSEC_DEBUG_MEM_ADDR OR PARSEC_DEBUG_MEM_LEAK)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
if(Threads_FOUND)
set(PARSEC_HAVE_PTHREAD true)
cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}")
check_symbol_exists(pthread_getspecific "pthread.h" PARSEC_HAVE_PTHREAD_GETSPECIFIC)
check_symbol_exists(pthread_barrier_init "pthread.h" PARSEC_HAVE_PTHREAD_BARRIER)
if(NOT PARSEC_HAVE_PTHREAD_BARRIER)
check_symbol_exists(pthread_barrier_init "pthread-barrier.h" PARSEC_HAVE_PTHREAD_BARRIER_H)
if(PARSEC_HAVE_PTHREAD_BARRIER_H)
set(CMAKE_REQUIRED_LIBRARIES "libuv.a")
check_function_exists(pthread_barrier_init PARSEC_HAVE_PTHREAD_BARRIER)
endif(PARSEC_HAVE_PTHREAD_BARRIER_H)
endif(NOT PARSEC_HAVE_PTHREAD_BARRIER)
cmake_pop_check_state()
endif(Threads_FOUND)
check_function_exists(sched_setaffinity PARSEC_HAVE_SCHED_SETAFFINITY)
if(NOT PARSEC_HAVE_SCHED_SETAFFINITY)
check_library_exists(rt sched_setaffinity "" PARSEC_HAVE_SCHED_SETAFFINITYRT)
if(PARSEC_HAVE_SCHED_SETAFFINITYRT)
set(PARSEC_HAVE_SCHED_SETAFFINITY true)
list(APPEND EXTRA_LIBS rt)
endif()
endif(NOT PARSEC_HAVE_SCHED_SETAFFINITY)
# timeval, timespec, realtime clocks, etc
include(CheckStructHasMember)
check_struct_has_member("struct timespec" tv_nsec time.h PARSEC_HAVE_TIMESPEC_TV_NSEC)
if( NOT PARSEC_HAVE_TIMESPEC_TV_NSEC )
cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE")
check_struct_has_member("struct timespec" tv_nsec time.h PARSEC_HAVE_TIMESPEC_TV_NSEC_GNU)
cmake_pop_check_state()
if( PARSEC_HAVE_TIMESPEC_TV_NSEC_GNU )
add_definitions(-D_GNU_SOURCE)
set(PARSEC_HAVE_TIMESPEC_TV_NSEC true)
endif( PARSEC_HAVE_TIMESPEC_TV_NSEC_GNU )
endif( NOT PARSEC_HAVE_TIMESPEC_TV_NSEC )
# clock_gettime was located in librt until glibc 2.17 when it moved
# to the libc.
check_library_exists(c clock_gettime "time.h" PARSEC_HAVE_CLOCK_GETTIME)
if( NOT PARSEC_HAVE_CLOCK_GETTIME )
check_library_exists(rt clock_gettime "time.h" PARSEC_HAVE_CLOCK_GETTIMERT)
if(PARSEC_HAVE_CLOCK_GETTIMERT)
set(PARSEC_HAVE_CLOCK_GETTIME true)
list(APPEND EXTRA_LIBS rt)
endif(PARSEC_HAVE_CLOCK_GETTIMERT)
endif( NOT PARSEC_HAVE_CLOCK_GETTIME )
if(CMAKE_SYSTEM_NAME MATCHES "Windows" OR
CMAKE_SYSTEM_NAME MATCHES "MSYS" OR
CMAKE_SYSTEM_NAME MATCHES "MINGW64")
check_library_exists(ws2_32 WSAStartup "" PARSEC_HAVE_WS2_32)
list(APPEND EXTRA_LIBS ws2_32)
list(APPEND EXTRA_LIBS wsock32)
endif()
# stdlib, stdio, string, getopt, etc
check_include_files(stdarg.h PARSEC_HAVE_STDARG_H)
# va_copy is special as it is not required to be a function.
if (PARSEC_HAVE_STDARG_H)
check_c_source_compiles("
#include <stdarg.h>
int main(void) {
va_list a, b;
va_copy(a, b);
return 0;
}"
PARSEC_HAVE_VA_COPY
)
if (NOT PARSEC_HAVE_VA_COPY)
check_c_source_compiles("
#include <stdarg.h>
int main(void) {
va_list a, b;
__va_copy(a, b);
return 0;
}"
PARSEC_HAVE_UNDERSCORE_VA_COPY
)
endif (NOT PARSEC_HAVE_VA_COPY)
check_c_source_compiles("#include <stdio.h>
#include <stdarg.h>
int my_printf(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
int my_printf(const char *format, ...) {
va_list ap;
int ret;
va_start(ap, format);
ret = vprintf(format, ap);
va_end(ap);
return ret;
}
int main() {
return my_printf(\"toto\");
}" PARSEC_HAVE_ATTRIBUTE_FORMAT_PRINTF)
endif (PARSEC_HAVE_STDARG_H)
check_c_source_compiles("
static _Thread_local int tls = 0;
int main(int argc, char *argv[]) {
tls = 1;
return 0;
}" PARSEC_HAVE_THREAD_LOCAL)
check_include_files(unistd.h PARSEC_HAVE_UNISTD_H)
check_include_files(getopt.h PARSEC_HAVE_GETOPT_H)
check_include_files(errno.h PARSEC_HAVE_ERRNO_H)
check_include_files(stddef.h PARSEC_HAVE_STDDEF_H)
check_include_files(stdbool.h PARSEC_HAVE_STDBOOL_H)
check_include_files(ctype.h PARSEC_HAVE_CTYPE_H)
check_include_files(execinfo.h PARSEC_HAVE_EXECINFO_H)
check_include_files(sys/mman.h PARSEC_HAVE_SYS_MMAN_H)
check_include_files(dlfcn.h PARSEC_HAVE_DLFCN_H)
check_function_exists(asprintf PARSEC_HAVE_ASPRINTF)
check_function_exists(vasprintf PARSEC_HAVE_VASPRINTF)
check_function_exists(getopt_long PARSEC_HAVE_GETOPT_LONG)
check_function_exists(rand_r PARSEC_HAVE_RAND_R)
check_function_exists(getline PARSEC_HAVE_GETLINE)
check_function_exists(setenv PARSEC_HAVE_SETENV)
check_function_exists(sysconf PARSEC_HAVE_SYSCONF)
if( NOT PARSEC_HAVE_SYS_MMAN_H AND PARSEC_PROFILING_USE_MMAP )
message(STATUS "sys/mman.h not found: PARSEC_PROFILING_USE_MMAP is disabled -- Profiling will allocate and free each tracing block")
set(PARSEC_PROFILING_USE_MMAP OFF CACHE BOOL "Use a Helper Thread to create the profile files" FORCE)
endif( NOT PARSEC_HAVE_SYS_MMAN_H AND PARSEC_PROFILING_USE_MMAP )
check_c_source_compiles("
int main(int argc, char* argv[]) {
__builtin_cpu_init();
return 0;
}" PARSEC_HAVE_BUILTIN_CPU)
check_function_exists(getrusage PARSEC_HAVE_GETRUSAGE)
check_symbol_exists(RUSAGE_THREAD sys/resource.h PARSEC_HAVE_RUSAGE_THREAD)
if( NOT PARSEC_HAVE_RUSAGE_THREAD )
cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE")
check_symbol_exists(RUSAGE_THREAD sys/resource.h PARSEC_HAVE_RUSAGE_THREAD_GNU)
cmake_pop_check_state()
if( PARSEC_HAVE_RUSAGE_THREAD_GNU )
add_definitions(-D_GNU_SOURCE)
set(PARSEC_HAVE_RUSAGE_THREAD true)
endif( PARSEC_HAVE_RUSAGE_THREAD_GNU )
endif( NOT PARSEC_HAVE_RUSAGE_THREAD)
check_include_files(limits.h PARSEC_HAVE_LIMITS_H)
check_include_files(string.h PARSEC_HAVE_STRING_H)
check_include_files(libgen.h PARSEC_HAVE_GEN_H)
check_include_files(complex.h PARSEC_HAVE_COMPLEX_H)
check_include_files(sys/param.h PARSEC_HAVE_SYS_PARAM_H)
check_include_files(sys/types.h PARSEC_HAVE_SYS_TYPES_H)
check_include_files(syslog.h PARSEC_HAVE_SYSLOG_H)
check_include_files(valgrind/valgrind.h PARSEC_HAVE_VALGRIND_API)
check_c_source_compiles("
static int toto(int c) __attribute__ ((always_inline));
static int toto(int c) {
return c;
}
int main() {
return toto(3);
}" PARSEC_HAVE_ATTRIBUTE_ALWAYS_INLINE)
check_c_source_compiles("
int toto(int c) __attribute__ ((visibility (\"hidden\")));
int toto(int c) {
return c;
}
int main() {
return toto(3);
}" PARSEC_HAVE_ATTRIBUTE_VISIBILITY)
check_c_source_compiles("
int main( int argc, char** argv) {
int x = 0;
if ( __builtin_expect(!!(x), 0) )
return -1;
return 0;
}
" PARSEC_HAVE_BUILTIN_EXPECT)
check_c_source_compiles("
int toto(int c) __attribute__ ((deprecated(\"deprecated\")));
int main() {
return 0;
}" PARSEC_HAVE_ATTRIBUTE_DEPRECATED)
check_c_source_compiles("
enum matrix_type {
matrix_Byte __parsec_attribute_deprecated__(\"Use PARSEC_MATRIX_BYTE instead\") = 1, /**< unsigned char */
matrix_Integer __parsec_attribute_deprecated__(\"Use PARSEC_MATRIX_INTEGER instead\") = 2, /**< signed int */
};
int main() {
return 0;
}" PARSEC_HAVE_ENUM_ATTRIBUTE_DEPRECATED)
check_type_size("size_t" PARSEC_SIZEOF_SIZE_T)
set(EXTRA_INCLUDES "")
#
# Find optional packages
#
if( BUILD_PARSEC )
if (PARSEC_DIST_WITH_MPI)
# Otherwise try to find MPI in the normal way
find_package(MPI)
set(PARSEC_HAVE_MPI ${MPI_C_FOUND})
if (NOT MPI_C_FOUND)
# Force MPI: if no compiler, do not proceed further
message(FATAL_ERROR "MPI is required but was not found. Please provide an MPI compiler")
endif (NOT MPI_C_FOUND)
list(APPEND EXTRA_LIBS ${MPI_C_LIBRARIES})
endif (PARSEC_DIST_WITH_MPI)
#
# Check to see if
# support for MPI 2.0 is available
# known bugged version of mpi_assert_no_ordering
#
if (MPI_C_FOUND)
cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_INCLUDES "${MPI_C_INCLUDE_PATH}")
list(APPEND CMAKE_REQUIRED_LIBRARIES "${MPI_C_LIBRARIES}")
check_function_exists(MPI_Type_create_resized PARSEC_HAVE_MPI_20)
check_function_exists(MPI_Comm_set_info PARSEC_HAVE_MPI_30)
if(PARSEC_HAVE_MPI_30)
# MPI Info mpi_assert_enable_overtaking is buggy in Open MPI 3.1.x, x<=4;
# and Open MPI 4.0.x, x <= 1
check_c_source_compiles("#include <mpi.h>
int main(int argc, char* argv[]) {
#if (3 == OMPI_MAJOR_VERSION && 1 >= OMPI_MINOR_VERSION && 4 >= OMPI_RELEASE_VERSION) || (4 == OMPI_MAJOR_VERSION && 0 == OMPI_MINOR_VERSION && 1 >= OMPI_RELEASE_VERSION)
#warning \"malfunctionning mpi_assert_enable_overtaking found\"
#endif
return 0;
}"
PARSEC_HAVE_MPI_OVERTAKE
FAIL_REGEX "malfunctionning mpi_assert_enable_overtaking")
endif(PARSEC_HAVE_MPI_30)
cmake_pop_check_state()
endif (MPI_C_FOUND)
# If MPI enabled and the user did not requested a specific HWLOC
# installation try to use one that is compatible with MPI, by finding if MPI
# provide HWLOC and use it.
if(MPI_C_FOUND AND NOT HWLOC_ROOT)
find_path(PARSEC_MPI_HWLOC_INCLUDE_DIR "hwloc.h"
HINTS ${MPI_C_INCLUDE_PATH}
NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
if(PARSEC_MPI_HWLOC_INCLUDE_DIR)
get_filename_component(PARSEC_MPI_HWLOC_ROOT ${PARSEC_MPI_HWLOC_INCLUDE_DIR} DIRECTORY)
message(STATUS "Force HWLOC to match collocated MPI ${PARSEC_MPI_HWLOC_ROOT}; you can override this by setting HWLOC_ROOT")
set(HWLOC_ROOT ${PARSEC_MPI_HWLOC_ROOT})
endif(PARSEC_MPI_HWLOC_INCLUDE_DIR)
endif(MPI_C_FOUND AND NOT HWLOC_ROOT)
find_package(HWLOC)
set(PARSEC_HAVE_HWLOC ${HWLOC_FOUND})
if( HWLOC_FOUND )
list(APPEND EXTRA_LIBS ${HWLOC_LIBRARIES})
list(APPEND EXTRA_INCLUDES ${HWLOC_INCLUDE_DIRS})
set (PARSEC_PKG_REQUIRE "hwloc")
if(MPI_C_FOUND AND MPI_HWLOC_COMPAT_CHECK AND NOT CMAKE_CROSSCOMPILING)
include(CheckCSourceRuns)
cmake_push_check_state()
# Some MPI libraries link with an external version of hwloc, and
# compiling/linking our own with a different, incompatible ABI hwloc
# will cause breakage. We try to capture this case ASAP during configure,
# except if we are cross-compiling: in this case the error will be
# mopped-up when runing the user program, late but safe.
#
# Note that we test the same link-order as in PaRSEC
# Dependent upon which one links first, either PaRSEC, or MPI will break.
#
# Do not use use targets here becuase CMake consider all imported
# interfaces as system headers, and instead of using -I (which provide
# priority during header search) will use -isystem (which does not and
# might allow to find the header in the standard path).
list(APPEND CMAKE_REQUIRED_LIBRARIES ${HWLOC_LIBRARIES} ${MPI_C_LIBRARIES})
list(PREPEND CMAKE_REQUIRED_INCLUDES ${HWLOC_INCLUDE_DIRS} ${MPI_C_INCLUDE_DIRS})
message(TRACE "CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}")
message(TRACE "CMAKE_REQUIRED_INCLUDES = ${CMAKE_REQUIRED_INCLUDES}")
check_c_source_runs("
#include <mpi.h>
#include <hwloc.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
printf(\"HWLOC headers version: %x.\\\\nCalling `hwloc_get_api_version()`...\\\\n\", HWLOC_API_VERSION); fflush(stdout);
unsigned int lib_api_version = hwloc_get_api_version();
printf(\"HWLOC library version: %x.\\\\n\", lib_api_version); fflush(stdout);
#if HWLOC_API_VERSION >= 0x00020000
if (lib_api_version < 0x00020000) {
#else
if (lib_api_version >= 0x00020000) {
#endif
printf(\"Header and library versions are incompatible.\\\\n\"); fflush(stdout);
return 1;
}
printf(\"Calling `MPI_Init()`...\\\\n\"); fflush(stdout);
MPI_Init(&argc, &argv);
MPI_Barrier(MPI_COMM_WORLD);
MPI_Finalize();
printf(\"HWLOC+MPI worked.\\\\n\");
return 0;
}" MPI_AND_HWLOC_COMPATIBLE)
if(NOT MPI_AND_HWLOC_COMPATIBLE)
message(FATAL_ERROR "The hwloc CMake found and the one used by MPI are incompatible!\n Make sure you use the same hwloc used to compile your MPI library\n The test failed with the following outputs:\n${RUN_OUTPUT}")
endif(NOT MPI_AND_HWLOC_COMPATIBLE)
cmake_pop_check_state()
else(MPI_C_FOUND AND MPI_HWLOC_COMPAT_CHECK AND NOT CMAKE_CROSSCOMPILING)
message(STATUS "MPI and HWLOC assumed compatible (check explicitly disabled)")
set(MPI_AND_HWLOC_COMPATIBLE 1 CACHE BOOL "MPI and HWLOC assumed compatible (check explicitly disabled)")
endif(MPI_C_FOUND AND MPI_HWLOC_COMPAT_CHECK AND NOT CMAKE_CROSSCOMPILING)
endif( HWLOC_FOUND )
if( PARSEC_GPU_WITH_CUDA )
string(REGEX MATCH "PGI$" _match_pgi ${CMAKE_C_COMPILER_ID})
if (_match_pgi)
get_filename_component(_pgcc ${CMAKE_C_COMPILER} ABSOLUTE)
string(REGEX REPLACE "/bin/.*" "" _path_pgi ${_pgcc})
file(GLOB_RECURSE _pgnvcc FOLLOW_SYMLINKS ${_path_pgi}/cuda/*/nvcc)
list(SORT _pgnvcc)
list(GET _pgnvcc -1 _pgnvcc)
string(REGEX REPLACE "/bin/.*" "" _path_pgcuda "${_pgnvcc}")
if(_path_pgcuda)
set(CUDAToolkit_ROOT ${_path_pgcuda})
message(STATUS "Using PGI internal CUDA SDK in ${CUDAToolkit_ROOT}")
endif(_path_pgcuda)
endif (_match_pgi)
find_package(CUDAToolkit 4)
set(PARSEC_HAVE_CUDA ${CUDAToolkit_FOUND} CACHE BOOL "True if PaRSEC provide support for CUDA")
if (CUDAToolkit_FOUND)
message(STATUS "Found CUDA ${CUDAToolkit_VERSION} in ${CUDAToolkit_LIBRARY_DIR}")
get_target_property(extra_cuda_libs CUDA::cudart INTERFACE_LINK_LIBRARIES)
if(extra_cuda_libs)
list(APPEND EXTRA_LIBS ${extra_cuda_libs})
endif(extra_cuda_libs)
# Check if PaRSEC can provide automatic compilation of .cu files.
check_language(CUDA)
if(CMAKE_CUDA_COMPILER)
enable_language(CUDA)
endif(CMAKE_CUDA_COMPILER)
endif (CUDAToolkit_FOUND)
set(PARSEC_HAVE_CU_COMPILER ${CMAKE_CUDA_COMPILER} CACHE BOOL "True if PaRSEC provide support for compiling .cu files")
endif( PARSEC_GPU_WITH_CUDA )
if( PARSEC_GPU_WITH_HIP )
# This is kinda ugly but the PATH and HINTS don't get transmitted to sub-dependents
set(CMAKE_SYSTEM_PREFIX_PATH_save ${CMAKE_SYSTEM_PREFIX_PATH})
list(APPEND CMAKE_SYSTEM_PREFIX_PATH /opt/rocm)
find_package(HIP QUIET) #quiet because hip-config.cmake is not part of core-cmake and will spam a loud warning when hip/rocm is not installed
if(HIP_FOUND AND HIP_VERSION VERSION_LESS 5) # find_package(HIP 5...6) does not work for some reason
message(FATAL_ERROR "Found HIP version ${HIP_VERSION} in ${HIP_LIB_INSTALL_DIR} is too old, use HIP_ROOT to select another version")
endif()
set(CMAKE_SYSTEM_PREFIX_PATH ${CMAKE_SYSTEM_PREFIX_PATH_save})
if(HIP_FOUND AND PARSEC_HAVE_CUDA)
# the underlying reason is that the generated ptg code cannot include at the same time
# cuda_runtime.h and hip_runtime.h, so we need to modify the dev_cuda.h to not expose any
# structure that depends on these headers.
message(WARNING "For the time being HIP and CUDA devices cannot be compiled at the same time. Choose one by setting explicitely the options PARSEC_GPU_WITH_{CUDA|HIP}")
set(HIP_NOT_CUDA_FOUND FALSE)
elseif(HIP_FOUND)
message(STATUS "Found HIP ${HIP_VERSION} in ${HIP_LIB_INSTALL_DIR}")
get_target_property(extra_hip_libs hip::host INTERFACE_LINK_LIBRARIES)
list(APPEND EXTRA_LIBS ${extra_hip_libs})
set(HIP_NOT_CUDA_FOUND TRUE)
else()
set(HIP_NOT_CUDA_FOUND FALSE)
endif()
set(PARSEC_HAVE_HIP ${HIP_NOT_CUDA_FOUND} CACHE BOOL "True if PaRSEC provide support for HIP")
endif( PARSEC_GPU_WITH_HIP )
if( PARSEC_GPU_WITH_LEVEL_ZERO )
find_package(level-zero)
set(PARSEC_HAVE_LEVEL_ZERO ${LEVEL_ZERO_FOUND} CACHE BOOL "True if PaRSEC provide support for Intel Level Zero")
if(PARSEC_HAVE_LEVEL_ZERO)
include_directories("${LEVEL_ZERO_INCLUDE_DIR}/level_zero/")
find_package(DPCPP)
if(DPCPP_EXECUTABLE)
set(PARSEC_HAVE_DPCPP TRUE CACHE BOOL "True if PaRSEC knows how to compile DPCPP code")
message(STATUS "Found Intel level-zero ${LEVEL_ZERO_VERSION} in -I${LEVEL_ZERO_INCLUDE_DIR} / -L${LEVEL_ZERO_LIBRARY_DIR}")
message(STATUS "Found dpcpp in ${DPCPP_EXECUTABLE}")
else(DPCPP_EXECUTABLE)
set(PARSEC_HAVE_DPCPP FALSE CACHE BOOL "True if PaRSEC knows how to compile DPCPP code")
endif(DPCPP_EXECUTABLE)
endif(PARSEC_HAVE_LEVEL_ZERO)
endif( PARSEC_GPU_WITH_LEVEL_ZERO )
find_package(AYUDAME QUIET)
set(PARSEC_HAVE_AYUDAME ${AYUDAME_FOUND})
#
# If AYUDAME support is enabled it means we need to deal with weak symbols. On
# MAC OS X we need to add a special linker flag or the applications will not
# compile correctly.
#
if(AYUDAME_FOUND)
target_include_directories(parsec
PRIVATE
${AYUDAME_INCLUDE_DIRS})
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
message(STATUS "Add '-undefined dynamic_lookup' to the linking flags")
target_link_libraries(parsec
PUBLIC
"-undefined dynamic_lookup")
endif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
endif(AYUDAME_FOUND)
# Coerce CMake to install the generated .mod files
if(CMAKE_Fortran_COMPILER_WORKS)
set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/parsec/include/fortran)
install(DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/ DESTINATION ${PARSEC_INSTALL_INCLUDEDIR})
endif(CMAKE_Fortran_COMPILER_WORKS)
endif( BUILD_PARSEC )
# Find how to link shm_open
check_function_exists(shm_open PARSEC_HAVE_SHM_OPEN)
if(NOT PARSEC_HAVE_SHM_OPEN)
check_library_exists(rt shm_open "" PARSEC_SHM_OPEN_IN_LIBRT)
set(PARSEC_HAVE_SHM_OPEN ${PARSEC_SHM_OPEN_IN_LIBRT} CACHE INTERNAL "Have function shm_open")
endif(NOT PARSEC_HAVE_SHM_OPEN)
#
##
###
# Finished detecting the system, lets do our own things now
###
##
#
#
# Using @rpath allows rellocatable libraries:
# https://blog.kitware.com/upcoming-in-cmake-2-8-12-osx-rpath-support/
#
set(CMAKE_MACOSX_RPATH 1)
# use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# the RPATH to be used when installing, but only if it's not a system directory
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${PARSEC_INSTALL_LIBDIR}" isSystemDir)
#message(STATUS "LINK_DIRECTORIES = ${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}")
#message(STATUS "INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}/${PARSEC_INSTALL_LIBDIR}")
if(isSystemDir STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${PARSEC_INSTALL_LIBDIR}")
endif(isSystemDir STREQUAL "-1")
# Prepare the list of include directories. From the source directory we need 2 the source
# itself and then the specialized headers from parsec/include. If we compile with VPATH
# we need to add the same thing for the BINARY_DIR.
string(COMPARE EQUAL ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} PARSEC_BUILD_INPLACE)
if(NOT PARSEC_BUILD_INPLACE)
include_directories(BEFORE "${CMAKE_CURRENT_SOURCE_DIR}")
include_directories(BEFORE "${CMAKE_CURRENT_SOURCE_DIR}/parsec/include")
endif(NOT PARSEC_BUILD_INPLACE)
set(PROJECT_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/parsec/include")
include_directories(BEFORE "${CMAKE_CURRENT_BINARY_DIR}")
include_directories(BEFORE "${PROJECT_INCLUDE_DIR}")
#
# Check if indent is available on the system.
#
set(PARSEC_HAVE_INDENT 0)
find_program(INDENT_EXECUTABLE indent DOC "path to the indent executable")
mark_as_advanced(INDENT_EXECUTABLE)
# K&R (not supported on Mac), so we settle for less
# -nbad -bap -bbo -nbc -br -brs -c33 -cd33 -ncdb -ce -ci4 -cli0
# -cp33 -cs -d0 -di1 -nfc1 -nfca -hnl -i4 -ip0 -l75 -lp -npcs
# -nprs -npsl -saf -sai -saw -nsc -nsob -nss
set(INDENT_OPTIONS "-nbad -bap -nbc -br -brs -ncdb -ce -cli0 -d0 -di1 -nfc1 -i4 -ip0 -lp -npcs -npsl -nsc -nsob -l120")
mark_as_advanced(INDENT_OPTIONS)
if(INDENT_EXECUTABLE)
set(PARSEC_HAVE_INDENT 1)
endif(INDENT_EXECUTABLE)
#
# Check if awk is available on the system.
#
set(PARSEC_HAVE_AWK 0)
find_program(AWK_EXECUTABLE awk DOC "path to the awk executable")
mark_as_advanced(AWK_EXECUTABLE)
if(AWK_EXECUTABLE)
set(PARSEC_HAVE_AWK 1)
endif(AWK_EXECUTABLE)
# Check for OTF2 support.
set(PARSEC_HAVE_OTF2 FALSE CACHE INTERNAL "Has support for the OTF2 format")
# OTF2 integration currently depends on MPI being available
if(PARSEC_PROF_TRACE AND PARSEC_DIST_WITH_MPI)
if(PARSEC_PROF_TRACE_SYSTEM STREQUAL "OTF2" OR PARSEC_PROF_TRACE_SYSTEM STREQUAL "Auto")
find_package(OTF2 2.1.1)
if(OTF2_FOUND AND MPI_C_FOUND)
set(PARSEC_HAVE_OTF2 ${OTF2_FOUND})
set(PARSEC_PROF_TRACE_SYSTEM "OTF2")
else(OTF2_FOUND AND MPI_C_FOUND)
if(PARSEC_PROF_TRACE_SYSTEM STREQUAL "OTF2")
message(FATAL_ERROR "Requested OTF2 tracing system is not available because OTF2 was not found or MPI was not found")
endif(PARSEC_PROF_TRACE_SYSTEM STREQUAL "OTF2")
endif(OTF2_FOUND AND MPI_C_FOUND)
endif(PARSEC_PROF_TRACE_SYSTEM STREQUAL "OTF2" OR PARSEC_PROF_TRACE_SYSTEM STREQUAL "Auto")
endif(PARSEC_PROF_TRACE AND PARSEC_DIST_WITH_MPI)
#
# First go for the tools.
#
add_subdirectory(tools)
if(CMAKE_CROSSCOMPILING)
#
# Import the EXPORT file from external native ptgpp.
#
set(IMPORT_EXECUTABLES "IMPORTFILE-NOTFOUND" CACHE FILEPATH "Point it to the export file from a native build")
message(STATUS "Prepare cross-compiling using ${IMPORT_EXECUTABLES}")
include(${IMPORT_EXECUTABLES})
set_target_properties(parsec-ptgpp PROPERTIES IMPORTED_GLOBAL ON)
get_target_property(PARSEC_PTGPP_EXECUTABLE parsec-ptgpp LOCATION)
# Build it, now
get_filename_component(NATIVE_BINARY_DIR "${IMPORT_EXECUTABLES}" DIRECTORY BASE_DIR ${PROJECT_BINARY_DIR} CACHE)
include(ExternalProject)
ExternalProject_add(native
PREFIX ${NATIVE_BINARY_DIR}/CMakeFiles
SOURCE_DIR ${PROJECT_SOURCE_DIR}
BINARY_DIR ${NATIVE_BINARY_DIR}
CONFIGURE_COMMAND "" # Do not reconfigure, this must have been done before to produce $IMPORT_EXECUTABLES
# Do not do BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR>/parsec/interfaces/ptg
# because that breaks parallel make
BUILD_COMMAND "$(MAKE)" -C parsec/interfaces/ptg
COMMAND "$(MAKE)" -C tools
BUILD_ALWAYS TRUE
INSTALL_COMMAND "$(MAKE)" -C parsec/interfaces/ptg install
COMMAND "$(MAKE)" -C tools install
EXCLUDE_FROM_ALL TRUE
STEP_TARGETS build install test clean
BYPRODUCTS ${PARSEC_PTGPP_EXECUTABLE}
)
ExternalProject_Add_Step(native test
WORKING_DIRECTORY <BINARY_DIR>
ALWAYS TRUE
COMMAND "$(MAKE)" -C parsec/interfaces/ptg test
COMMAND "$(MAKE)" -C tools test
)
ExternalProject_Add_Step(native clean
WORKING_DIRECTORY <BINARY_DIR>
ALWAYS TRUE
COMMAND "$(MAKE)" -C parsec/interfaces/ptg clean
COMMAND "$(MAKE)" -C tools clean
)
add_dependencies(parsec-ptgpp native-build)
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR} --target native-install)")
add_test(NAME native-test COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR} --target native-test)
else()
set(PARSEC_PTGPP_EXECUTABLE parsec-ptgpp)
endif(CMAKE_CROSSCOMPILING)
set(PARSEC_PTGPP_EXECUTABLE ${PARSEC_PTGPP_EXECUTABLE} CACHE STRING "Point to the parsec-ptgpp executable")
# List of files that will go through documentation generation
include(AddDocumentedFiles)
add_subdirectory(parsec)
#
# Add dependency to Level-Zero if it is enabled
#
if(PARSEC_HAVE_LEVEL_ZERO)
target_link_libraries(parsec PRIVATE level_zero::ze_loader)
endif(PARSEC_HAVE_LEVEL_ZERO)
#
# Now continue with compiling the tests.
#
set(CTEST_SHM_LAUNCHER
"" CACHE STRING
"A command to run shared memory testings")
string(REPLACE " " ";" SHM_TEST_CMD_LIST "${CTEST_SHM_LAUNCHER}")
set(CTEST_MPI_LAUNCHER
"${MPIEXEC} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG}" CACHE STRING
"A command to run distributed memory testings")
if( CTEST_MPI_LAUNCHER STREQUAL "" )
message(WARNING "MPI tests will most likely not work: 'CTEST_MPI_LAUNCHER' is not set")
endif()
string(REPLACE " " ";" MPI_TEST_CMD_LIST "${CTEST_MPI_LAUNCHER}")
set(CTEST_CUDA_LAUNCHER_OPTIONS
"" CACHE STRING
"Options to pass to the CTEST_MPI_LAUNCHER to select CUDA nodes")
set(CTEST_HIP_LAUNCHER_OPTIONS
"" CACHE STRING
"Options to pass to the CTEST_MPI_LAUNCHER to select RoCM/HIP nodes")
if( BUILD_TESTING )
find_program(HOSTNAME_EXE hostname)
mark_as_advanced(HOSTNAME_EXE)
# Test that the launchers work
add_test(launcher:shm ${SHM_TEST_CMD_LIST} ${HOSTNAME_EXE})
if(PARSEC_HAVE_MPI)
add_test(launcher:mpi ${MPI_TEST_CMD_LIST} 4 ${HOSTNAME_EXE})
endif(PARSEC_HAVE_MPI)
if(PARSEC_HAVE_CUDA)
add_test(launcher:cuda ${MPI_TEST_CMD_LIST} 4 ${CTEST_CUDA_LAUNCHER_OPTIONS} ${HOSTNAME_EXE})
endif(PARSEC_HAVE_CUDA)
if(PARSEC_HAVE_HIP)
add_test(launcher:hip ${MPI_TEST_CMD_LIST} 4 ${CTEST_HIP_LAUNCHER_OPTIONS} ${HOSTNAME_EXE})
endif(PARSEC_HAVE_HIP)
add_subdirectory(tests)
add_subdirectory(examples)