From 30c3cc6d19591aae2cc98d1d796df43c4db033f4 Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 8 Nov 2024 00:22:01 +0100 Subject: [PATCH 01/20] Adding OpenMP as compilation option with a simple test --- .README.md.swp | Bin 0 -> 12288 bytes CMakeLists.txt | 30 +++++++++++++++------- README.md | 6 +++++ examples/loop_omp.cpp | 29 +++++++++++++++++++++ examples/{simple.cpp => matrix_eigen.cpp} | 0 5 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 .README.md.swp create mode 100644 examples/loop_omp.cpp rename examples/{simple.cpp => matrix_eigen.cpp} (100%) diff --git a/.README.md.swp b/.README.md.swp new file mode 100644 index 0000000000000000000000000000000000000000..4dcf1f910fceff30d04a588427d7585c5e474f6c GIT binary patch literal 12288 zcmeI2y>A>v7{(_Fhy+LokP4a?43Q)I?qV#I6p4|2cSIJs*s>iEGEr`BcW!U+?#yO( z*3MDzQPA-r@zFv-!9ReM3QEdEf&!!zAVk3*0HFh(*$?A@6DZO|nv;G$-|oBfKJW9s zv$o|O9Di}KM<<&z46nnCU4On2O}>AG{nTMB76WcFcjET1{~Pyu8QAKGL|9>3E8Y1{ zuiH$*+b{3WdI!7%cf^5%Z1$O%<8G;mC!e54A31+VR`rW`2fPE`0q=l!z&qd_@D6wf zyaRWK12)~m-hkA-mE6VZea}DMtB?N8JK!Dg4tNK=1Kt7efOo(<;2rP|cn7=#-hsQ& z0givZU%8L5-}gg2{{LV9{eR;j#(o3$f_s2E#8?7Of)ijGOo2n->Osc70GnVP{Q4k1 zgAaiON5IbyFm?@G1z&+L!8&*jJPsZM2f%*7z%TbR_5=71d<(t-*T7ZqHMjyk1D}FV zz{lVt@D6wzyanC_A$SEez&`Nj0ml9SKZ5VU=imeI9(Wf>z`<#73_J~<0uO`3U?12E zoL@JbXa40K@D6wfyaV0=@4(&Sz{CWdm4Q&1z@tzTv?7MW2o;o{){M>vvB*YRTd5+( z`u#o&622j*(HP`14ypKBA6um+H5STa)aaaF?Ot43?w;!{pI$oWt{w1fge()()@mrD z+z8@iL@anFXiM4=Eu}*BmT#G;wOghZQc=4%|3dfT!uiFsor`NPFLzI`l*|5S+Ohx_ zR)l;NM-1}lmKs8Lwz9BL&}=1Ks_l5THWG@g8Q;>7 zT1jR4-&bl=UQ;&f)he#pWXVP-O;yv;qZHIF>{sn^Q?O99maC9fa)nGRZ* zRGH;*OtBmYcXYN9ip@S^+C4WHH^mgA(r5G3o|>XSC#j5uDZb%WVzA1db4zXlENu#t zNv&w+1nD6;!;wmb+=SC4q9&bbx9Q|GwPUU#dX}8NnB)1`W;ME(a%u2Ht+IGjw?XT4 zfjT0Sk;0J0I?~PR;2MuNh!1pb$%@QoG?`=kL_`6%!HBe>$Q?hnOMIvUXc|NLB;w0Y z20P7^ zTopD?2~87$)n<(RCJ!w3P94z3_Cx`^xT=4&XVPu$LI25DMNo91D{Q^rnZ`Cx9QNu4e%?MWpw zbedE*w+5rUX1K~yZO~aAZ+2HswOlx3=ki3Daw4XS%;{*H$snVYBUWZbFGDBGZJomF z<*^-MMV>(tWE-4B#vu&(jf=(%-B!x2jAe$Q(<*CH=>S&6b?`}7+dru8!gUy9 z)dT6MDV>{fTGKfvhEsxpG)NAcHEz+UCO1eNy2sa(?V?3lwB0V+&2ga)opjUdyv(s@ zOIf(Pl{1SJVX;$7bt%fyCZXAmn?MY4nam|GZaJGg&T%D=gL*ADtj=IJt*(zqVr3)3 XkFS)}zf_4!c_G1d61Rxr8GQB^>!F#z literal 0 HcmV?d00001 diff --git a/CMakeLists.txt b/CMakeLists.txt index b7d462c..e50c995 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,20 +10,32 @@ set(CMAKE_CXX_FLAGS_DEBUG "-g -fsanitize=address,undefined") # include_directories(include) -# OpenMP -find_package(OpenMP) -if(OpenMP_CXX_FOUND) - set(LINK_LIBS ${LINK_LIBS} ${OpenMP_CXX_LIBRARIES}) -endif() - # Eigen find_package(Eigen3 3.3 REQUIRED NO_MODULE) set(LINK_LIBS ${LINK_LIBS} Eigen3::Eigen) - # Executables add_executable(main examples/main.cpp) # create an executable using the specified file target_link_libraries(main PUBLIC ${LINK_LIBS}) -add_executable(simple examples/simple.cpp) # create an executable using the specified file -target_link_libraries(simple PUBLIC ${LINK_LIBS}) \ No newline at end of file +add_executable(matrix_eigen examples/matrix_eigen.cpp) # create an executable using the specified file +target_link_libraries(matrix_eigen PUBLIC ${LINK_LIBS}) + + +# OpenMP activation +option(USE_OPENMP "Enable OpenMP support" OFF) + +# If ON search for OpenMP +if(USE_OPENMP) + find_package(OpenMP REQUIRED) + if(OpenMP_CXX_FOUND) + add_executable(loop_omp examples/loop_omp.cpp) # create an executable using the specified file + target_compile_options(loop_omp PUBLIC ${OpenMP_CXX_FLAGS}) + target_link_libraries(loop_omp PUBLIC ${OpenMP_CXX_FLAGS}) + message(STATUS "OpenMP flags added for GCC/Clang: ${OpenMP_CXX_FLAGS}") + else() + message(FATAL_ERROR "OpenMP was requested but could not be found.") + endif() +else() + message(STATUS "OpenMP support disabled") +endif() diff --git a/README.md b/README.md index 71edb0f..9975422 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,12 @@ cmake -S . -B build/ -D CMAKE_BUILD_TYPE=Release cmake --build build/ ``` +### Configure a release with OpenMP +```bash +cmake -S . -B build -DUSE_OPENMP=ON +cmake --build build +``` + ## Troubleshooting ## Reference diff --git a/examples/loop_omp.cpp b/examples/loop_omp.cpp new file mode 100644 index 0000000..62bfa22 --- /dev/null +++ b/examples/loop_omp.cpp @@ -0,0 +1,29 @@ +#include +#include +#include + +int main() { + // Initialisation d'un grand tableau pour simuler une charge de travail + const int N = 1000000; + std::vector array(N, 1); // Crée un tableau avec des valeurs de 1 + int sum = 0; + + // Mesurer le temps avant le calcul + double start_time = omp_get_wtime(); + + // Début de la région parallèle + #pragma omp parallel for reduction(+:sum) + for (int i = 0; i < N; ++i) { + sum += array[i]; + } + + // Mesurer le temps après le calcul + double end_time = omp_get_wtime(); + + // Résultats + std::cout << "La somme est: " << sum << std::endl; + std::cout << "Temps d'exécution avec OpenMP: " << (end_time - start_time) << " secondes" << std::endl; + + return 0; +} + diff --git a/examples/simple.cpp b/examples/matrix_eigen.cpp similarity index 100% rename from examples/simple.cpp rename to examples/matrix_eigen.cpp From c6e16b2eb5afde358e90be2e299dc9814f29c5e8 Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 8 Nov 2024 00:26:57 +0100 Subject: [PATCH 02/20] Adding OpenMP as compilation option with a simple test --- .github/workflows/cmake-multi-platform.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index cf8c92d..34ce798 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -79,7 +79,7 @@ jobs: run: ${{github.workspace}}/build/main - name: Run example - run: ${{github.workspace}}/build/simple + run: ${{github.workspace}}/build/matrix_eigen # - name: Test # working-directory: ${{ steps.strings.outputs.build-output-dir }} From d19163055c9a41f80bcb79d6358bfa0e5333cd0f Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 8 Nov 2024 01:30:38 +0100 Subject: [PATCH 03/20] Corrections pull request #5 --- .README.md.swp | Bin 12288 -> 0 bytes .github/workflows/cmake-multi-platform.yml | 3 ++ .gitignore | 6 +++- CMakeLists.txt | 31 ++++++++------------- README.md | 6 ---- examples/loop_omp.cpp | 4 +-- 6 files changed, 21 insertions(+), 29 deletions(-) delete mode 100644 .README.md.swp diff --git a/.README.md.swp b/.README.md.swp deleted file mode 100644 index 4dcf1f910fceff30d04a588427d7585c5e474f6c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2y>A>v7{(_Fhy+LokP4a?43Q)I?qV#I6p4|2cSIJs*s>iEGEr`BcW!U+?#yO( z*3MDzQPA-r@zFv-!9ReM3QEdEf&!!zAVk3*0HFh(*$?A@6DZO|nv;G$-|oBfKJW9s zv$o|O9Di}KM<<&z46nnCU4On2O}>AG{nTMB76WcFcjET1{~Pyu8QAKGL|9>3E8Y1{ zuiH$*+b{3WdI!7%cf^5%Z1$O%<8G;mC!e54A31+VR`rW`2fPE`0q=l!z&qd_@D6wf zyaRWK12)~m-hkA-mE6VZea}DMtB?N8JK!Dg4tNK=1Kt7efOo(<;2rP|cn7=#-hsQ& z0givZU%8L5-}gg2{{LV9{eR;j#(o3$f_s2E#8?7Of)ijGOo2n->Osc70GnVP{Q4k1 zgAaiON5IbyFm?@G1z&+L!8&*jJPsZM2f%*7z%TbR_5=71d<(t-*T7ZqHMjyk1D}FV zz{lVt@D6wzyanC_A$SEez&`Nj0ml9SKZ5VU=imeI9(Wf>z`<#73_J~<0uO`3U?12E zoL@JbXa40K@D6wfyaV0=@4(&Sz{CWdm4Q&1z@tzTv?7MW2o;o{){M>vvB*YRTd5+( z`u#o&622j*(HP`14ypKBA6um+H5STa)aaaF?Ot43?w;!{pI$oWt{w1fge()()@mrD z+z8@iL@anFXiM4=Eu}*BmT#G;wOghZQc=4%|3dfT!uiFsor`NPFLzI`l*|5S+Ohx_ zR)l;NM-1}lmKs8Lwz9BL&}=1Ks_l5THWG@g8Q;>7 zT1jR4-&bl=UQ;&f)he#pWXVP-O;yv;qZHIF>{sn^Q?O99maC9fa)nGRZ* zRGH;*OtBmYcXYN9ip@S^+C4WHH^mgA(r5G3o|>XSC#j5uDZb%WVzA1db4zXlENu#t zNv&w+1nD6;!;wmb+=SC4q9&bbx9Q|GwPUU#dX}8NnB)1`W;ME(a%u2Ht+IGjw?XT4 zfjT0Sk;0J0I?~PR;2MuNh!1pb$%@QoG?`=kL_`6%!HBe>$Q?hnOMIvUXc|NLB;w0Y z20P7^ zTopD?2~87$)n<(RCJ!w3P94z3_Cx`^xT=4&XVPu$LI25DMNo91D{Q^rnZ`Cx9QNu4e%?MWpw zbedE*w+5rUX1K~yZO~aAZ+2HswOlx3=ki3Daw4XS%;{*H$snVYBUWZbFGDBGZJomF z<*^-MMV>(tWE-4B#vu&(jf=(%-B!x2jAe$Q(<*CH=>S&6b?`}7+dru8!gUy9 z)dT6MDV>{fTGKfvhEsxpG)NAcHEz+UCO1eNy2sa(?V?3lwB0V+&2ga)opjUdyv(s@ zOIf(Pl{1SJVX;$7bt%fyCZXAmn?MY4nam|GZaJGg&T%D=gL*ADtj=IJt*(zqVr3)3 XkFS)}zf_4!c_G1d61Rxr8GQB^>!F#z diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index 34ce798..0758e97 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -80,6 +80,9 @@ jobs: - name: Run example run: ${{github.workspace}}/build/matrix_eigen + + - name: Run example + run: ${{github.workspace}}/build/loop_omp # - name: Test # working-directory: ${{ steps.strings.outputs.build-output-dir }} diff --git a/.gitignore b/.gitignore index a20d21e..3446d93 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,8 @@ debug # Compiled Static libraries *.a -*.lib \ No newline at end of file +*.lib + +# VIM Tampon file +*.swp +*.swo diff --git a/CMakeLists.txt b/CMakeLists.txt index e50c995..9059501 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,15 +5,22 @@ set(CMAKE_CXX_STANDARD 14) # specifying the C++ Standard set(GCC_COVERAGE_COMPILE_FLAGS "-Wall -Wextra -pedantic") # probably not the best variable name set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}") -set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native -funroll-loops -funroll-all-loops -DNDEBUG") -set(CMAKE_CXX_FLAGS_DEBUG "-g -fsanitize=address,undefined") +set(CMAKE_CXX_FLAGS_RELEASE "-O3 -fopenmp -march=native -funroll-loops -funroll-all-loops -DNDEBUG") +set(CMAKE_CXX_FLAGS_DEBUG "-g -fopenmp -fsanitize=address,undefined") # include_directories(include) +# OpenMP +find_package(OpenMP) +if(OpenMP_CXX_FOUND) + set(LINK_LIBS ${LINK_LIBS} ${OpenMP_CXX_LIBRARIES}) +endif() + # Eigen find_package(Eigen3 3.3 REQUIRED NO_MODULE) set(LINK_LIBS ${LINK_LIBS} Eigen3::Eigen) + # Executables add_executable(main examples/main.cpp) # create an executable using the specified file target_link_libraries(main PUBLIC ${LINK_LIBS}) @@ -21,21 +28,5 @@ target_link_libraries(main PUBLIC ${LINK_LIBS}) add_executable(matrix_eigen examples/matrix_eigen.cpp) # create an executable using the specified file target_link_libraries(matrix_eigen PUBLIC ${LINK_LIBS}) - -# OpenMP activation -option(USE_OPENMP "Enable OpenMP support" OFF) - -# If ON search for OpenMP -if(USE_OPENMP) - find_package(OpenMP REQUIRED) - if(OpenMP_CXX_FOUND) - add_executable(loop_omp examples/loop_omp.cpp) # create an executable using the specified file - target_compile_options(loop_omp PUBLIC ${OpenMP_CXX_FLAGS}) - target_link_libraries(loop_omp PUBLIC ${OpenMP_CXX_FLAGS}) - message(STATUS "OpenMP flags added for GCC/Clang: ${OpenMP_CXX_FLAGS}") - else() - message(FATAL_ERROR "OpenMP was requested but could not be found.") - endif() -else() - message(STATUS "OpenMP support disabled") -endif() +add_executable(loop_omp examples/loop_omp.cpp) # create an executable using the specified file +target_link_libraries(loop_omp PUBLIC ${OpenMP_CXX_FLAGS}) diff --git a/README.md b/README.md index 9975422..71edb0f 100644 --- a/README.md +++ b/README.md @@ -60,12 +60,6 @@ cmake -S . -B build/ -D CMAKE_BUILD_TYPE=Release cmake --build build/ ``` -### Configure a release with OpenMP -```bash -cmake -S . -B build -DUSE_OPENMP=ON -cmake --build build -``` - ## Troubleshooting ## Reference diff --git a/examples/loop_omp.cpp b/examples/loop_omp.cpp index 62bfa22..ffdf07f 100644 --- a/examples/loop_omp.cpp +++ b/examples/loop_omp.cpp @@ -5,7 +5,7 @@ int main() { // Initialisation d'un grand tableau pour simuler une charge de travail const int N = 1000000; - std::vector array(N, 1); // Crée un tableau avec des valeurs de 1 + std::vector tab(N, 1); // Crée un tableau avec des valeurs de 1 int sum = 0; // Mesurer le temps avant le calcul @@ -14,7 +14,7 @@ int main() { // Début de la région parallèle #pragma omp parallel for reduction(+:sum) for (int i = 0; i < N; ++i) { - sum += array[i]; + sum += tab[i]; } // Mesurer le temps après le calcul From 27ffbed30eb7e44cec73fa98515e3eb47caa724e Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 8 Nov 2024 01:33:51 +0100 Subject: [PATCH 04/20] Corrections pull request #5 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9059501..c308093 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,4 +29,4 @@ add_executable(matrix_eigen examples/matrix_eigen.cpp) # create an executable us target_link_libraries(matrix_eigen PUBLIC ${LINK_LIBS}) add_executable(loop_omp examples/loop_omp.cpp) # create an executable using the specified file -target_link_libraries(loop_omp PUBLIC ${OpenMP_CXX_FLAGS}) +target_link_libraries(loop_omp PUBLIC ${LINK_LIBS}) From c12bb9d1397adb5cb611523d090f9bf2ac3c998a Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 8 Nov 2024 01:55:52 +0100 Subject: [PATCH 05/20] Correcting OpenMp flag : pull request #5 --- CMakeLists.txt | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c308093..7741e73 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,17 +5,31 @@ set(CMAKE_CXX_STANDARD 14) # specifying the C++ Standard set(GCC_COVERAGE_COMPILE_FLAGS "-Wall -Wextra -pedantic") # probably not the best variable name set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}") -set(CMAKE_CXX_FLAGS_RELEASE "-O3 -fopenmp -march=native -funroll-loops -funroll-all-loops -DNDEBUG") -set(CMAKE_CXX_FLAGS_DEBUG "-g -fopenmp -fsanitize=address,undefined") +set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native -funroll-loops -funroll-all-loops -DNDEBUG") +set(CMAKE_CXX_FLAGS_DEBUG "-g -fsanitize=address,undefined") # include_directories(include) # OpenMP find_package(OpenMP) if(OpenMP_CXX_FOUND) + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${OpenMP_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${OpenMP_CXX_FLAGS}") set(LINK_LIBS ${LINK_LIBS} ${OpenMP_CXX_LIBRARIES}) endif() +# find_package(OpenMP REQUIRED) +# if(OpenMP_CXX_FOUND) +# add_executable(loop_omp examples/loop_omp.cpp) # create an executable using the specified file +# target_compile_options(loop_omp PUBLIC ${OpenMP_CXX_FLAGS}) +# target_link_libraries(loop_omp PUBLIC ${OpenMP_CXX_FLAGS}) +# message(STATUS "OpenMP flags added for GCC/Clang: ${OpenMP_CXX_FLAGS}") +# else() +# message(FATAL_ERROR "OpenMP was requested but could not be found.") +# endif() + + + # Eigen find_package(Eigen3 3.3 REQUIRED NO_MODULE) set(LINK_LIBS ${LINK_LIBS} Eigen3::Eigen) From 36a342dd5e612439d626d3e3002635f9ab181ec2 Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 8 Nov 2024 02:01:34 +0100 Subject: [PATCH 06/20] Correcting OpenMp flag : pull request #5 --- CMakeLists.txt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7741e73..4668ea4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ project(demeter) # set the project name set(CMAKE_CXX_STANDARD 14) # specifying the C++ Standard set(GCC_COVERAGE_COMPILE_FLAGS "-Wall -Wextra -pedantic") # probably not the best variable name -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} -fopenmp") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native -funroll-loops -funroll-all-loops -DNDEBUG") set(CMAKE_CXX_FLAGS_DEBUG "-g -fsanitize=address,undefined") @@ -12,11 +12,10 @@ set(CMAKE_CXX_FLAGS_DEBUG "-g -fsanitize=address,undefined") # OpenMP find_package(OpenMP) -if(OpenMP_CXX_FOUND) - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${OpenMP_CXX_FLAGS}") - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${OpenMP_CXX_FLAGS}") - set(LINK_LIBS ${LINK_LIBS} ${OpenMP_CXX_LIBRARIES}) -endif() +set(LINK_LIBS ${LINK_LIBS} OpenMP::OpenMP_CXX) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp") + + # find_package(OpenMP REQUIRED) # if(OpenMP_CXX_FOUND) From 3f44b6d94e7bac2fb067343dbf89c2632fc563f4 Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 8 Nov 2024 02:07:23 +0100 Subject: [PATCH 07/20] Correcting OpenMp flag : pull request #5 --- CMakeLists.txt | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4668ea4..bc203ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ project(demeter) # set the project name set(CMAKE_CXX_STANDARD 14) # specifying the C++ Standard set(GCC_COVERAGE_COMPILE_FLAGS "-Wall -Wextra -pedantic") # probably not the best variable name -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} -fopenmp") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native -funroll-loops -funroll-all-loops -DNDEBUG") set(CMAKE_CXX_FLAGS_DEBUG "-g -fsanitize=address,undefined") @@ -12,22 +12,8 @@ set(CMAKE_CXX_FLAGS_DEBUG "-g -fsanitize=address,undefined") # OpenMP find_package(OpenMP) -set(LINK_LIBS ${LINK_LIBS} OpenMP::OpenMP_CXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp") - - - -# find_package(OpenMP REQUIRED) -# if(OpenMP_CXX_FOUND) -# add_executable(loop_omp examples/loop_omp.cpp) # create an executable using the specified file -# target_compile_options(loop_omp PUBLIC ${OpenMP_CXX_FLAGS}) -# target_link_libraries(loop_omp PUBLIC ${OpenMP_CXX_FLAGS}) -# message(STATUS "OpenMP flags added for GCC/Clang: ${OpenMP_CXX_FLAGS}") -# else() -# message(FATAL_ERROR "OpenMP was requested but could not be found.") -# endif() - - +set(LINK_LIBS ${LINK_LIBS} OpenMP::OpenMP_CXX) # Eigen find_package(Eigen3 3.3 REQUIRED NO_MODULE) From 5f600fec076f57cdf92b19c5165b699f8a51df06 Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 8 Nov 2024 02:13:09 +0100 Subject: [PATCH 08/20] Correcting OpenMp flag : pull request #5 --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bc203ac..ca3dd97 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,10 +22,14 @@ set(LINK_LIBS ${LINK_LIBS} Eigen3::Eigen) # Executables add_executable(main examples/main.cpp) # create an executable using the specified file +target_compile_options(main PUBLIC ${OpenMP_CXX_FLAGS}) target_link_libraries(main PUBLIC ${LINK_LIBS}) add_executable(matrix_eigen examples/matrix_eigen.cpp) # create an executable using the specified file +target_compile_options(matrix_eigen PUBLIC ${OpenMP_CXX_FLAGS}) target_link_libraries(matrix_eigen PUBLIC ${LINK_LIBS}) +find_package(OpenMP REQUIRED) add_executable(loop_omp examples/loop_omp.cpp) # create an executable using the specified file -target_link_libraries(loop_omp PUBLIC ${LINK_LIBS}) +target_compile_options(loop_omp PUBLIC ${OpenMP_CXX_FLAGS}) +target_link_libraries(loop_omp PUBLIC ${OpenMP_CXX_FLAGS}) From 918b4074c1268a1451fa6714e80600109c7894bd Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 8 Nov 2024 02:19:46 +0100 Subject: [PATCH 09/20] Correcting OpenMp flag : pull request #5 --- CMakeLists.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ca3dd97..3ddccd1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,8 +12,6 @@ set(CMAKE_CXX_FLAGS_DEBUG "-g -fsanitize=address,undefined") # OpenMP find_package(OpenMP) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp") -set(LINK_LIBS ${LINK_LIBS} OpenMP::OpenMP_CXX) # Eigen find_package(Eigen3 3.3 REQUIRED NO_MODULE) @@ -22,14 +20,14 @@ set(LINK_LIBS ${LINK_LIBS} Eigen3::Eigen) # Executables add_executable(main examples/main.cpp) # create an executable using the specified file -target_compile_options(main PUBLIC ${OpenMP_CXX_FLAGS}) +target_compile_options(main PUBLIC "${OpenMP_CXX_FLAGS} ${OpenMP_CXX_LIB_NAMES}") target_link_libraries(main PUBLIC ${LINK_LIBS}) add_executable(matrix_eigen examples/matrix_eigen.cpp) # create an executable using the specified file -target_compile_options(matrix_eigen PUBLIC ${OpenMP_CXX_FLAGS}) +target_compile_options(matrix_eigen PUBLIC "${OpenMP_CXX_FLAGS} ${OpenMP_CXX_LIB_NAMES}") target_link_libraries(matrix_eigen PUBLIC ${LINK_LIBS}) find_package(OpenMP REQUIRED) add_executable(loop_omp examples/loop_omp.cpp) # create an executable using the specified file -target_compile_options(loop_omp PUBLIC ${OpenMP_CXX_FLAGS}) +target_compile_options(loop_omp PUBLIC "${OpenMP_CXX_FLAGS} ${OpenMP_CXX_LIB_NAMES}") target_link_libraries(loop_omp PUBLIC ${OpenMP_CXX_FLAGS}) From 5f1cf9a9132625aed64d80e037a25098bf8dd5aa Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 8 Nov 2024 02:29:38 +0100 Subject: [PATCH 10/20] Correcting OpenMp flag : pull request #5 --- CMakeLists.txt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ddccd1..08254c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ project(demeter) # set the project name set(CMAKE_CXX_STANDARD 14) # specifying the C++ Standard set(GCC_COVERAGE_COMPILE_FLAGS "-Wall -Wextra -pedantic") # probably not the best variable name -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} ${OpenMP_CXX_FLAGS}") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native -funroll-loops -funroll-all-loops -DNDEBUG") set(CMAKE_CXX_FLAGS_DEBUG "-g -fsanitize=address,undefined") @@ -12,6 +12,7 @@ set(CMAKE_CXX_FLAGS_DEBUG "-g -fsanitize=address,undefined") # OpenMP find_package(OpenMP) +set(LINK_LIBS ${LINK_LIBS} ${OpenMP_CXX_LIBRARIES}) # Eigen find_package(Eigen3 3.3 REQUIRED NO_MODULE) @@ -20,14 +21,10 @@ set(LINK_LIBS ${LINK_LIBS} Eigen3::Eigen) # Executables add_executable(main examples/main.cpp) # create an executable using the specified file -target_compile_options(main PUBLIC "${OpenMP_CXX_FLAGS} ${OpenMP_CXX_LIB_NAMES}") target_link_libraries(main PUBLIC ${LINK_LIBS}) add_executable(matrix_eigen examples/matrix_eigen.cpp) # create an executable using the specified file -target_compile_options(matrix_eigen PUBLIC "${OpenMP_CXX_FLAGS} ${OpenMP_CXX_LIB_NAMES}") target_link_libraries(matrix_eigen PUBLIC ${LINK_LIBS}) -find_package(OpenMP REQUIRED) add_executable(loop_omp examples/loop_omp.cpp) # create an executable using the specified file -target_compile_options(loop_omp PUBLIC "${OpenMP_CXX_FLAGS} ${OpenMP_CXX_LIB_NAMES}") -target_link_libraries(loop_omp PUBLIC ${OpenMP_CXX_FLAGS}) +target_link_libraries(loop_omp PUBLIC ${LINK_LIBS}) From 645b28ba440b77a9001b2ae5d860e80cb225bad4 Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 8 Nov 2024 02:35:52 +0100 Subject: [PATCH 11/20] Correcting OpenMp flag : pull request #5 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 08254c9..2a0b1c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ set(CMAKE_CXX_STANDARD 14) # specifying the C++ Standard set(GCC_COVERAGE_COMPILE_FLAGS "-Wall -Wextra -pedantic") # probably not the best variable name set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} ${OpenMP_CXX_FLAGS}") -set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native -funroll-loops -funroll-all-loops -DNDEBUG") +set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native -DNDEBUG") set(CMAKE_CXX_FLAGS_DEBUG "-g -fsanitize=address,undefined") # include_directories(include) From 734fc7fb44bcd9f4e1599759ba671bc1fc860517 Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 8 Nov 2024 02:37:30 +0100 Subject: [PATCH 12/20] Correcting OpenMp flag : pull request #5 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a0b1c6..cd99ea4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ project(demeter) # set the project name set(CMAKE_CXX_STANDARD 14) # specifying the C++ Standard set(GCC_COVERAGE_COMPILE_FLAGS "-Wall -Wextra -pedantic") # probably not the best variable name -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} ${OpenMP_CXX_FLAGS}") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} ${OpenMP_CXX_FLAGS} ${OpenMP_CXX_LIB_NAMES}") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native -DNDEBUG") set(CMAKE_CXX_FLAGS_DEBUG "-g -fsanitize=address,undefined") From b2e333a6b7e3ec5d45963d24396ca70109741baa Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 8 Nov 2024 02:39:27 +0100 Subject: [PATCH 13/20] Correcting OpenMp flag : pull request #5 --- CMakeLists.txt | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cd99ea4..b56b80a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,15 +1,7 @@ cmake_minimum_required(VERSION 3.4...3.31) # specifying a minimum CMake version project(demeter) # set the project name -set(CMAKE_CXX_STANDARD 14) # specifying the C++ Standard -set(GCC_COVERAGE_COMPILE_FLAGS "-Wall -Wextra -pedantic") # probably not the best variable name -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} ${OpenMP_CXX_FLAGS} ${OpenMP_CXX_LIB_NAMES}") - -set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native -DNDEBUG") -set(CMAKE_CXX_FLAGS_DEBUG "-g -fsanitize=address,undefined") - # include_directories(include) - # OpenMP find_package(OpenMP) set(LINK_LIBS ${LINK_LIBS} ${OpenMP_CXX_LIBRARIES}) @@ -18,6 +10,12 @@ set(LINK_LIBS ${LINK_LIBS} ${OpenMP_CXX_LIBRARIES}) find_package(Eigen3 3.3 REQUIRED NO_MODULE) set(LINK_LIBS ${LINK_LIBS} Eigen3::Eigen) +set(CMAKE_CXX_STANDARD 14) # specifying the C++ Standard +set(GCC_COVERAGE_COMPILE_FLAGS "-Wall -Wextra -pedantic") # probably not the best variable name +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} ${OpenMP_CXX_FLAGS} ${OpenMP_CXX_LIB_NAMES}") + +set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native -DNDEBUG") +set(CMAKE_CXX_FLAGS_DEBUG "-g -fsanitize=address,undefined") # Executables add_executable(main examples/main.cpp) # create an executable using the specified file From ba8a568101b649d53e90b96d02a2d167c6a5015b Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 8 Nov 2024 02:43:38 +0100 Subject: [PATCH 14/20] Correcting OpenMp flag : pull request #5 --- CMakeLists.txt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b56b80a..b71dca5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,21 +1,22 @@ cmake_minimum_required(VERSION 3.4...3.31) # specifying a minimum CMake version project(demeter) # set the project name +set(CMAKE_CXX_STANDARD 14) # specifying the C++ Standard +set(GCC_COVERAGE_COMPILE_FLAGS "-Wall -Wextra -pedantic") # probably not the best variable name +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} ${OpenMP_CXX_FLAGS}") + +set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native -DNDEBUG") +set(CMAKE_CXX_FLAGS_DEBUG "-g -fsanitize=address,undefined") + # include_directories(include) # OpenMP find_package(OpenMP) -set(LINK_LIBS ${LINK_LIBS} ${OpenMP_CXX_LIBRARIES}) +set(LINK_LIBS ${LINK_LIBS} ${OpenMP_CXX_LIB_NAMES}) # Eigen find_package(Eigen3 3.3 REQUIRED NO_MODULE) set(LINK_LIBS ${LINK_LIBS} Eigen3::Eigen) -set(CMAKE_CXX_STANDARD 14) # specifying the C++ Standard -set(GCC_COVERAGE_COMPILE_FLAGS "-Wall -Wextra -pedantic") # probably not the best variable name -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} ${OpenMP_CXX_FLAGS} ${OpenMP_CXX_LIB_NAMES}") - -set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native -DNDEBUG") -set(CMAKE_CXX_FLAGS_DEBUG "-g -fsanitize=address,undefined") # Executables add_executable(main examples/main.cpp) # create an executable using the specified file From e94c029ab57073f9f12da50519db1e25eeb92338 Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 8 Nov 2024 02:49:32 +0100 Subject: [PATCH 15/20] Correcting OpenMp flag : pull request #5 --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b71dca5..6e8da16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ project(demeter) # set the project name set(CMAKE_CXX_STANDARD 14) # specifying the C++ Standard set(GCC_COVERAGE_COMPILE_FLAGS "-Wall -Wextra -pedantic") # probably not the best variable name -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} ${OpenMP_CXX_FLAGS}") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native -DNDEBUG") set(CMAKE_CXX_FLAGS_DEBUG "-g -fsanitize=address,undefined") @@ -11,7 +11,8 @@ set(CMAKE_CXX_FLAGS_DEBUG "-g -fsanitize=address,undefined") # include_directories(include) # OpenMP find_package(OpenMP) -set(LINK_LIBS ${LINK_LIBS} ${OpenMP_CXX_LIB_NAMES}) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") +set(LINK_LIBS ${LINK_LIBS} OpenMP::OpenMP_CXX) # Eigen find_package(Eigen3 3.3 REQUIRED NO_MODULE) From 4eb64bf188e93f22bbf2563ce9c50916c0c0afc4 Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 8 Nov 2024 02:52:04 +0100 Subject: [PATCH 16/20] Correcting OpenMp flag : pull request #5 --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e8da16..e30adc6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,8 +11,10 @@ set(CMAKE_CXX_FLAGS_DEBUG "-g -fsanitize=address,undefined") # include_directories(include) # OpenMP find_package(OpenMP) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") -set(LINK_LIBS ${LINK_LIBS} OpenMP::OpenMP_CXX) +if (OPENMP_FOUND) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") + set(LINK_LIBS ${LINK_LIBS} OpenMP::OpenMP_CXX) +endif() # Eigen find_package(Eigen3 3.3 REQUIRED NO_MODULE) From 94aaa096efa49f0fbac60aab4d5c775250df74c9 Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 8 Nov 2024 02:54:28 +0100 Subject: [PATCH 17/20] Correcting OpenMp flag : pull request #5 --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e30adc6..1a8723a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,4 +29,5 @@ add_executable(matrix_eigen examples/matrix_eigen.cpp) # create an executable us target_link_libraries(matrix_eigen PUBLIC ${LINK_LIBS}) add_executable(loop_omp examples/loop_omp.cpp) # create an executable using the specified file +target_compile_options(loop_omp PRIVATE ${OpenMP_CXX_FLAGS}) target_link_libraries(loop_omp PUBLIC ${LINK_LIBS}) From 9892845b1dfdbf1b76581fdaf9ef786ce7bc6b1d Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 8 Nov 2024 03:07:18 +0100 Subject: [PATCH 18/20] Correcting OpenMp flag : pull request #5 --- CMakeLists.txt | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a8723a..e3d70d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,19 +8,10 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native -DNDEBUG") set(CMAKE_CXX_FLAGS_DEBUG "-g -fsanitize=address,undefined") -# include_directories(include) -# OpenMP -find_package(OpenMP) -if (OPENMP_FOUND) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") - set(LINK_LIBS ${LINK_LIBS} OpenMP::OpenMP_CXX) -endif() - # Eigen find_package(Eigen3 3.3 REQUIRED NO_MODULE) set(LINK_LIBS ${LINK_LIBS} Eigen3::Eigen) - # Executables add_executable(main examples/main.cpp) # create an executable using the specified file target_link_libraries(main PUBLIC ${LINK_LIBS}) @@ -28,6 +19,7 @@ target_link_libraries(main PUBLIC ${LINK_LIBS}) add_executable(matrix_eigen examples/matrix_eigen.cpp) # create an executable using the specified file target_link_libraries(matrix_eigen PUBLIC ${LINK_LIBS}) +find_package(OpenMP) add_executable(loop_omp examples/loop_omp.cpp) # create an executable using the specified file target_compile_options(loop_omp PRIVATE ${OpenMP_CXX_FLAGS}) -target_link_libraries(loop_omp PUBLIC ${LINK_LIBS}) +target_link_libraries(loop_omp PUBLIC ${LINK_LIBS} OpenMP::OpenMP_CXX) From 574f6d7f84fd137342ec3a4e0ecd21037f5f5392 Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 8 Nov 2024 03:09:35 +0100 Subject: [PATCH 19/20] Correcting OpenMp flag : pull request #5 --- CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e3d70d7..acdfa66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,8 @@ add_executable(matrix_eigen examples/matrix_eigen.cpp) # create an executable us target_link_libraries(matrix_eigen PUBLIC ${LINK_LIBS}) find_package(OpenMP) -add_executable(loop_omp examples/loop_omp.cpp) # create an executable using the specified file -target_compile_options(loop_omp PRIVATE ${OpenMP_CXX_FLAGS}) -target_link_libraries(loop_omp PUBLIC ${LINK_LIBS} OpenMP::OpenMP_CXX) +if(OPENMP_FOUND) + add_executable(loop_omp examples/loop_omp.cpp) # create an executable using the specified file + target_compile_options(loop_omp PRIVATE ${OpenMP_CXX_FLAGS}) + target_link_libraries(loop_omp PUBLIC ${LINK_LIBS} OpenMP::OpenMP_CXX) +endif() From 4ce1a59122875edc7a51bba22bbfa2167f6bb87b Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 8 Nov 2024 03:11:49 +0100 Subject: [PATCH 20/20] Correcting OpenMp flag : pull request #5 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index acdfa66..578f557 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,6 @@ target_link_libraries(matrix_eigen PUBLIC ${LINK_LIBS}) find_package(OpenMP) if(OPENMP_FOUND) add_executable(loop_omp examples/loop_omp.cpp) # create an executable using the specified file - target_compile_options(loop_omp PRIVATE ${OpenMP_CXX_FLAGS}) + target_compile_options(loop_omp PUBLIC ${OpenMP_CXX_FLAGS}) target_link_libraries(loop_omp PUBLIC ${LINK_LIBS} OpenMP::OpenMP_CXX) endif()