7.1.2 : Le CMakeLists.txt
1 2 |
project(HadamardProduct) cmake_minimum_required(VERSION 3.0) |
Pour l'exemple en C++20, le compilateur va appeler TBB (Threading Bounding Block, la bibliohtèque de parallélisation d'Intel) pour gérer les exécutions std::execution::par_unseq et std::execution::par . Si vous l'oubliez, vous aurez une erreur de linkage :
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 |
find_package(TBB COMPONENTS tbb REQUIRED) include(runExample.cmake) add_definitions(-DVECTOR_ALIGNEMENT=32) add_subdirectory(AstericsHPC) include_directories(AstericsHPC) add_executable(hadamard_product_cpp20_seq_O0 main_cpp20.cpp) set_property(TARGET hadamard_product_cpp20_seq_O0 PROPERTY COMPILE_FLAGS "-O0 -Wall -std=c++20 -DEXECUTION_POLICY=\"std::execution::seq\"") target_link_libraries(hadamard_product_cpp20_seq_O0 asterics_hpc TBB::tbb) runExample(hadamard_product_cpp20_seq_O0) add_executable(hadamard_product_cpp20_seq_O1 main_cpp20.cpp) set_property(TARGET hadamard_product_cpp20_seq_O1 PROPERTY COMPILE_FLAGS "-O1 -Wall -std=c++20 -DEXECUTION_POLICY=\"std::execution::seq\"") target_link_libraries(hadamard_product_cpp20_seq_O1 asterics_hpc TBB::tbb) runExample(hadamard_product_cpp20_seq_O1) add_executable(hadamard_product_cpp20_seq_O2 main_cpp20.cpp) set_property(TARGET hadamard_product_cpp20_seq_O2 PROPERTY COMPILE_FLAGS "-O2 -Wall -std=c++20 -DEXECUTION_POLICY=\"std::execution::seq\"") target_link_libraries(hadamard_product_cpp20_seq_O2 asterics_hpc TBB::tbb) runExample(hadamard_product_cpp20_seq_O2) add_executable(hadamard_product_cpp20_unseq_O1 main_cpp20.cpp) set_property(TARGET hadamard_product_cpp20_unseq_O1 PROPERTY COMPILE_FLAGS "-O1 -Wall -std=c++20 -DEXECUTION_POLICY=\"std::execution::unseq\"") target_link_libraries(hadamard_product_cpp20_unseq_O1 asterics_hpc TBB::tbb) runExample(hadamard_product_cpp20_unseq_O1) add_executable(hadamard_product_cpp20_unseq_O2 main_cpp20.cpp) set_property(TARGET hadamard_product_cpp20_unseq_O2 PROPERTY COMPILE_FLAGS "-O2 -Wall -std=c++20 -DEXECUTION_POLICY=\"std::execution::unseq\"") target_link_libraries(hadamard_product_cpp20_unseq_O2 asterics_hpc TBB::tbb) runExample(hadamard_product_cpp20_unseq_O2) add_executable(hadamard_product_cpp20_unseq_O3 main_cpp20.cpp) set_property(TARGET hadamard_product_cpp20_unseq_O3 PROPERTY COMPILE_FLAGS "-O3 -Wall -std=c++20 -DEXECUTION_POLICY=\"std::execution::unseq\"") target_link_libraries(hadamard_product_cpp20_unseq_O3 asterics_hpc TBB::tbb) runExample(hadamard_product_cpp20_unseq_O3) add_executable(hadamard_product_cpp20_unseq_vectorize main_cpp20.cpp) set_property(TARGET hadamard_product_cpp20_unseq_vectorize PROPERTY COMPILE_FLAGS "-O3 -ftree-vectorize -march=native -mtune=native -mavx2 -Wall -std=c++20 -DEXECUTION_POLICY=\"std::execution::unseq\"") target_link_libraries(hadamard_product_cpp20_unseq_vectorize asterics_hpc TBB::tbb) runExample(hadamard_product_cpp20_unseq_vectorize) add_executable(hadamard_product_cpp20_unseq_vectorize_align main_cpp20_vectorize.cpp) set_property(TARGET hadamard_product_cpp20_unseq_vectorize_align PROPERTY COMPILE_FLAGS "-O3 -ftree-vectorize -march=native -mtune=native -mavx2 -Wall -std=c++20 -DEXECUTION_POLICY=\"std::execution::unseq\"") target_link_libraries(hadamard_product_cpp20_unseq_vectorize_align asterics_hpc TBB::tbb) runExample(hadamard_product_cpp20_unseq_vectorize_align) add_executable(hadamard_product_O0 main.cpp) set_property(TARGET hadamard_product_O0 PROPERTY COMPILE_FLAGS "-O0") target_link_libraries(hadamard_product_O0 asterics_hpc) runExample(hadamard_product_O0) add_executable(hadamard_product_O1 main.cpp) set_property(TARGET hadamard_product_O1 PROPERTY COMPILE_FLAGS "-O1") target_link_libraries(hadamard_product_O1 asterics_hpc) runExample(hadamard_product_O1) add_executable(hadamard_product_O2 main.cpp) set_property(TARGET hadamard_product_O2 PROPERTY COMPILE_FLAGS "-O2") target_link_libraries(hadamard_product_O2 asterics_hpc) runExample(hadamard_product_O2) add_executable(hadamard_product_O3 main.cpp) set_property(TARGET hadamard_product_O3 PROPERTY COMPILE_FLAGS "-O3") target_link_libraries(hadamard_product_O3 asterics_hpc) runExample(hadamard_product_O3) add_executable(hadamard_product_Ofast main.cpp) set_property(TARGET hadamard_product_Ofast PROPERTY COMPILE_FLAGS "-Ofast") target_link_libraries(hadamard_product_Ofast asterics_hpc) runExample(hadamard_product_Ofast) add_executable(hadamard_product_vectorize main_vectorize.cpp) set_property(TARGET hadamard_product_vectorize PROPERTY COMPILE_FLAGS "-O3 -ftree-vectorize -march=native -mtune=native -mavx2") target_link_libraries(hadamard_product_vectorize asterics_hpc) runExample(hadamard_product_vectorize) add_executable(hadamard_product_intrinsics main_intrinsics.cpp) set_property(TARGET hadamard_product_intrinsics PROPERTY COMPILE_FLAGS "-O3 -march=native -mtune=native") target_link_libraries(hadamard_product_intrinsics asterics_hpc) runExample(hadamard_product_intrinsics) add_executable(hadamard_product_intrinsics_interleaved2 main_intrinsics_interleaved2.cpp) set_property(TARGET hadamard_product_intrinsics_interleaved2 PROPERTY COMPILE_FLAGS "-O3 -march=native -mtune=native") target_link_libraries(hadamard_product_intrinsics_interleaved2 asterics_hpc) runExample(hadamard_product_intrinsics_interleaved2) plotPerf("hadamardBase" hadamard_product_O0 hadamard_product_O1 hadamard_product_O2 hadamard_product_O3 hadamard_product_Ofast) plotPerf("hadamardCpp20seq" hadamard_product_cpp20_seq_O0 hadamard_product_cpp20_seq_O1 hadamard_product_cpp20_seq_O2) plotPerf("hadamardCpp20unseq" hadamard_product_cpp20_unseq_O1 hadamard_product_cpp20_unseq_O2 hadamard_product_cpp20_unseq_O3 hadamard_product_cpp20_unseq_vectorize hadamard_product_cpp20_unseq_vectorize_align) plotPerf("hadamardBaseCpp20" hadamard_product_O2 hadamard_product_O3 hadamard_product_Ofast hadamard_product_cpp20_seq_O2 hadamard_product_cpp20_unseq_O3) plotPerf("hadamardVectorize" hadamard_product_O3 hadamard_product_vectorize hadamard_product_cpp20_unseq_vectorize hadamard_product_cpp20_unseq_vectorize_align) plotPerf("hadamardIntrinsics" hadamard_product_O3 hadamard_product_vectorize hadamard_product_intrinsics) plotPerf("hadamardSummary" hadamard_product_O0 hadamard_product_O3 hadamard_product_vectorize hadamard_product_intrinsics) plotPerf("hadamardIntrinsicsInterleaved2" hadamard_product_vectorize hadamard_product_intrinsics hadamard_product_intrinsics_interleaved2) |
Le CMakeLists.txt complet :
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 |
project(HadamardProduct) cmake_minimum_required(VERSION 3.0) find_package(TBB COMPONENTS tbb REQUIRED) include(runExample.cmake) add_definitions(-DVECTOR_ALIGNEMENT=32) add_subdirectory(AstericsHPC) include_directories(AstericsHPC) add_executable(hadamard_product_cpp20_seq_O0 main_cpp20.cpp) set_property(TARGET hadamard_product_cpp20_seq_O0 PROPERTY COMPILE_FLAGS "-O0 -Wall -std=c++20 -DEXECUTION_POLICY=\"std::execution::seq\"") target_link_libraries(hadamard_product_cpp20_seq_O0 asterics_hpc TBB::tbb) runExample(hadamard_product_cpp20_seq_O0) add_executable(hadamard_product_cpp20_seq_O1 main_cpp20.cpp) set_property(TARGET hadamard_product_cpp20_seq_O1 PROPERTY COMPILE_FLAGS "-O1 -Wall -std=c++20 -DEXECUTION_POLICY=\"std::execution::seq\"") target_link_libraries(hadamard_product_cpp20_seq_O1 asterics_hpc TBB::tbb) runExample(hadamard_product_cpp20_seq_O1) add_executable(hadamard_product_cpp20_seq_O2 main_cpp20.cpp) set_property(TARGET hadamard_product_cpp20_seq_O2 PROPERTY COMPILE_FLAGS "-O2 -Wall -std=c++20 -DEXECUTION_POLICY=\"std::execution::seq\"") target_link_libraries(hadamard_product_cpp20_seq_O2 asterics_hpc TBB::tbb) runExample(hadamard_product_cpp20_seq_O2) add_executable(hadamard_product_cpp20_unseq_O1 main_cpp20.cpp) set_property(TARGET hadamard_product_cpp20_unseq_O1 PROPERTY COMPILE_FLAGS "-O1 -Wall -std=c++20 -DEXECUTION_POLICY=\"std::execution::unseq\"") target_link_libraries(hadamard_product_cpp20_unseq_O1 asterics_hpc TBB::tbb) runExample(hadamard_product_cpp20_unseq_O1) add_executable(hadamard_product_cpp20_unseq_O2 main_cpp20.cpp) set_property(TARGET hadamard_product_cpp20_unseq_O2 PROPERTY COMPILE_FLAGS "-O2 -Wall -std=c++20 -DEXECUTION_POLICY=\"std::execution::unseq\"") target_link_libraries(hadamard_product_cpp20_unseq_O2 asterics_hpc TBB::tbb) runExample(hadamard_product_cpp20_unseq_O2) add_executable(hadamard_product_cpp20_unseq_O3 main_cpp20.cpp) set_property(TARGET hadamard_product_cpp20_unseq_O3 PROPERTY COMPILE_FLAGS "-O3 -Wall -std=c++20 -DEXECUTION_POLICY=\"std::execution::unseq\"") target_link_libraries(hadamard_product_cpp20_unseq_O3 asterics_hpc TBB::tbb) runExample(hadamard_product_cpp20_unseq_O3) add_executable(hadamard_product_cpp20_unseq_vectorize main_cpp20.cpp) set_property(TARGET hadamard_product_cpp20_unseq_vectorize PROPERTY COMPILE_FLAGS "-O3 -ftree-vectorize -march=native -mtune=native -mavx2 -Wall -std=c++20 -DEXECUTION_POLICY=\"std::execution::unseq\"") target_link_libraries(hadamard_product_cpp20_unseq_vectorize asterics_hpc TBB::tbb) runExample(hadamard_product_cpp20_unseq_vectorize) add_executable(hadamard_product_cpp20_unseq_vectorize_align main_cpp20_vectorize.cpp) set_property(TARGET hadamard_product_cpp20_unseq_vectorize_align PROPERTY COMPILE_FLAGS "-O3 -ftree-vectorize -march=native -mtune=native -mavx2 -Wall -std=c++20 -DEXECUTION_POLICY=\"std::execution::unseq\"") target_link_libraries(hadamard_product_cpp20_unseq_vectorize_align asterics_hpc TBB::tbb) runExample(hadamard_product_cpp20_unseq_vectorize_align) add_executable(hadamard_product_O0 main.cpp) set_property(TARGET hadamard_product_O0 PROPERTY COMPILE_FLAGS "-O0") target_link_libraries(hadamard_product_O0 asterics_hpc) runExample(hadamard_product_O0) add_executable(hadamard_product_O1 main.cpp) set_property(TARGET hadamard_product_O1 PROPERTY COMPILE_FLAGS "-O1") target_link_libraries(hadamard_product_O1 asterics_hpc) runExample(hadamard_product_O1) add_executable(hadamard_product_O2 main.cpp) set_property(TARGET hadamard_product_O2 PROPERTY COMPILE_FLAGS "-O2") target_link_libraries(hadamard_product_O2 asterics_hpc) runExample(hadamard_product_O2) add_executable(hadamard_product_O3 main.cpp) set_property(TARGET hadamard_product_O3 PROPERTY COMPILE_FLAGS "-O3") target_link_libraries(hadamard_product_O3 asterics_hpc) runExample(hadamard_product_O3) add_executable(hadamard_product_Ofast main.cpp) set_property(TARGET hadamard_product_Ofast PROPERTY COMPILE_FLAGS "-Ofast") target_link_libraries(hadamard_product_Ofast asterics_hpc) runExample(hadamard_product_Ofast) add_executable(hadamard_product_vectorize main_vectorize.cpp) set_property(TARGET hadamard_product_vectorize PROPERTY COMPILE_FLAGS "-O3 -ftree-vectorize -march=native -mtune=native -mavx2") target_link_libraries(hadamard_product_vectorize asterics_hpc) runExample(hadamard_product_vectorize) add_executable(hadamard_product_intrinsics main_intrinsics.cpp) set_property(TARGET hadamard_product_intrinsics PROPERTY COMPILE_FLAGS "-O3 -march=native -mtune=native") target_link_libraries(hadamard_product_intrinsics asterics_hpc) runExample(hadamard_product_intrinsics) add_executable(hadamard_product_intrinsics_interleaved2 main_intrinsics_interleaved2.cpp) set_property(TARGET hadamard_product_intrinsics_interleaved2 PROPERTY COMPILE_FLAGS "-O3 -march=native -mtune=native") target_link_libraries(hadamard_product_intrinsics_interleaved2 asterics_hpc) runExample(hadamard_product_intrinsics_interleaved2) plotPerf("hadamardBase" hadamard_product_O0 hadamard_product_O1 hadamard_product_O2 hadamard_product_O3 hadamard_product_Ofast) plotPerf("hadamardCpp20seq" hadamard_product_cpp20_seq_O0 hadamard_product_cpp20_seq_O1 hadamard_product_cpp20_seq_O2) plotPerf("hadamardCpp20unseq" hadamard_product_cpp20_unseq_O1 hadamard_product_cpp20_unseq_O2 hadamard_product_cpp20_unseq_O3 hadamard_product_cpp20_unseq_vectorize hadamard_product_cpp20_unseq_vectorize_align) plotPerf("hadamardBaseCpp20" hadamard_product_O2 hadamard_product_O3 hadamard_product_Ofast hadamard_product_cpp20_seq_O2 hadamard_product_cpp20_unseq_O3) plotPerf("hadamardVectorize" hadamard_product_O3 hadamard_product_vectorize hadamard_product_cpp20_unseq_vectorize hadamard_product_cpp20_unseq_vectorize_align) plotPerf("hadamardIntrinsics" hadamard_product_O3 hadamard_product_vectorize hadamard_product_intrinsics) plotPerf("hadamardSummary" hadamard_product_O0 hadamard_product_O3 hadamard_product_vectorize hadamard_product_intrinsics) plotPerf("hadamardIntrinsicsInterleaved2" hadamard_product_vectorize hadamard_product_intrinsics hadamard_product_intrinsics_interleaved2) |