From 9a23d52dd3847ac3c087225a64a9a9fb88b04204 Mon Sep 17 00:00:00 2001 From: Thomas Kittelmann Date: Thu, 20 Mar 2025 13:36:03 +0100 Subject: [PATCH 01/29] First stab at adding basic windows MSVC test --- .github/workflows/mcstas-winbasictest.yml | 88 +++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 .github/workflows/mcstas-winbasictest.yml diff --git a/.github/workflows/mcstas-winbasictest.yml b/.github/workflows/mcstas-winbasictest.yml new file mode 100644 index 0000000000..75cff36742 --- /dev/null +++ b/.github/workflows/mcstas-winbasictest.yml @@ -0,0 +1,88 @@ +name: mcstas-winbasictest + +on: + push: + pull_request: + +jobs: + build: + # More platform information available on: + # https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md + + runs-on: ${{ matrix.os }} + defaults: + run: + shell: cmd + + strategy: + matrix: +# os: [windows-2019, windows-2022] + os: [windows-2022] + + steps: + + - name: Checkout + uses: actions/checkout@v4 + with: + path: src + + - name: Setup python + uses: actions/setup-python@v5 + with: + python-version: 3.11 + + +# - name: Enable parallel cmake +# run: python ./src/devel/bin/ncdevtool nprocs --enable-github-parallel + + - name: choco install deps + run: choco install winflexbison3 + + - name: CMake cfg + run: > + cmake -B build -S src + "-DCMAKE_INSTALL_PREFIX=./install" + -DMCVERSION="3.99.99" + -DMCCODE_BUILD_CONDA_PKG=OFF + -DCMAKE_INSTALL_LIBDIR=lib + -DBUILD_MCSTAS=ON + -DMCCODE_USE_LEGACY_DESTINATIONS=OFF + -DBUILD_TOOLS=ON + -DENABLE_COMPONENTS=ON + -DENABLE_CIF2HKL=OFF + -DENABLE_NEUTRONICS=OFF + + - name: CMake build + shell: cmd + run: cmake --build build --config Release -j 2 + + - name: CMake install + run: cmake --install build --config Release + + - name: pip install deps + run: pip install PyYAML ply McStasscript ncrystal mslex + + - name: pip install mcpl-core preview + run: pip install -v "git+https://github.com/mctools/mcpl@tk_volatile#subdirectory=mcpl_core" + + - name: set MCSTAS env var + shell: bash + run: echo "MCSTAS=$PWD/install/share/mcstas/resources" >> $GITHUB_ENV + + - name: check MCSTAS env var + run: echo %MCSTAS% + + - run: .\install\bin\mcrun -h + - run: .\install\bin\mcstas -v + - run: mcpl-config -s + - run: ncrystal-config -s + + - name: Prepare rundirs + run: mkdir run_std run_mcpl run_union run_ncrystal + + - name: Prepare std instrument + working-directory: run_std + run: copy "%MCSTAS%\examples\BNL\BNL_H8\BNL_H8.instr" "%CD%\test.instr" + - name: Run + working-directory: run_std + run: mcrun "%CD%\test.instr" "lambda=2.36" From 7aca5bc0b4707e3cf726a5ade5396e5e7ecd1c1c Mon Sep 17 00:00:00 2001 From: Thomas Kittelmann Date: Thu, 20 Mar 2025 14:12:58 +0100 Subject: [PATCH 02/29] Adapt CMake for multicfg generators --- cmake/Modules/InstallMCCODE.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/Modules/InstallMCCODE.cmake b/cmake/Modules/InstallMCCODE.cmake index 3a87544457..04b1cc1df7 100644 --- a/cmake/Modules/InstallMCCODE.cmake +++ b/cmake/Modules/InstallMCCODE.cmake @@ -423,14 +423,14 @@ macro(installMCCODE) # Binaries install ( - PROGRAMS "${PROJECT_BINARY_DIR}/${FLAVOR}${DOT_EXE_SUFFIX}" + TARGETS ${FLAVOR} DESTINATION "${DEST_BINDIR}" ) # Binaries install ( - PROGRAMS "${PROJECT_BINARY_DIR}/${FLAVOR}-pygen${DOT_EXE_SUFFIX}" - DESTINATION ${DEST_BINDIR} + TARGETS ${FLAVOR}-pygen + DESTINATION "${DEST_BINDIR}" ) if ( MCCODE_USE_LEGACY_DESTINATIONS ) install(PROGRAMS From 1569b748f0092cab23257284142624e40cd31804 Mon Sep 17 00:00:00 2001 From: Thomas Kittelmann Date: Thu, 20 Mar 2025 14:26:07 +0100 Subject: [PATCH 03/29] CMake cleanup for executable installs --- cmake/Modules/InstallMCCODE.cmake | 4 ++-- cmake/Modules/MCUtil.cmake | 1 - mcstas-comps/CMakeLists.txt | 2 +- mcxtrace-comps/CMakeLists.txt | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/cmake/Modules/InstallMCCODE.cmake b/cmake/Modules/InstallMCCODE.cmake index 04b1cc1df7..498caf23f8 100644 --- a/cmake/Modules/InstallMCCODE.cmake +++ b/cmake/Modules/InstallMCCODE.cmake @@ -365,12 +365,12 @@ macro(installMCCODE) if(NOT WINDOWS) # Binaries install ( - PROGRAMS "${PROJECT_BINARY_DIR}/${FLAVOR}${DOT_EXE_SUFFIX}" + TARGETS ${FLAVOR} DESTINATION "${DEST_BINDIR}" ) install ( - PROGRAMS "${PROJECT_BINARY_DIR}/${FLAVOR}-pygen${DOT_EXE_SUFFIX}" + TARGETS ${FLAVOR}-pygen DESTINATION "${DEST_BINDIR}" ) diff --git a/cmake/Modules/MCUtil.cmake b/cmake/Modules/MCUtil.cmake index e3cdaa21ca..5e650cd8b9 100644 --- a/cmake/Modules/MCUtil.cmake +++ b/cmake/Modules/MCUtil.cmake @@ -227,7 +227,6 @@ macro(setupMCCODE FLAVOR) endif() # Define suffix-macros that include a leading dot "." - addDot(DOT_EXE_SUFFIX "${MCCODE_EXE_SUFFIX}") addDot(DOT_OUT_SUFFIX "${OUT_SUFFIX}") addDot(DOT_PYTHON_SUFFIX "${PYTHON_SUFFIX}") diff --git a/mcstas-comps/CMakeLists.txt b/mcstas-comps/CMakeLists.txt index b63b6d912b..4738871cce 100644 --- a/mcstas-comps/CMakeLists.txt +++ b/mcstas-comps/CMakeLists.txt @@ -48,7 +48,7 @@ if ( ENABLE_CIF2HKL ) ) target_compile_options(cif2hkl PUBLIC "-ffree-line-length-512") install ( - PROGRAMS "${PROJECT_BINARY_DIR}/cif2hkl${DOT_EXE_SUFFIX}" + TARGETS cif2hkl DESTINATION "${DEST_BINDIR}" ) endif() diff --git a/mcxtrace-comps/CMakeLists.txt b/mcxtrace-comps/CMakeLists.txt index f46127d462..62af2c1c63 100644 --- a/mcxtrace-comps/CMakeLists.txt +++ b/mcxtrace-comps/CMakeLists.txt @@ -38,7 +38,7 @@ if ( ENABLE_CIF2HKL ) ) target_compile_options(cif2hkl PUBLIC "-ffree-line-length-512") install ( - PROGRAMS "${PROJECT_BINARY_DIR}/cif2hkl${DOT_EXE_SUFFIX}" + TARGETS cif2hkl DESTINATION "${DEST_BINDIR}" ) endif() From faeadc2a758adacfeb79f7e688d537f7ebab149a Mon Sep 17 00:00:00 2001 From: Thomas Kittelmann Date: Thu, 20 Mar 2025 13:52:39 +0100 Subject: [PATCH 04/29] Change default values of deprecated ENSURE_MCPL and ENSURE_NCRYSTAL to OFF --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ee3d64bda1..56fbc0d8f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,7 +36,7 @@ endif() include(MCUtil) if ( BUILD_MCSTAS ) - option( ENSURE_NCRYSTAL "Build Third Party code NCrystal if not already available" ON ) + option( ENSURE_NCRYSTAL "Build Third Party code NCrystal if not already available" OFF ) if ( ENSURE_NCRYSTAL ) set ( NCRYSTAL_LEGACY_USE 1 ) else() @@ -74,7 +74,7 @@ endif() # Find/Fetch dependencies: -option( ENSURE_MCPL "Build Third Party code MCPL if not already available" ON ) +option( ENSURE_MCPL "Build Third Party code MCPL if not already available" OFF ) if( ENSURE_MCPL ) include( MCPL ) endif() From 21ffdfed833625d39a375b074951b3ba89c41d5e Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Thu, 20 Mar 2025 14:54:00 +0100 Subject: [PATCH 05/29] Attempt setting MCSTAS env var via cmd syntax --- .github/workflows/mcstas-winbasictest.yml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/mcstas-winbasictest.yml b/.github/workflows/mcstas-winbasictest.yml index 75cff36742..a1c510a1e0 100644 --- a/.github/workflows/mcstas-winbasictest.yml +++ b/.github/workflows/mcstas-winbasictest.yml @@ -51,7 +51,6 @@ jobs: -DENABLE_COMPONENTS=ON -DENABLE_CIF2HKL=OFF -DENABLE_NEUTRONICS=OFF - - name: CMake build shell: cmd run: cmake --build build --config Release -j 2 @@ -63,11 +62,10 @@ jobs: run: pip install PyYAML ply McStasscript ncrystal mslex - name: pip install mcpl-core preview - run: pip install -v "git+https://github.com/mctools/mcpl@tk_volatile#subdirectory=mcpl_core" + run: pip install -v "git+https://github.com/mctools/mcpl@path_to_mcpl2#subdirectory=mcpl_core" - name: set MCSTAS env var - shell: bash - run: echo "MCSTAS=$PWD/install/share/mcstas/resources" >> $GITHUB_ENV + run: echo MCSTAS=%CD%\install\share\mcstas\resources >> %GITHUB_ENV% - name: check MCSTAS env var run: echo %MCSTAS% @@ -82,7 +80,16 @@ jobs: - name: Prepare std instrument working-directory: run_std - run: copy "%MCSTAS%\examples\BNL\BNL_H8\BNL_H8.instr" "%CD%\test.instr" + run: copy ..\install\share\mcstas\resources\examples\BNL\BNL_H8\BNL_H8.instr test.instr + - name: Run working-directory: run_std - run: mcrun "%CD%\test.instr" "lambda=2.36" + run: mcrun test.instr lambda=2.36 + + - name: Prepare NCrystal instrument + working-directory: run_ncrystal + run: copy ..\install\share\mcstas\resources\examples\NCrystal\NCrystal_example\NCrystal_example.instr test.instr + + - name: Run + working-directory: run_ncrystal + run: mcrun test.instr sample_cfg="Y2O3_sg206_Yttrium_Oxide.ncmat;density=0.6x" From cd0ee5fa46bff2bbed6f06a5f6ac879335b6222b Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Mon, 24 Mar 2025 14:14:11 +0100 Subject: [PATCH 06/29] Call mcrun with relative path, cat the config file --- .github/workflows/mcstas-winbasictest.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mcstas-winbasictest.yml b/.github/workflows/mcstas-winbasictest.yml index a1c510a1e0..94a0e8e8f8 100644 --- a/.github/workflows/mcstas-winbasictest.yml +++ b/.github/workflows/mcstas-winbasictest.yml @@ -74,6 +74,7 @@ jobs: - run: .\install\bin\mcstas -v - run: mcpl-config -s - run: ncrystal-config -s + - run: type .\install\share\mcstas\tools\Python\mccodelib\mccode_config.json - name: Prepare rundirs run: mkdir run_std run_mcpl run_union run_ncrystal @@ -84,7 +85,7 @@ jobs: - name: Run working-directory: run_std - run: mcrun test.instr lambda=2.36 + run: call ..\install\bin\mcrun.bat --verbose test.instr lambda=2.36 - name: Prepare NCrystal instrument working-directory: run_ncrystal @@ -92,4 +93,4 @@ jobs: - name: Run working-directory: run_ncrystal - run: mcrun test.instr sample_cfg="Y2O3_sg206_Yttrium_Oxide.ncmat;density=0.6x" + run: ..\install\bin\mcrun --verbose test.instr sample_cfg="Y2O3_sg206_Yttrium_Oxide.ncmat;density=0.6x" From c914f21322b2952e3dc7d374088b56f03f924d3f Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Mon, 24 Mar 2025 14:15:15 +0100 Subject: [PATCH 07/29] Add wget dependency --- .github/workflows/mcstas-winbasictest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mcstas-winbasictest.yml b/.github/workflows/mcstas-winbasictest.yml index 94a0e8e8f8..3c09eeb850 100644 --- a/.github/workflows/mcstas-winbasictest.yml +++ b/.github/workflows/mcstas-winbasictest.yml @@ -36,7 +36,7 @@ jobs: # run: python ./src/devel/bin/ncdevtool nprocs --enable-github-parallel - name: choco install deps - run: choco install winflexbison3 + run: choco install winflexbison3 wget - name: CMake cfg run: > From cfc11ec03b34716101c5e832ba6fdb7264aa0adf Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Fri, 21 Mar 2025 09:33:26 +0100 Subject: [PATCH 08/29] Use ilammy/msvc-dev-cmd@v1 --- .github/workflows/mcstas-winbasictest.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/mcstas-winbasictest.yml b/.github/workflows/mcstas-winbasictest.yml index 3c09eeb850..5224b4c5af 100644 --- a/.github/workflows/mcstas-winbasictest.yml +++ b/.github/workflows/mcstas-winbasictest.yml @@ -31,9 +31,19 @@ jobs: with: python-version: 3.11 - -# - name: Enable parallel cmake -# run: python ./src/devel/bin/ncdevtool nprocs --enable-github-parallel + #Two ways of enabling cl.exe and other tools. One is via an external action...: + - name: Setup VS in shell + uses: ilammy/msvc-dev-cmd@v1 + #...but a simpler one might be to simply invoke the correct vcvars64.bat + #file first, like...: + # + # - name: whatever + # shell: cmd + # run: | + # call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" + # cl /help + # + #...but since we also want to support VS 2019, we use the above action for now - name: choco install deps run: choco install winflexbison3 wget @@ -85,7 +95,7 @@ jobs: - name: Run working-directory: run_std - run: call ..\install\bin\mcrun.bat --verbose test.instr lambda=2.36 + run: ..\install\bin\mcrun.bat --verbose test.instr lambda=2.36 - name: Prepare NCrystal instrument working-directory: run_ncrystal From 67a7cdd6f5b37afc4500d0fe887db6d9c3473ea0 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Fri, 21 Mar 2025 09:51:07 +0100 Subject: [PATCH 09/29] Implement @MCPLFLAGS@ and use CMD(ncrystal-config --show buildflags) on MCPL2 windows --- .github/workflows/mcstas-winbasictest.yml | 44 +++++++++++++++++--- cmake/Modules/PlatformDefaults.cmake | 11 ++++- cmake/toolchains/mingw64.cmake | 1 + mcstas-comps/misc/MCPL_input.comp | 2 +- mcstas-comps/misc/MCPL_input_once.comp | 2 +- mcstas-comps/misc/MCPL_output.comp | 2 +- mcstas-comps/misc/MCPL_output_noacc.comp | 2 +- mcxtrace-comps/misc/MCPL_input.comp | 2 +- mcxtrace-comps/misc/MCPL_output.comp | 2 +- tools/Python/mccodelib/CMakeLists.txt | 2 +- tools/Python/mccodelib/mccode_config.json.in | 1 + 11 files changed, 56 insertions(+), 15 deletions(-) diff --git a/.github/workflows/mcstas-winbasictest.yml b/.github/workflows/mcstas-winbasictest.yml index 5224b4c5af..c41f09c90c 100644 --- a/.github/workflows/mcstas-winbasictest.yml +++ b/.github/workflows/mcstas-winbasictest.yml @@ -87,20 +87,52 @@ jobs: - run: type .\install\share\mcstas\tools\Python\mccodelib\mccode_config.json - name: Prepare rundirs - run: mkdir run_std run_mcpl run_union run_ncrystal + run: mkdir run_std run_mcpl_output run_mcpl_input run_union run_ncrystal - name: Prepare std instrument working-directory: run_std run: copy ..\install\share\mcstas\resources\examples\BNL\BNL_H8\BNL_H8.instr test.instr - - name: Run + - name: Run std instrument working-directory: run_std - run: ..\install\bin\mcrun.bat --verbose test.instr lambda=2.36 + run: ..\install\bin\mcrun --verbose test.instr -d Single_core lambda=2.36 - - name: Prepare NCrystal instrument + - name: Run std instrument MPI + working-directory: run_std + run: ..\install\bin\mcrun --verbose test.instr -d MPI_multicore -c mpi=auto lambda=2.36 + + - name: Prepare NCrystal instrument working-directory: run_ncrystal run: copy ..\install\share\mcstas\resources\examples\NCrystal\NCrystal_example\NCrystal_example.instr test.instr - - name: Run + - name: Run NCrystal instrument working-directory: run_ncrystal - run: ..\install\bin\mcrun --verbose test.instr sample_cfg="Y2O3_sg206_Yttrium_Oxide.ncmat;density=0.6x" + run: ..\install\bin\mcrun --verbose test.instr -d Single_core sample_cfg="Y2O3_sg206_Yttrium_Oxide.ncmat;density=0.6x" + + - name: Run NCrystal instrument MPI + working-directory: run_ncrystal + run: ..\install\bin\mcrun --verbose test.instr -d MPI_multicore -c mpi=auto sample_cfg="Y2O3_sg206_Yttrium_Oxide.ncmat;density=0.6x" + + - name: Prepare MCPL_output instrument + working-directory: run_mcpl_output + run: copy ..\install\share\mcstas\resources\examples\Tests_MCPL_etc\Test_MCPL_output\Test_MCPL_output.instr test.instr + + - name: Run MCPL_output instrument + working-directory: run_mcpl_output + run: ..\install\bin\mcrun --verbose test.instr -d Single_core Ncount=1e3 + + - name: Run MCPL_output instrument MPI + working-directory: run_mcpl_output + run: ..\install\bin\mcrun --verbose test.instr -d MPI_multicore -c mpi=auto Ncount=1e3 + + - name: Prepare MCPL_input instrument + working-directory: run_mcpl_input + run: copy ..\install\share\mcstas\resources\examples\Tests_MCPL_etc\Test_MCPL_input\Test_MCPL_input.instr test.instr + + - name: Run MCPL_input instrument + working-directory: run_mcpl_input + run: ..\install\bin\mcrun --verbose test.instr -d Single_core Ncount=1e3 + + - name: Run MCPL_input instrument MPI + working-directory: run_mcpl_input + run: ..\install\bin\mcrun --verbose test.instr -d MPI_multicore -c mpi=auto Ncount=1e3 diff --git a/cmake/Modules/PlatformDefaults.cmake b/cmake/Modules/PlatformDefaults.cmake index b01a6e4991..abeebead8a 100644 --- a/cmake/Modules/PlatformDefaults.cmake +++ b/cmake/Modules/PlatformDefaults.cmake @@ -78,17 +78,24 @@ function( detect_platform_variables resultvarname ) if ( BUILD_MCSTAS ) set( IDFGEN mcdisplay-mantid ) set( NCRYSTALFLAGS "CMD(ncrystal-config --show buildflags)" ) - + set( MCPLFLAGS "CMD(mcpl-config --show buildflags)" ) # Temporary solution for NCrystal on Windows 'MingW cross-compiled' systems - if ( WINDOWS AND NOT MCCODE_BUILD_CONDA_PKG ) + if ( WINDOWS AND MCCODE_BUILD_WINDOWS_MINGW ) set( NCRYSTALFLAGS "-Wl,-rpath,CMD(ncrystal-config --show libdir) -Wl,CMD(ncrystal-config --show libpath) -ICMD(ncrystal-config --show includedir)" ) + set( MCPLFLAGS "-Wl,-rpath,CMD(mcpl-config --show libdir) -Wl,CMD(mcpl-config --show libpath) -ICMD(mcpl-config --show includedir)" ) endif() else() set( IDFGEN "" ) set( NCRYSTALFLAGS "") + set( MCPLFLAGS "CMD(mcpl-config --show buildflags)" ) + # Temporary solution for NCrystal on Windows 'MingW cross-compiled' systems + if ( WINDOWS AND MCCODE_BUILD_WINDOWS_MINGW ) + set( MCPLFLAGS "-Wl,-rpath,CMD(mcpl-config --show libdir) -Wl,CMD(mcpl-config --show libpath) -ICMD(mcpl-config --show includedir)" ) + endif() endif() provide_var( IDFGEN ) provide_var( NCRYSTALFLAGS ) + provide_var( MCPLFLAGS ) #HDF viewer if ( NOT HDFVIEW ) diff --git a/cmake/toolchains/mingw64.cmake b/cmake/toolchains/mingw64.cmake index 5b3d63a6dd..1e82ea2522 100644 --- a/cmake/toolchains/mingw64.cmake +++ b/cmake/toolchains/mingw64.cmake @@ -51,3 +51,4 @@ set(HDFVIEW "nexpy") # gsl and xraylib locations set(GSLFLAGS "-IGETPATH(../miniconda3/Library/include/) -Wl,-rpath,GETPATH(../miniconda3/Library/lib) -LGETPATH(../miniconda3/Library/lib) -lgsl -lgslcblas") set(XRLFLAGS "-IGETPATH(../miniconda3/Library/include/) -Wl,-rpath,GETPATH(../miniconda3/Library/lib) -LGETPATH(../miniconda3/Library/lib) -lxrl") +set(MCCODE_BUILD_WINDOWS_MINGW "yes") diff --git a/mcstas-comps/misc/MCPL_input.comp b/mcstas-comps/misc/MCPL_input.comp index c73313c659..c70fcacb42 100644 --- a/mcstas-comps/misc/MCPL_input.comp +++ b/mcstas-comps/misc/MCPL_input.comp @@ -44,7 +44,7 @@ DEFINE COMPONENT MCPL_input SETTING PARAMETERS (string filename=0, polarisationuse=1,verbose=1, Emin=0, Emax=FLT_MAX, int repeat_count=1, v_smear=0, pos_smear=0, dir_smear=0, int preload=0) -DEPENDENCY "-Wl,-rpath,CMD(mcpl-config --show libdir) -LCMD(mcpl-config --show libdir) -lmcpl -ICMD(mcpl-config --show includedir)" +DEPENDENCY "@MCPLFLAGS@" SHARE %{ diff --git a/mcstas-comps/misc/MCPL_input_once.comp b/mcstas-comps/misc/MCPL_input_once.comp index 805eb56939..67d7b56877 100644 --- a/mcstas-comps/misc/MCPL_input_once.comp +++ b/mcstas-comps/misc/MCPL_input_once.comp @@ -39,7 +39,7 @@ DEFINE COMPONENT MCPL_input_once SETTING PARAMETERS (string filename=0, polarisationuse=1, Emin=0, Emax=FLT_MAX, v_smear=0, pos_smear=0, dir_smear=0, int always_smear=0, int preload=0, int verbose=0) -DEPENDENCY "-Wl,-rpath,CMD(mcpl-config --show libdir) -LCMD(mcpl-config --show libdir) -lmcpl -ICMD(mcpl-config --show includedir)" +DEPENDENCY "@MCPLFLAGS@" SHARE %{ diff --git a/mcstas-comps/misc/MCPL_output.comp b/mcstas-comps/misc/MCPL_output.comp index 133aac7bc2..528fad2ffc 100644 --- a/mcstas-comps/misc/MCPL_output.comp +++ b/mcstas-comps/misc/MCPL_output.comp @@ -54,7 +54,7 @@ DEFINE COMPONENT MCPL_output SETTING PARAMETERS (int polarisationuse=0, int doubleprec=0, verbose=0, string userflag="", string filename=0, string userflagcomment="", merge_mpi=1, keep_mpi_unmerged=0, buffermax=0) -DEPENDENCY "-Wl,-rpath,CMD(mcpl-config --show libdir) -LCMD(mcpl-config --show libdir) -lmcpl -ICMD(mcpl-config --show includedir)" +DEPENDENCY "@MCPLFLAGS@" SHARE %{ diff --git a/mcstas-comps/misc/MCPL_output_noacc.comp b/mcstas-comps/misc/MCPL_output_noacc.comp index 642c09cfcf..18af84a6c2 100644 --- a/mcstas-comps/misc/MCPL_output_noacc.comp +++ b/mcstas-comps/misc/MCPL_output_noacc.comp @@ -54,7 +54,7 @@ DEFINE COMPONENT MCPL_output_noacc SETTING PARAMETERS (int polarisationuse=0, int doubleprec=0, verbose=0, string userflag="", string filename=0, string userflagcomment="", merge_mpi=1, keep_mpi_unmerged=0, buffermax=0) -DEPENDENCY "-Wl,-rpath,CMD(mcpl-config --show libdir) -LCMD(mcpl-config --show libdir) -lmcpl -ICMD(mcpl-config --show includedir)" +DEPENDENCY "@MCPLFLAGS@" NOACC SHARE diff --git a/mcxtrace-comps/misc/MCPL_input.comp b/mcxtrace-comps/misc/MCPL_input.comp index 5568055c66..6ab63167f7 100644 --- a/mcxtrace-comps/misc/MCPL_input.comp +++ b/mcxtrace-comps/misc/MCPL_input.comp @@ -45,7 +45,7 @@ DEFINE COMPONENT MCPL_input SETTING PARAMETERS (string filename=0, polarisationuse=1,verbose=1, Emin=0, Emax=FLT_MAX, int repeat_count=1, E_smear=0, pos_smear=0, dir_smear=0) -DEPENDENCY "-Wl,-rpath,CMD(mcpl-config --show libdir) -LCMD(mcpl-config --show libdir) -lmcpl -ICMD(mcpl-config --show includedir)" +DEPENDENCY "@MCPLFLAGS@" SHARE %{ diff --git a/mcxtrace-comps/misc/MCPL_output.comp b/mcxtrace-comps/misc/MCPL_output.comp index a8d416c044..f867928ff4 100644 --- a/mcxtrace-comps/misc/MCPL_output.comp +++ b/mcxtrace-comps/misc/MCPL_output.comp @@ -55,7 +55,7 @@ DEFINE COMPONENT MCPL_output SETTING PARAMETERS (int polarisationuse=0, int doubleprec=0, int verbose=0, string userflag="", string filename=0, string userflagcomment="", merge_mpi=1, keep_mpi_unmerged=0, buffermax=0) -DEPENDENCY "-Wl,-rpath,CMD(mcpl-config --show libdir) -LCMD(mcpl-config --show libdir) -lmcpl -ICMD(mcpl-config --show includedir)" +DEPENDENCY "@MCPLFLAGS@" SHARE %{ diff --git a/tools/Python/mccodelib/CMakeLists.txt b/tools/Python/mccodelib/CMakeLists.txt index a6f93e9b61..9eb4912801 100644 --- a/tools/Python/mccodelib/CMakeLists.txt +++ b/tools/Python/mccodelib/CMakeLists.txt @@ -92,7 +92,7 @@ include(CPack) set(WORK "${PROJECT_BINARY_DIR}/work") -set(entries_with_conda_prefix "CFLAGS;NEXUSFLAGS;MPIFLAGS;NCRYSTALFLAGS;GSLFLAGS;XRLFLAGS;OACCFLAGS;TOOLS_CC;MPIRUN;MPICC") +set(entries_with_conda_prefix "CFLAGS;NEXUSFLAGS;MPIFLAGS;MCPLFLAGS;NCRYSTALFLAGS;GSLFLAGS;XRLFLAGS;OACCFLAGS;TOOLS_CC;MPIRUN;MPICC") foreach( var ${entries_with_conda_prefix} ) set( MCCODE_FINAL_${var} "${${var}}" ) endforeach() diff --git a/tools/Python/mccodelib/mccode_config.json.in b/tools/Python/mccodelib/mccode_config.json.in index c18ba66591..e71adfb335 100644 --- a/tools/Python/mccodelib/mccode_config.json.in +++ b/tools/Python/mccodelib/mccode_config.json.in @@ -26,6 +26,7 @@ "MPIFLAGS": "@MCCODE_FINAL_MPIFLAGS@", "GSLFLAGS": "@MCCODE_FINAL_GSLFLAGS@", "NCRYSTALFLAGS": "@MCCODE_FINAL_NCRYSTALFLAGS@", + "MCPLFLAGS": "@MCCODE_FINAL_MCPLFLAGS@", "XRLFLAGS": "@MCCODE_FINAL_XRLFLAGS@", "OACCFLAGS": "@MCCODE_FINAL_OACCFLAGS@", "CC": "@MCCODE_FINAL_TOOLS_CC@", From c187c63ca63294eaea5c67eb6e0d3180277f85cd Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Fri, 21 Mar 2025 17:31:56 +0100 Subject: [PATCH 10/29] Add MCPLFLAGS in parsing DEPENDENCIES --- tools/Python/mcrun/mccode.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/Python/mcrun/mccode.py b/tools/Python/mcrun/mccode.py index 206a716957..0add6daacf 100755 --- a/tools/Python/mcrun/mccode.py +++ b/tools/Python/mcrun/mccode.py @@ -249,6 +249,9 @@ def x_path(file): # Insert NEXUSFLAGS if instrument/comps request this flags = re.sub(r'\@NEXUSFLAGS\@', mccode_config.compilation['NEXUSFLAGS'], flags) + # Insert NCRYSTALFLAGS if instrument/comps request this + flags = re.sub(r'\@MCPLFLAGS\@', mccode_config.compilation['MCPLFLAGS'], flags) + # Insert NCRYSTALFLAGS if instrument/comps request this flags = re.sub(r'\@NCRYSTALFLAGS\@', mccode_config.compilation['NCRYSTALFLAGS'], flags) From 109404a9a728584b33c66472541a3fb624085f0c Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Fri, 21 Mar 2025 10:13:51 +0100 Subject: [PATCH 11/29] Add msmpi --- ...ctest.yml => mcstas-winbasictest-msvc.yml} | 92 +++++++++++++------ cmake/Modules/PlatformDefaults.cmake | 89 +++++++++--------- mcstas-comps/misc/MCPL_input.comp | 5 + mcxtrace-comps/misc/MCPL_input.comp | 5 + tools/Python/mcrun/mccode.py | 4 +- 5 files changed, 118 insertions(+), 77 deletions(-) rename .github/workflows/{mcstas-winbasictest.yml => mcstas-winbasictest-msvc.yml} (71%) diff --git a/.github/workflows/mcstas-winbasictest.yml b/.github/workflows/mcstas-winbasictest-msvc.yml similarity index 71% rename from .github/workflows/mcstas-winbasictest.yml rename to .github/workflows/mcstas-winbasictest-msvc.yml index c41f09c90c..9960e3e031 100644 --- a/.github/workflows/mcstas-winbasictest.yml +++ b/.github/workflows/mcstas-winbasictest-msvc.yml @@ -45,6 +45,30 @@ jobs: # #...but since we also want to support VS 2019, we use the above action for now + - name: Setup MPI + uses: mpi4py/setup-mpi@v1 + with: + mpi: 'msmpi' + + - name: Setup MPI cygpath bash... + shell: bash + run: | + cygpath -sm "$MSMPI_BIN" > binpath.txt + cygpath -sm "$MSMPI_INC" > includepath.txt + cygpath -sm "$MSMPI_LIB64" > libpath.txt + ls `cygpath -sm "$MSMPI_BIN"` + + - name: Setup MPI cygpath... + run: | + set /p MPIBINVAR=> %GITHUB_ENV% + echo MPIINCVAR=%MPIINCVAR% >> %GITHUB_ENV% + echo MPILIBVAR=%MPILIBVAR% >> %GITHUB_ENV% + - name: choco install deps run: choco install winflexbison3 wget @@ -61,6 +85,9 @@ jobs: -DENABLE_COMPONENTS=ON -DENABLE_CIF2HKL=OFF -DENABLE_NEUTRONICS=OFF + -DMPIINCLUDEDIR=%MPIINCVAR% + -DMPILIBDIR=%MPILIBVAR% + - name: CMake build shell: cmd run: cmake --build build --config Release -j 2 @@ -80,11 +107,18 @@ jobs: - name: check MCSTAS env var run: echo %MCSTAS% + - run: type .\install\share\mcstas\tools\Python\mccodelib\mccode_config.json - run: .\install\bin\mcrun -h - run: .\install\bin\mcstas -v - run: mcpl-config -s + - run: mcpl-config --show includedir > mcplinclude.txt + + - name: Look in mcplincludedir + run: | + set /p MCPLINCLUDE= +#ifdef _MSC_EXTENSIONS +#include +#define sleep Sleep +#endif + %} DECLARE diff --git a/mcxtrace-comps/misc/MCPL_input.comp b/mcxtrace-comps/misc/MCPL_input.comp index 6ab63167f7..7ea07ec09a 100644 --- a/mcxtrace-comps/misc/MCPL_input.comp +++ b/mcxtrace-comps/misc/MCPL_input.comp @@ -50,6 +50,11 @@ DEPENDENCY "@MCPLFLAGS@" SHARE %{ #include +#ifdef _MSC_EXTENSIONS +#include +#define sleep Sleep +#endif + %} DECLARE diff --git a/tools/Python/mcrun/mccode.py b/tools/Python/mcrun/mccode.py index 0add6daacf..7147d28055 100755 --- a/tools/Python/mcrun/mccode.py +++ b/tools/Python/mcrun/mccode.py @@ -277,8 +277,8 @@ def x_path(file): if any("NeXus" in cf for cf in cflags): cflags += '-D__GNUC__'+ " " - # cl.exe under conda needs the linking flags at the end... - if os.environ.get('CONDA_PREFIX') and "cl.exe" in mccode_config.compilation['CC'].lower(): + # cl.exe on Windows needs the linking flags at the end... + if os.name == 'nt' and "cl.exe" in mccode_config.compilation['CC'].lower(): libflags = [] otherflags = [] for flag in lexer.split(cflags): From 55ad1eeb1e441241495cc5c428ccab71dd074546 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Sat, 22 Mar 2025 09:43:34 +0100 Subject: [PATCH 12/29] Tar up run_ folders and provide for download --- .github/workflows/mcstas-winbasictest-msvc.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/mcstas-winbasictest-msvc.yml b/.github/workflows/mcstas-winbasictest-msvc.yml index 9960e3e031..4e02ade2a8 100644 --- a/.github/workflows/mcstas-winbasictest-msvc.yml +++ b/.github/workflows/mcstas-winbasictest-msvc.yml @@ -172,3 +172,21 @@ jobs: - name: Run NCrystal instrument MPI working-directory: run_ncrystal run: ..\install\bin\mcrun --verbose test.instr -d MPI_multicore -c --mpi=auto sample_cfg="Y2O3_sg206_Yttrium_Oxide.ncmat;density=0.6x" + + - name: 'Tar output files' + id: tar-package + if: always() + shell: bash + run: | + set -e + set -u + set -x + tar cvfz output.tgz run_* + + - name: 'Upload Artifact' + id: tar-upload + uses: actions/upload-artifact@v4 + if: always() + with: + name: output.tgz + path: "output.tgz" From d5cca8277b33b5ddf72e378dacff774f5046f744 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Sat, 22 Mar 2025 10:37:29 +0100 Subject: [PATCH 13/29] REVISIT Remove extra USE_MPI bracing of MPI_MASTER that handles this internally --- mcstas-comps/misc/MCPL_input.comp | 57 ++++----- mcstas-comps/misc/MCPL_input_once.comp | 10 +- mcstas-comps/misc/MCPL_output.comp | 141 +++++++++++------------ mcstas-comps/misc/MCPL_output_noacc.comp | 97 +++++++++++----- 4 files changed, 163 insertions(+), 142 deletions(-) diff --git a/mcstas-comps/misc/MCPL_input.comp b/mcstas-comps/misc/MCPL_input.comp index 2dbd969c68..d98951a146 100644 --- a/mcstas-comps/misc/MCPL_input.comp +++ b/mcstas-comps/misc/MCPL_input.comp @@ -121,32 +121,32 @@ INITIALIZE repeat_cnt = ceil(1.0*repeat_cnt/mpi_node_count); mpi_cnt=mpi_node_count; ismpislave = mpi_node_rank; - MPI_MASTER( #endif - fprintf(stdout, "\n\n Warning: You are using MCPL_input with a repeat_count of %lu:\n - Minimum neutron count requested is %lu x %lu <= %lu", - (long unsigned)repeat_count,(long unsigned)nparticles, - (long unsigned)repeat_count,(long unsigned)repeat_cnt*nparticles); + MPI_MASTER( + fprintf(stdout, "\n\n Warning: You are using MCPL_input with a repeat_count of %lu:\n - Minimum neutron count requested is %lu x %lu <= %lu", + (long unsigned)repeat_count,(long unsigned)nparticles, + (long unsigned)repeat_count,(long unsigned)repeat_cnt*nparticles); + ); + + char tmpstr[CHAR_BUF_LENGTH]; #if defined (USE_MPI) - fprintf(stdout, " x %i MPI nodes = %lu neutrons total\n", - mpi_node_count,(long unsigned)mpi_node_count*repeat_cnt*nparticles); - ); + sprintf(tmpstr, " x %i MPI nodes = %lu neutrons total\n", + mpi_node_count,(long unsigned)mpi_node_count*repeat_cnt*nparticles); #else - fprintf(stdout, " neutrons total\n\n"); + sprintf(tmpstr, " neutrons total\n\n"); #endif - read_neutrons=0; - used_neutrons=0; -#if defined (USE_MPI) MPI_MASTER( -#endif + printf(stdout, "%s",tmpstr); + ); + read_neutrons=0; + used_neutrons=0; + MPI_MASTER( if (verbose==1) { - printf("MCPL_input verbose mode - outputting data on the 10 first read neutrons in MCPL units:\n"); + printf("MCPL_input verbose mode - outputting data on the 10 first read neutrons in MCPL units:\n"); } - -#if defined (USE_MPI) ); -#endif repeating = 0; #ifdef OPENACC preload=1; @@ -248,13 +248,10 @@ TRACE repeating++; mcpl_rewind(inputfile); particle = mcpl_read(inputfile); -#if defined (USE_MPI) + MPI_MASTER( -#endif - printf("MCPL inputfile %s rewound %i time(s)\n",filename,repeating); -#if defined (USE_MPI) - ); -#endif + printf("MCPL inputfile %s rewound %i time(s)\n",filename,repeating); + ); } else ABSORB; } @@ -271,20 +268,14 @@ TRACE } used_neutrons++; -#if defined (USE_MPI) - MPI_MASTER( -#endif - - if (verbose && used_neutrons<11) { - printf("id=%ld pdg=2112\tekin=%g MeV\tx=%g cm\ty=%g cm\tz=%g cm\tux=%g\tuy=%g\tuz=%g\tt=%g ms\tweight=%g\tpolx=%g\tpoly=%g\tpolz=%g\n", + MPI_MASTER( + if (verbose && used_neutrons<11) { + printf("id=%ld pdg=2112\tekin=%g MeV\tx=%g cm\ty=%g cm\tz=%g cm\tux=%g\tuy=%g\tuz=%g\tt=%g ms\tweight=%g\tpolx=%g\tpoly=%g\tpolz=%g\n", (long unsigned)read_neutrons, particle->ekin, particle->position[0], particle->position[1], particle->position[2], particle->direction[0], particle->direction[1], particle->direction[2], particle->time, particle->weight, particle->polarisation[0], particle->polarisation[1], particle->polarisation[2]); - } - -#if defined (USE_MPI) - ); -#endif + } + ); } #endif ncount = mcget_ncount(); diff --git a/mcstas-comps/misc/MCPL_input_once.comp b/mcstas-comps/misc/MCPL_input_once.comp index 67d7b56877..218ec27b37 100644 --- a/mcstas-comps/misc/MCPL_input_once.comp +++ b/mcstas-comps/misc/MCPL_input_once.comp @@ -104,14 +104,10 @@ INITIALIZE fprintf(stderr, "Error(%s): MCPL-file reports no present particles. Aborting.\n", NAME_CURRENT_COMP); exit(-1); } else { -#if defined (USE_MPI) MPI_MASTER( -#endif - printf("Message(%s): MCPL file (%s) produced with %s.\n", NAME_CURRENT_COMP, filename, mcpl_hdr_srcname(inputfile)); - printf("Message(%s): MCPL file (%s) contains %lu particles.\n", NAME_CURRENT_COMP, filename, (long unsigned)nparticles); -#if defined (USE_MPI) + printf("Message(%s): MCPL file (%s) produced with %s.\n", NAME_CURRENT_COMP, filename, mcpl_hdr_srcname(inputfile)); + printf("Message(%s): MCPL file (%s) contains %lu particles.\n", NAME_CURRENT_COMP, filename, (long unsigned)nparticles); ); -#endif } first_particle = 0; last_particle = nparticles; @@ -213,7 +209,7 @@ TRACE #ifdef OPENACC #pragma acc atomic current_index++; // track how many particles have been accessed, to ensure we don't exceed our slice of the file -#else OPENACC +#else } #endif // copy from the component particle struct to the particle ray struct: diff --git a/mcstas-comps/misc/MCPL_output.comp b/mcstas-comps/misc/MCPL_output.comp index 528fad2ffc..025146e8fa 100644 --- a/mcstas-comps/misc/MCPL_output.comp +++ b/mcstas-comps/misc/MCPL_output.comp @@ -93,17 +93,24 @@ INITIALIZE %{ char extension[128]=""; char *myfilename; - + char tmpstr[CHAR_BUF_LENGTH]; + // Use instance name for base output if no input was given if (!strcmp(filename,"\0")) sprintf(filename, "%s", NAME_CURRENT_COMP); #if defined (USE_MPI) - /* In case of MPI, simply redefine the filename used by each node */ - MPI_MASTER(fprintf(stdout, "Message(%s): You are using MCPL_output with MPI, hence your will get %i filenames %s.node_#i.mcpl{.gz} as output.\n",NAME_CURRENT_COMP,mpi_node_count,filename); ); + /* In case of MPI, simply redefine the filename used by each node */ + sprintf(tmpstr, "Message(%s): You are using MCPL_output with MPI, hence your will get %i filenames %s.node_#i.mcpl{.gz} as output.\n",NAME_CURRENT_COMP,mpi_node_count,filename); sprintf(extension,"node_%i.mcpl",mpi_node_rank); #else sprintf(extension,"mcpl"); #endif +sprintf(tmpstr, ""); + MPI_MASTER( + fprintf(stdout, "%s",tmpstr ); + ); + + /*add output dir (if applicable) to the output filename and add extension if */ // Append the extension to the filename // -- do not use mcfull_file for this since it can not handle absolute filenames with a '.' in them @@ -170,17 +177,11 @@ INITIALIZE mcpl_enable_doubleprec(outputfile); } -#if defined (USE_MPI) - MPI_MASTER( -#endif - - if (verbose==1) { - printf("MCPL_output verbose mode: after generating the mcpl-file a summary will be printed.\n"); - } - -#if defined (USE_MPI) - ); -#endif + MPI_MASTER( + if (verbose==1) { + printf("MCPL_output verbose mode: after generating the mcpl-file a summary will be printed.\n"); + } + ); /*Add comments on what the orientation and position of this component is.*/ /*Include the instrument file itself as a binary blob in the mcpl file*/ @@ -288,18 +289,14 @@ TRACE particle->userflags = (uint32_t) uvar; } -#if defined (USE_MPI) - MPI_MASTER( -#endif - if (verbose==3 && mcrun_num<10) { - printf("id=%ld\tpdg=2112\tekin=%g MeV\tx=%g cm\ty=%g cm\tz=%g cm\tux=%g\tuy=%g\tuz=%g\tt=%g ms\tweight=%g\tpolx=%g\tpoly=%g\tpolz=%g\n", - mcrun_num, particle->ekin, particle->position[0], particle->position[1], particle->position[2], - particle->direction[0], particle->direction[1], particle->direction[2], particle->time, particle->weight, - particle->polarisation[0], particle->polarisation[1], particle->polarisation[2]); - } -#if defined (USE_MPI) - ); -#endif + MPI_MASTER( + if (verbose==3 && mcrun_num<10) { + printf("id=%ld\tpdg=2112\tekin=%g MeV\tx=%g cm\ty=%g cm\tz=%g cm\tux=%g\tuy=%g\tuz=%g\tt=%g ms\tweight=%g\tpolx=%g\tpoly=%g\tpolz=%g\n", + mcrun_num, particle->ekin, particle->position[0], particle->position[1], particle->position[2], + particle->direction[0], particle->direction[1], particle->direction[2], particle->time, particle->weight, + particle->polarisation[0], particle->polarisation[1], particle->polarisation[2]); + } + ); mcpl_add_particle(outputfile,particle); @@ -369,56 +366,54 @@ FINALLY mcpl_closeandgzip_outfile(outputfile); #endif #ifdef USE_MPI - MPI_Barrier(MPI_COMM_WORLD); - MPI_MASTER( - /* Only attempt merge if requested and meaningful */ - if (merge_mpi && mpi_node_count > 1) { - char **mpi_node_files; - char *merge_outfilename; - char extension[128]="mcpl"; - int j; - mcpl_outfile_t merge_outfile; - - char * real_filename = (char *) calloc(strlen(filename) + strlen(extension) + 2, sizeof(char)); - strcpy(real_filename, filename); - strcat(real_filename, "."); - strcat(real_filename, extension); - - merge_outfilename = mcfull_file(real_filename, NULL); - - mpi_node_files=(char **) calloc(mpi_node_count,sizeof(char *)); - sprintf(extension,"node_%i.mcpl", mpi_node_count); - char * temp_name = (char *) calloc(strlen(filename) + strlen(extension) + 2, sizeof(char)); - for (j=0;j 1) { + char **mpi_node_files; + char *merge_outfilename; + char extension[128]="mcpl"; + int j; + mcpl_outfile_t merge_outfile; + + char * real_filename = (char *) calloc(strlen(filename) + strlen(extension) + 2, sizeof(char)); + strcpy(real_filename, filename); + strcat(real_filename, "."); + strcat(real_filename, extension); + + merge_outfilename = mcfull_file(real_filename, NULL); + + mpi_node_files=(char **) calloc(mpi_node_count,sizeof(char *)); + sprintf(extension,"node_%i.mcpl", mpi_node_count); + char * temp_name = (char *) calloc(strlen(filename) + strlen(extension) + 2, sizeof(char)); + for (j=0;jposition[0]=x*100; particle->position[1]=y*100; particle->position[2]=z*100; - + if(polarisationuse){ particle->polarisation[0]=sx; particle->polarisation[1]=sy; particle->polarisation[2]=sz; } - + nrm =sqrt(vx*vx + vy*vy + vz*vz); /*ekin is in MeV*/ particle->ekin = VS2E*nrm*nrm/1e9; @@ -213,28 +229,29 @@ TRACE uvar = particle_getvar(_particle,userflag,&fail); if(fail) uvar=0; particle->userflags = (uint32_t) uvar; } - -#if defined (USE_MPI) + MPI_MASTER( -#endif if (verbose==3 && mcrun_num<10) { printf("id=%ld\tpdg=2112\tekin=%g MeV\tx=%g cm\ty=%g cm\tz=%g cm\tux=%g\tuy=%g\tuz=%g\tt=%g ms\tweight=%g\tpolx=%g\tpoly=%g\tpolz=%g\n", mcrun_num, particle->ekin, particle->position[0], particle->position[1], particle->position[2], particle->direction[0], particle->direction[1], particle->direction[2], particle->time, particle->weight, particle->polarisation[0], particle->polarisation[1], particle->polarisation[2]); } -#if defined (USE_MPI) ); -#endif mcpl_add_particle(outputfile,particle); - + SCATTER; %} SAVE %{ + +%} + +FINALLY +%{ #ifdef USE_MPI if (merge_mpi && mpi_node_count > 1) { mcpl_close_outfile(outputfile); @@ -244,28 +261,32 @@ SAVE #else mcpl_closeandgzip_outfile(outputfile); #endif -%} - -FINALLY -%{ #ifdef USE_MPI MPI_Barrier(MPI_COMM_WORLD); - MPI_MASTER( /* Only attempt merge if requested and meaningful */ - if (merge_mpi && mpi_node_count > 1) { + if (mpi_node_rank==0 && merge_mpi && mpi_node_count > 1) { char **mpi_node_files; char *merge_outfilename; char extension[128]="mcpl"; int j; mcpl_outfile_t merge_outfile; - merge_outfilename=mcfull_file(filename,extension); + char * real_filename = (char *) calloc(strlen(filename) + strlen(extension) + 2, sizeof(char)); + strcpy(real_filename, filename); + strcat(real_filename, "."); + strcat(real_filename, extension); + + merge_outfilename = mcfull_file(real_filename, NULL); mpi_node_files=(char **) calloc(mpi_node_count,sizeof(char *)); + sprintf(extension,"node_%i.mcpl", mpi_node_count); + char * temp_name = (char *) calloc(strlen(filename) + strlen(extension) + 2, sizeof(char)); for (j=0;j Date: Sat, 22 Mar 2025 11:01:32 +0100 Subject: [PATCH 14/29] Re-enable MCPL_output and MPI --- .../workflows/mcstas-winbasictest-msvc.yml | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/.github/workflows/mcstas-winbasictest-msvc.yml b/.github/workflows/mcstas-winbasictest-msvc.yml index 4e02ade2a8..1ee5dd32ea 100644 --- a/.github/workflows/mcstas-winbasictest-msvc.yml +++ b/.github/workflows/mcstas-winbasictest-msvc.yml @@ -53,19 +53,13 @@ jobs: - name: Setup MPI cygpath bash... shell: bash run: | - cygpath -sm "$MSMPI_BIN" > binpath.txt cygpath -sm "$MSMPI_INC" > includepath.txt cygpath -sm "$MSMPI_LIB64" > libpath.txt - ls `cygpath -sm "$MSMPI_BIN"` - name: Setup MPI cygpath... run: | - set /p MPIBINVAR=> %GITHUB_ENV% echo MPIINCVAR=%MPIINCVAR% >> %GITHUB_ENV% echo MPILIBVAR=%MPILIBVAR% >> %GITHUB_ENV% @@ -111,17 +105,10 @@ jobs: - run: .\install\bin\mcrun -h - run: .\install\bin\mcstas -v - run: mcpl-config -s - - run: mcpl-config --show includedir > mcplinclude.txt - - - name: Look in mcplincludedir - run: | - set /p MCPLINCLUDE= Date: Sat, 22 Mar 2025 12:00:11 +0100 Subject: [PATCH 15/29] Put MCPL instrs in own test category --- .../Test_MCPL_input/Test_MCPL_input.instr | 0 .../Test_MCPL_output/Test_MCPL_output.instr | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename mcxtrace-comps/examples/{Tests => Tests_MCPL_etc}/Test_MCPL_input/Test_MCPL_input.instr (100%) rename mcxtrace-comps/examples/{Tests => Tests_MCPL_etc}/Test_MCPL_output/Test_MCPL_output.instr (100%) diff --git a/mcxtrace-comps/examples/Tests/Test_MCPL_input/Test_MCPL_input.instr b/mcxtrace-comps/examples/Tests_MCPL_etc/Test_MCPL_input/Test_MCPL_input.instr similarity index 100% rename from mcxtrace-comps/examples/Tests/Test_MCPL_input/Test_MCPL_input.instr rename to mcxtrace-comps/examples/Tests_MCPL_etc/Test_MCPL_input/Test_MCPL_input.instr diff --git a/mcxtrace-comps/examples/Tests/Test_MCPL_output/Test_MCPL_output.instr b/mcxtrace-comps/examples/Tests_MCPL_etc/Test_MCPL_output/Test_MCPL_output.instr similarity index 100% rename from mcxtrace-comps/examples/Tests/Test_MCPL_output/Test_MCPL_output.instr rename to mcxtrace-comps/examples/Tests_MCPL_etc/Test_MCPL_output/Test_MCPL_output.instr From 379e81cfafc79b547414e983ed127478a9f63289 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Sat, 22 Mar 2025 12:00:33 +0100 Subject: [PATCH 16/29] Add McXtrace test, but don't run MPI for MCPL yet --- .../workflows/mcstas-winbasictest-msvc.yml | 3 +- .../workflows/mcxtrace-winbasictest-msvc.yml | 165 ++++++++++++++++++ 2 files changed, 166 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/mcxtrace-winbasictest-msvc.yml diff --git a/.github/workflows/mcstas-winbasictest-msvc.yml b/.github/workflows/mcstas-winbasictest-msvc.yml index 1ee5dd32ea..4b3a0bc254 100644 --- a/.github/workflows/mcstas-winbasictest-msvc.yml +++ b/.github/workflows/mcstas-winbasictest-msvc.yml @@ -16,8 +16,7 @@ jobs: strategy: matrix: -# os: [windows-2019, windows-2022] - os: [windows-2022] + os: [windows-2019, windows-2022] steps: diff --git a/.github/workflows/mcxtrace-winbasictest-msvc.yml b/.github/workflows/mcxtrace-winbasictest-msvc.yml new file mode 100644 index 0000000000..5a42ec1d83 --- /dev/null +++ b/.github/workflows/mcxtrace-winbasictest-msvc.yml @@ -0,0 +1,165 @@ +name: mcxtrace-winbasictest + +on: + push: + pull_request: + +jobs: + build: + # More platform information available on: + # https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md + + runs-on: ${{ matrix.os }} + defaults: + run: + shell: cmd + + strategy: + matrix: +# os: [windows-2019, windows-2022] + os: [windows-2022] + + steps: + + - name: Checkout + uses: actions/checkout@v4 + with: + path: src + + - name: Setup python + uses: actions/setup-python@v5 + with: + python-version: 3.11 + + #Two ways of enabling cl.exe and other tools. One is via an external action...: + - name: Setup VS in shell + uses: ilammy/msvc-dev-cmd@v1 + #...but a simpler one might be to simply invoke the correct vcvars64.bat + #file first, like...: + # + # - name: whatever + # shell: cmd + # run: | + # call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" + # cl /help + # + #...but since we also want to support VS 2019, we use the above action for now + + - name: Setup MPI + uses: mpi4py/setup-mpi@v1 + with: + mpi: 'msmpi' + + - name: Setup MPI cygpath bash... + shell: bash + run: | + cygpath -sm "$MSMPI_INC" > includepath.txt + cygpath -sm "$MSMPI_LIB64" > libpath.txt + + - name: Setup MPI cygpath... + run: | + set /p MPIINCVAR=> %GITHUB_ENV% + echo MPILIBVAR=%MPILIBVAR% >> %GITHUB_ENV% + + - name: choco install deps + run: choco install winflexbison3 wget + + - name: CMake cfg + run: > + cmake -B build -S src + "-DCMAKE_INSTALL_PREFIX=./install" + -DMCVERSION="3.99.99" + -DMCCODE_BUILD_CONDA_PKG=OFF + -DCMAKE_INSTALL_LIBDIR=lib + -DBUILD_MCXTRACE=ON + -DMCCODE_USE_LEGACY_DESTINATIONS=OFF + -DBUILD_TOOLS=ON + -DENABLE_COMPONENTS=ON + -DENABLE_CIF2HKL=OFF + -DENABLE_NEUTRONICS=OFF + -DMPIINCLUDEDIR=%MPIINCVAR% + -DMPILIBDIR=%MPILIBVAR% + + - name: CMake build + shell: cmd + run: cmake --build build --config Release -j 2 + + - name: CMake install + run: cmake --install build --config Release + + - name: pip install deps + run: pip install PyYAML ply McStasscript mslex + + - name: pip install mcpl-core preview + run: pip install -v "git+https://github.com/mctools/mcpl@path_to_mcpl2#subdirectory=mcpl_core" + + - name: set MCXTRACE env var + run: echo MCXTRACE=%CD%\install\share\mcxtrace\resources >> %GITHUB_ENV% + + - name: check MCXTRACE env var + run: echo %MCXTRACE% + + - run: type .\install\share\mcxtrace\tools\Python\mccodelib\mccode_config.json + - run: .\install\bin\mxrun -h + - run: .\install\bin\mcxtrace -v + - run: mcpl-config -s + + - name: Prepare rundirs + run: mkdir run_std run_mcpl_output run_mcpl_input run_union + + - name: Prepare std instrument + working-directory: run_std + run: copy ..\install\share\mcxtrace\resources\examples\Tests_optics\Test_CRL.instr test.instr + + - name: Prepare MCPL_input instrument + working-directory: run_mcpl_input + run: | + copy ..\install\share\mcxtrace\resources\examples\Tests_MCPL_etc\Test_MCPL_input\Test_MCPL_input.instr test.instr + + - name: Prepare MCPL_output instrument + working-directory: run_mcpl_output + run: copy ..\install\share\mcxtrace\resources\examples\Tests_MCPL_etc\Test_MCPL_output\Test_MCPL_output.instr test.instr + + - name: Run std instrument + working-directory: run_std + run: ..\install\bin\mxrun --verbose test.instr -d Single_core LENS=0 + + - name: Run MCPL_output instrument + working-directory: run_mcpl_output + run: ..\install\bin\mxrun --verbose test.instr -d Single_core Ncount=1e3 + + - name: Run MCPL_input instrument + working-directory: run_mcpl_input + run: ..\install\bin\mxrun --verbose test.instr -d Single_core repeat=1 + + - name: Run std instrument MPI + working-directory: run_std + run: ..\install\bin\mxrun --verbose test.instr -d MPI_multicore -c --mpi=auto LENS=0 + + # - name: Run MCPL_output instrument MPI + # working-directory: run_mcpl_output + # run: ..\install\bin\mxrun --verbose test.instr -d MPI_multicore -c --mpi=auto Ncount=1e3 + + # - name: Run MCPL_input instrument MPI + # working-directory: run_mcpl_input + # run: ..\install\bin\mxrun --verbose test.instr -d MPI_multicore -c --mpi=auto repeat=1 + + - name: 'Tar output files' + id: tar-package + if: always() + shell: bash + run: | + set -e + set -u + set -x + tar cvfz output.tgz run_* + + - name: 'Upload Artifact' + id: tar-upload + uses: actions/upload-artifact@v4 + if: always() + with: + name: output.tgz + path: "output.tgz" From ea8e1be03de8ba66390e26dfb1a1ed30686a4614 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Sat, 22 Mar 2025 16:33:44 +0100 Subject: [PATCH 17/29] Use ${{ matrix.os }} for output --- .github/workflows/mcstas-winbasictest-msvc.yml | 4 ++-- .github/workflows/mcxtrace-winbasictest-msvc.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/mcstas-winbasictest-msvc.yml b/.github/workflows/mcstas-winbasictest-msvc.yml index 4b3a0bc254..49485f57fd 100644 --- a/.github/workflows/mcstas-winbasictest-msvc.yml +++ b/.github/workflows/mcstas-winbasictest-msvc.yml @@ -181,7 +181,7 @@ jobs: set -e set -u set -x - tar cvfz output.tgz run_* + tar cvfz mcstas-${{ matrix.os }}_output.tgz run_* - name: 'Upload Artifact' id: tar-upload @@ -189,4 +189,4 @@ jobs: if: always() with: name: output.tgz - path: "output.tgz" + path: "mcstas-${{ matrix.os }}_output.tgz" diff --git a/.github/workflows/mcxtrace-winbasictest-msvc.yml b/.github/workflows/mcxtrace-winbasictest-msvc.yml index 5a42ec1d83..c0016d07ae 100644 --- a/.github/workflows/mcxtrace-winbasictest-msvc.yml +++ b/.github/workflows/mcxtrace-winbasictest-msvc.yml @@ -154,7 +154,7 @@ jobs: set -e set -u set -x - tar cvfz output.tgz run_* + tar cvfz mcxtrace-${{ matrix.os }}_output.tgz run_* - name: 'Upload Artifact' id: tar-upload @@ -162,4 +162,4 @@ jobs: if: always() with: name: output.tgz - path: "output.tgz" + path: "mcxtrace-${{ matrix.os }}_output.tgz" From 12369849e6421e8b4d7d0ba7bbdaba96a15e952d Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Sat, 22 Mar 2025 16:37:48 +0100 Subject: [PATCH 18/29] Path correction and test look at %MCXTRACE% --- .github/workflows/mcstas-winbasictest-msvc.yml | 2 +- .github/workflows/mcxtrace-winbasictest-msvc.yml | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/mcstas-winbasictest-msvc.yml b/.github/workflows/mcstas-winbasictest-msvc.yml index 49485f57fd..35bcdec188 100644 --- a/.github/workflows/mcstas-winbasictest-msvc.yml +++ b/.github/workflows/mcstas-winbasictest-msvc.yml @@ -188,5 +188,5 @@ jobs: uses: actions/upload-artifact@v4 if: always() with: - name: output.tgz + name: mcstas-${{ matrix.os }}_output.tgz path: "mcstas-${{ matrix.os }}_output.tgz" diff --git a/.github/workflows/mcxtrace-winbasictest-msvc.yml b/.github/workflows/mcxtrace-winbasictest-msvc.yml index c0016d07ae..fc68a9fc96 100644 --- a/.github/workflows/mcxtrace-winbasictest-msvc.yml +++ b/.github/workflows/mcxtrace-winbasictest-msvc.yml @@ -99,7 +99,9 @@ jobs: run: echo MCXTRACE=%CD%\install\share\mcxtrace\resources >> %GITHUB_ENV% - name: check MCXTRACE env var - run: echo %MCXTRACE% + run: | + echo %MCXTRACE% + dir %MCXTRACE% - run: type .\install\share\mcxtrace\tools\Python\mccodelib\mccode_config.json - run: .\install\bin\mxrun -h @@ -111,7 +113,7 @@ jobs: - name: Prepare std instrument working-directory: run_std - run: copy ..\install\share\mcxtrace\resources\examples\Tests_optics\Test_CRL.instr test.instr + run: copy ..\install\share\mcxtrace\resources\examples\Tests_optics\Test_CRL\Test_CRL.instr test.instr - name: Prepare MCPL_input instrument working-directory: run_mcpl_input @@ -161,5 +163,5 @@ jobs: uses: actions/upload-artifact@v4 if: always() with: - name: output.tgz + name: mcxtrace-${{ matrix.os }}_output.tgz path: "mcxtrace-${{ matrix.os }}_output.tgz" From 6683cd957405467d48e38b27a22d0e314c2e946e Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Sat, 22 Mar 2025 18:05:01 +0100 Subject: [PATCH 19/29] MPI_MASTER without USE_MPI for MCPL_input McXtrace --- mcxtrace-comps/misc/MCPL_input.comp | 47 +++++++++++------------------ 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/mcxtrace-comps/misc/MCPL_input.comp b/mcxtrace-comps/misc/MCPL_input.comp index 7ea07ec09a..46d88fae09 100644 --- a/mcxtrace-comps/misc/MCPL_input.comp +++ b/mcxtrace-comps/misc/MCPL_input.comp @@ -64,9 +64,10 @@ long long nparticles; long long read_photons; long long used_photons; int repeat_cnt; +int repeat_tot; int repeating; int ismpislave; -#ifdef OPENACC +int mpi_cnt; DArray1d X; DArray1d Y; DArray1d Z; @@ -78,7 +79,6 @@ DArray1d EY; DArray1d EZ; DArray1d T; DArray1d P; -#endif %} INITIALIZE @@ -115,41 +115,38 @@ INITIALIZE if(repeat_count==0) repeat_count=1; repeat_cnt = repeat_count; + mpi_cnt=1; ismpislave=0; #if defined (USE_MPI) repeat_cnt = ceil(1.0*repeat_cnt/mpi_node_count); + mpi_cnt=mpi_node_count; ismpislave = mpi_node_rank; - MPI_MASTER( #endif - fprintf(stdout, "\n\n Warning: You are using MCPL_input with a repeat_count of %lu:\n - Minimum photon count requested is %lu x %lu <= %lu", + MPI_MASTER( + fprintf(stdout, "\n\n Warning: You are using MCPL_input with a repeat_count of %lu:\n - Minimum photon count requested is %lu x %lu <= %lu", (long unsigned)repeat_count,(long unsigned)nparticles, (long unsigned)repeat_count,(long unsigned)repeat_cnt*nparticles); + ); + + char tmpstr[CHAR_BUF_LENGTH]; #if defined (USE_MPI) - fprintf(stdout, " x %i MPI nodes = %lu photons total\n", + sprintf(tmpstr, " x %i MPI nodes = %lu photons total\n", mpi_node_count,(long unsigned)mpi_node_count*repeat_cnt*nparticles); - ); - mcset_ncount(mpi_node_count*repeat_cnt*nparticles); #else - fprintf(stdout, " photons total\n\n"); - mcset_ncount(repeat_cnt*nparticles); + sprintf(tmpstr, " photons total\n\n"); #endif - ncount=mcget_ncount(); - fprintf(stdout,"Initialize ncount is %lu\n",(long unsigned)ncount); + MPI_MASTER( + printf(stdout, "%s",tmpstr); + ); read_photons=0; used_photons=0; -#if defined (USE_MPI) MPI_MASTER( -#endif - if (verbose==1) { printf("MCPL_input verbose mode - outputting data on the 10 first read photons in MCPL units:\n"); } - -#if defined (USE_MPI) ); -#endif repeating = 0; #ifdef OPENACC X = create_darr1d(nparticles); @@ -229,10 +226,10 @@ INITIALIZE TRACE %{ -#ifndef OPENACC - long long ncount; double nrm; + long long ncount; +#ifndef OPENACC const mcpl_particle_t *particle;// = (mcpl_particle_t *) calloc(sizeof(mcpl_particle_t),1); particle = mcpl_read(inputfile); @@ -244,13 +241,10 @@ TRACE repeating++; mcpl_rewind(inputfile); particle = mcpl_read(inputfile); -#if defined (USE_MPI) + MPI_MASTER( -#endif printf("MCPL inputfile %s rewound %i time(s)\n",filename,repeating); -#if defined (USE_MPI) ); -#endif } else ABSORB; } @@ -267,9 +261,7 @@ TRACE } used_photons++; -#if defined (USE_MPI) MPI_MASTER( -#endif if (verbose && used_photons<11) { printf("id=%ld\tpdg=22\tekin=%g MeV\tx=%g cm\ty=%g cm\tz=%g cm\tux=%g\tuy=%g\tuz=%g\tt=%g ms\tweight=%g\tpolx=%g\tpoly=%g\tpolz=%g\n", @@ -277,10 +269,7 @@ TRACE particle->direction[0], particle->direction[1], particle->direction[2], particle->time, particle->weight, particle->polarisation[0], particle->polarisation[1], particle->polarisation[2]); } - -#if defined (USE_MPI) - ); -#endif + ); /*positions are in cm*/ x=particle->position[0]/100; From 319d3e2405aac96515df0f1934c0517b34f654a1 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Sat, 22 Mar 2025 18:06:31 +0100 Subject: [PATCH 20/29] Try enabling MPI on MCPL_input McXtrace --- .github/workflows/mcxtrace-winbasictest-msvc.yml | 6 +++--- mcstas-comps/misc/MCPL_output.comp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/mcxtrace-winbasictest-msvc.yml b/.github/workflows/mcxtrace-winbasictest-msvc.yml index fc68a9fc96..caa632908f 100644 --- a/.github/workflows/mcxtrace-winbasictest-msvc.yml +++ b/.github/workflows/mcxtrace-winbasictest-msvc.yml @@ -144,9 +144,9 @@ jobs: # working-directory: run_mcpl_output # run: ..\install\bin\mxrun --verbose test.instr -d MPI_multicore -c --mpi=auto Ncount=1e3 - # - name: Run MCPL_input instrument MPI - # working-directory: run_mcpl_input - # run: ..\install\bin\mxrun --verbose test.instr -d MPI_multicore -c --mpi=auto repeat=1 + - name: Run MCPL_input instrument MPI + working-directory: run_mcpl_input + run: ..\install\bin\mxrun --verbose test.instr -d MPI_multicore -c --mpi=auto repeat=1 - name: 'Tar output files' id: tar-package diff --git a/mcstas-comps/misc/MCPL_output.comp b/mcstas-comps/misc/MCPL_output.comp index 025146e8fa..65cb33848d 100644 --- a/mcstas-comps/misc/MCPL_output.comp +++ b/mcstas-comps/misc/MCPL_output.comp @@ -100,7 +100,7 @@ INITIALIZE #if defined (USE_MPI) /* In case of MPI, simply redefine the filename used by each node */ - sprintf(tmpstr, "Message(%s): You are using MCPL_output with MPI, hence your will get %i filenames %s.node_#i.mcpl{.gz} as output.\n",NAME_CURRENT_COMP,mpi_node_count,filename); + sprintf(tmpstr, "Message(%s): You are using MCPL_output with MPI, hence you will get %i filenames %s.node_#i.mcpl{.gz} as output.\n",NAME_CURRENT_COMP,mpi_node_count,filename); sprintf(extension,"node_%i.mcpl",mpi_node_rank); #else sprintf(extension,"mcpl"); From 1770c7293d68d6f1f0be944f330219e218d43ba3 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Sat, 22 Mar 2025 18:15:01 +0100 Subject: [PATCH 21/29] MPI_MASTER fixes for McXtrace MCPL_output --- mcxtrace-comps/misc/MCPL_output.comp | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/mcxtrace-comps/misc/MCPL_output.comp b/mcxtrace-comps/misc/MCPL_output.comp index f867928ff4..8264faee83 100644 --- a/mcxtrace-comps/misc/MCPL_output.comp +++ b/mcxtrace-comps/misc/MCPL_output.comp @@ -95,17 +95,24 @@ INITIALIZE %{ char extension[128]=""; char *myfilename; - + char tmpstr[CHAR_BUF_LENGTH]; + // Use instance name for base output if no input was given if (!strcmp(filename,"\0")) sprintf(filename,"%s",NAME_CURRENT_COMP); #if defined (USE_MPI) /* In case of MPI, simply redefine the filename used by each node */ - MPI_MASTER(fprintf(stdout, "INFO (%s): You are using MCPL_output with MPI, hence you will get %i filenames %s_node_#i as output.\n",NAME_CURRENT_COMP,mpi_node_count,filename); ); + sprintf(tmpstr, "Message(%s): You are using MCPL_output with MPI, hence you will get %i filenames %s.node_#i.mcpl{.gz} as output.\n",NAME_CURRENT_COMP,mpi_node_count,filename); sprintf(extension,"node_%i.mcpl",mpi_node_rank); #else sprintf(extension,"mcpl"); #endif +sprintf(tmpstr, ""); + MPI_MASTER( + fprintf(stdout, "%s",tmpstr ); + ); + + /*add output dir (if applicable) to the output filename and add extension if */ // Append the extension to the filename // -- do not use mcfull_file for this since it can not handle absolute filenames with a '.' in them @@ -172,17 +179,11 @@ INITIALIZE mcpl_enable_doubleprec(outputfile); } -#if defined (USE_MPI) MPI_MASTER( -#endif - if (verbose==1) { printf("MCPL_output verbose mode: after generating the mcpl-file a summary will be printed.\n"); } - -#if defined (USE_MPI) ); -#endif /*Add comments on what the orientation and position of this component is.*/ /*Include the instrument file itself as a binary blob in the mcpl file*/ @@ -292,18 +293,14 @@ TRACE particle->userflags = (uint32_t) uvar; } -#if defined (USE_MPI) MPI_MASTER( -#endif if (verbose==3 && mcrun_num<10) { printf("id=%ld\tpdg=22\tekin=%g MeV\tx=%g cm\ty=%g cm\tz=%g cm\tux=%g\tuy=%g\tuz=%g\tt=%g ms\tweight=%g\tpolx=%g\tpoly=%g\tpolz=%g\n", mcrun_num, particle->ekin, particle->position[0], particle->position[1], particle->position[2], particle->direction[0], particle->direction[1], particle->direction[2], particle->time, particle->weight, particle->polarisation[0], particle->polarisation[1], particle->polarisation[2]); } -#if defined (USE_MPI) ); -#endif mcpl_add_particle(outputfile,particle); @@ -374,9 +371,8 @@ FINALLY #endif #ifdef USE_MPI MPI_Barrier(MPI_COMM_WORLD); - MPI_MASTER( /* Only attempt merge if requested and meaningful */ - if (merge_mpi && mpi_node_count > 1) { + if (mpi_node_rank==0 && merge_mpi && mpi_node_count > 1) { char **mpi_node_files; char *merge_outfilename; char extension[128]="mcpl"; @@ -422,7 +418,6 @@ FINALLY } free(mpi_node_files); } - ); #endif if(verbose) { MPI_MASTER( From 6f735be9a6bf0d2e16f54a51151dbba902c46c44 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Sat, 22 Mar 2025 18:15:34 +0100 Subject: [PATCH 22/29] Enable MCPL_output MPI McXtrace --- .github/workflows/mcstas-winbasictest-msvc.yml | 2 +- .github/workflows/mcxtrace-winbasictest-msvc.yml | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/mcstas-winbasictest-msvc.yml b/.github/workflows/mcstas-winbasictest-msvc.yml index 35bcdec188..3aa3dd1c1c 100644 --- a/.github/workflows/mcstas-winbasictest-msvc.yml +++ b/.github/workflows/mcstas-winbasictest-msvc.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: - os: [windows-2019, windows-2022] + os: [windows-2019, windows-2022, windows-2025] steps: diff --git a/.github/workflows/mcxtrace-winbasictest-msvc.yml b/.github/workflows/mcxtrace-winbasictest-msvc.yml index caa632908f..6b791c4364 100644 --- a/.github/workflows/mcxtrace-winbasictest-msvc.yml +++ b/.github/workflows/mcxtrace-winbasictest-msvc.yml @@ -16,8 +16,7 @@ jobs: strategy: matrix: -# os: [windows-2019, windows-2022] - os: [windows-2022] + os: [windows-2019, windows-2022, windows-2025] steps: @@ -140,9 +139,9 @@ jobs: working-directory: run_std run: ..\install\bin\mxrun --verbose test.instr -d MPI_multicore -c --mpi=auto LENS=0 - # - name: Run MCPL_output instrument MPI - # working-directory: run_mcpl_output - # run: ..\install\bin\mxrun --verbose test.instr -d MPI_multicore -c --mpi=auto Ncount=1e3 + - name: Run MCPL_output instrument MPI + working-directory: run_mcpl_output + run: ..\install\bin\mxrun --verbose test.instr -d MPI_multicore -c --mpi=auto Ncount=1e3 - name: Run MCPL_input instrument MPI working-directory: run_mcpl_input From 900801b2227e224600b4c41cdb8c842edecc31d5 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Sun, 23 Mar 2025 16:23:53 +0100 Subject: [PATCH 23/29] mingw / gcc based workflow for mcstas windows --- .../workflows/mcstas-winbasictest-mingw.yml | 184 ++++++++++++++++++ .../workflows/mcstas-winbasictest-msvc.yml | 8 +- .../workflows/mcxtrace-winbasictest-msvc.yml | 8 +- 3 files changed, 192 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/mcstas-winbasictest-mingw.yml diff --git a/.github/workflows/mcstas-winbasictest-mingw.yml b/.github/workflows/mcstas-winbasictest-mingw.yml new file mode 100644 index 0000000000..0381e0884f --- /dev/null +++ b/.github/workflows/mcstas-winbasictest-mingw.yml @@ -0,0 +1,184 @@ +name: mcstas-mingw-winbasictest + +on: + push: + pull_request: + +jobs: + build: + # More platform information available on: + # https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md + + runs-on: ${{ matrix.os }} + defaults: + run: + shell: cmd + + strategy: + matrix: + os: [windows-2022] + + steps: + + - name: Checkout + uses: actions/checkout@v4 + with: + path: src + + - name: Setup python + uses: actions/setup-python@v5 + with: + python-version: 3.11 + + - name: Setup MPI + uses: mpi4py/setup-mpi@v1 + with: + mpi: 'msmpi' + + - name: Setup MPI cygpath bash... + shell: bash + run: | + cygpath -sm "$MSMPI_INC" > includepath.txt + cygpath -sm "$MSMPI_LIB64" > libpath.txt + + - name: Setup MPI cygpath... + run: | + set /p MPIINCVAR=> %GITHUB_ENV% + echo MPILIBVAR=%MPILIBVAR% >> %GITHUB_ENV% + + - name: choco install wget + run: choco install wget + + - name: pip install deps + run: pip install PyYAML ply McStasscript ncrystal mslex + + - name: pip install mcpl-core preview + run: pip install -v "git+https://github.com/mctools/mcpl@path_to_mcpl2#subdirectory=mcpl_core" + + - name: choco install deps2 + run: choco install mingw make winflexbison3 + + - name: CMake cfg + run: > + cmake -B build -S src + -G "Unix Makefiles" + -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc.exe + "-DCMAKE_INSTALL_PREFIX=./install" + -DMCVERSION="3.99.99" + -DMCCODE_BUILD_CONDA_PKG=OFF + -DMCCODE_BUILD_WINDOWS_MINGW=ON + -DCMAKE_INSTALL_LIBDIR=lib + -DBUILD_MCSTAS=ON + -DMCCODE_USE_LEGACY_DESTINATIONS=OFF + -DBUILD_TOOLS=ON + -DENABLE_COMPONENTS=ON + -DENABLE_CIF2HKL=OFF + -DENABLE_NEUTRONICS=OFF + -DMPIINCLUDEDIR=%MPIINCVAR% + -DMPILIBDIR=%MPILIBVAR% + + - name: CMake build + shell: cmd + run: cmake --build build --config Release -j 2 + + - name: CMake install + run: cmake --install build --config Release + + - name: set MCSTAS env var + run: echo MCSTAS=%CD%\install\share\mcstas\resources >> %GITHUB_ENV% + + - name: check MCSTAS env var + run: echo %MCSTAS% + + - run: type .\install\share\mcstas\tools\Python\mccodelib\mccode_config.json + - run: .\install\bin\mcrun -h + - run: .\install\bin\mcstas -v + - run: mcpl-config -s + - run: ncrystal-config -s + + - name: Prepare rundirs + run: mkdir run_std run_mcpl_output run_mcpl_input run_mcpl_input_once run_union run_ncrystal + + - name: Prepare std instrument + working-directory: run_std + run: copy ..\install\share\mcstas\resources\examples\BNL\BNL_H8\BNL_H8.instr test.instr + + - name: Prepare NCrystal instrument + working-directory: run_ncrystal + run: copy ..\install\share\mcstas\resources\examples\NCrystal\NCrystal_example\NCrystal_example.instr test.instr + + - name: Prepare MCPL_input instrument + working-directory: run_mcpl_input + run: | + copy ..\install\share\mcstas\resources\examples\Tests_MCPL_etc\Test_MCPL_input\Test_MCPL_input.instr test.instr + copy ..\install\share\mcstas\resources\examples\Tests_MCPL_etc\Test_MCPL_input\voutput.mcpl . + + - name: Prepare MCPL_input_once instrument + working-directory: run_mcpl_input_once + run: | + copy ..\install\share\mcstas\resources\examples\Tests_MCPL_etc\Test_MCPL_input_once\Test_MCPL_input_once.instr test.instr + copy ..\install\share\mcstas\resources\examples\Tests_MCPL_etc\Test_MCPL_input_once\voutput.mcpl . + + - name: Prepare MCPL_output instrument + working-directory: run_mcpl_output + run: copy ..\install\share\mcstas\resources\examples\Tests_MCPL_etc\Test_MCPL_output\Test_MCPL_output.instr test.instr + + - name: Run std instrument + working-directory: run_std + run: ..\install\bin\mcrun --verbose test.instr -d Single_core lambda=2.36 + + - name: Run MCPL_output instrument + working-directory: run_mcpl_output + run: ..\install\bin\mcrun --verbose test.instr -d Single_core Ncount=1e3 + + - name: Run MCPL_input instrument + working-directory: run_mcpl_input + run: ..\install\bin\mcrun --verbose test.instr -d Single_core repeat=1 + + - name: Run MCPL_input_once instrument + working-directory: run_mcpl_input_once + run: ..\install\bin\mcrun --verbose test.instr -d Single_core v_smear=0.1 + + - name: Run NCrystal instrument + working-directory: run_ncrystal + run: ..\install\bin\mcrun --verbose test.instr -d Single_core sample_cfg="Y2O3_sg206_Yttrium_Oxide.ncmat;density=0.6x" + + - name: Run std instrument MPI + working-directory: run_std + run: ..\install\bin\mcrun --verbose test.instr -d MPI_multicore -c --mpi=auto lambda=2.36 + + - name: Run MCPL_output instrument MPI + working-directory: run_mcpl_output + run: ..\install\bin\mcrun --verbose test.instr -d MPI_multicore -c --mpi=auto Ncount=1e3 + + - name: Run MCPL_input instrument MPI + working-directory: run_mcpl_input + run: ..\install\bin\mcrun --verbose test.instr -d MPI_multicore -c --mpi=auto repeat=1 + + - name: Run MCPL_input_once instrument MPI + working-directory: run_mcpl_input_once + run: ..\install\bin\mcrun --verbose test.instr -d MPI_multicore -c --mpi=auto v_smear=0.1 + + - name: Run NCrystal instrument MPI + working-directory: run_ncrystal + run: ..\install\bin\mcrun --verbose test.instr -d MPI_multicore -c --mpi=auto sample_cfg="Y2O3_sg206_Yttrium_Oxide.ncmat;density=0.6x" + + - name: 'Tar output files' + id: tar-package + if: always() + shell: bash + run: | + set -e + set -u + set -x + tar cvfz mcstas-mingw-${{ matrix.os }}_output.tgz run_* + + - name: 'Upload Artifact' + id: tar-upload + uses: actions/upload-artifact@v4 + if: always() + with: + name: mcstas-mingw-${{ matrix.os }}_output.tgz + path: "mcstas-mingw-${{ matrix.os }}_output.tgz" diff --git a/.github/workflows/mcstas-winbasictest-msvc.yml b/.github/workflows/mcstas-winbasictest-msvc.yml index 3aa3dd1c1c..4792358415 100644 --- a/.github/workflows/mcstas-winbasictest-msvc.yml +++ b/.github/workflows/mcstas-winbasictest-msvc.yml @@ -1,4 +1,4 @@ -name: mcstas-winbasictest +name: mcstas-msvc-winbasictest on: push: @@ -181,12 +181,12 @@ jobs: set -e set -u set -x - tar cvfz mcstas-${{ matrix.os }}_output.tgz run_* + tar cvfz mcstas-msvc-${{ matrix.os }}_output.tgz run_* - name: 'Upload Artifact' id: tar-upload uses: actions/upload-artifact@v4 if: always() with: - name: mcstas-${{ matrix.os }}_output.tgz - path: "mcstas-${{ matrix.os }}_output.tgz" + name: mcstas-msvc-${{ matrix.os }}_output.tgz + path: "mcstas-msvc-${{ matrix.os }}_output.tgz" diff --git a/.github/workflows/mcxtrace-winbasictest-msvc.yml b/.github/workflows/mcxtrace-winbasictest-msvc.yml index 6b791c4364..f647781697 100644 --- a/.github/workflows/mcxtrace-winbasictest-msvc.yml +++ b/.github/workflows/mcxtrace-winbasictest-msvc.yml @@ -1,4 +1,4 @@ -name: mcxtrace-winbasictest +name: mcxtrace-msvc-winbasictest on: push: @@ -155,12 +155,12 @@ jobs: set -e set -u set -x - tar cvfz mcxtrace-${{ matrix.os }}_output.tgz run_* + tar cvfz mcxtrace-msvc-${{ matrix.os }}_output.tgz run_* - name: 'Upload Artifact' id: tar-upload uses: actions/upload-artifact@v4 if: always() with: - name: mcxtrace-${{ matrix.os }}_output.tgz - path: "mcxtrace-${{ matrix.os }}_output.tgz" + name: mcxtrace-msvc-${{ matrix.os }}_output.tgz + path: "mcxtrace-msvc-${{ matrix.os }}_output.tgz" From af09c1ecada65a9741c7c6d6794c753ce33e3265 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Sun, 23 Mar 2025 18:55:42 +0100 Subject: [PATCH 24/29] Add workflow for mingw McXtrace --- .../workflows/mcxtrace-winbasictest-mingw.yml | 156 ++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 .github/workflows/mcxtrace-winbasictest-mingw.yml diff --git a/.github/workflows/mcxtrace-winbasictest-mingw.yml b/.github/workflows/mcxtrace-winbasictest-mingw.yml new file mode 100644 index 0000000000..3ea61bcb6d --- /dev/null +++ b/.github/workflows/mcxtrace-winbasictest-mingw.yml @@ -0,0 +1,156 @@ +name: mcxtrace-mingw-winbasictest + +on: + push: + pull_request: + +jobs: + build: + # More platform information available on: + # https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md + + runs-on: ${{ matrix.os }} + defaults: + run: + shell: cmd + + strategy: + matrix: + os: [windows-2022] + + steps: + + - name: Checkout + uses: actions/checkout@v4 + with: + path: src + + - name: Setup python + uses: actions/setup-python@v5 + with: + python-version: 3.11 + + - name: Setup MPI + uses: mpi4py/setup-mpi@v1 + with: + mpi: 'msmpi' + + - name: Setup MPI cygpath bash... + shell: bash + run: | + cygpath -sm "$MSMPI_INC" > includepath.txt + cygpath -sm "$MSMPI_LIB64" > libpath.txt + + - name: Setup MPI cygpath... + run: | + set /p MPIINCVAR=> %GITHUB_ENV% + echo MPILIBVAR=%MPILIBVAR% >> %GITHUB_ENV% + + - name: choco install wget + run: choco install wget + + - name: pip install deps + run: pip install PyYAML ply McStasscript mslex + + - name: pip install mcpl-core preview + run: pip install -v "git+https://github.com/mctools/mcpl@path_to_mcpl2#subdirectory=mcpl_core" + + - name: choco install deps2 + run: choco install mingw make winflexbison3 + + - name: CMake cfg + run: > + cmake -B build -S src + -G "Unix Makefiles" + -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc.exe + "-DCMAKE_INSTALL_PREFIX=./install" + -DMCVERSION="3.99.99" + -DMCCODE_BUILD_CONDA_PKG=OFF + -DMCCODE_BUILD_WINDOWS_MINGW=ON + -DCMAKE_INSTALL_LIBDIR=lib + -DBUILD_MCXTRACE=ON + -DMCCODE_USE_LEGACY_DESTINATIONS=OFF + -DBUILD_TOOLS=ON + -DENABLE_COMPONENTS=ON + -DENABLE_CIF2HKL=OFF + -DENABLE_NEUTRONICS=OFF + -DMPIINCLUDEDIR=%MPIINCVAR% + -DMPILIBDIR=%MPILIBVAR% + + - name: CMake build + shell: cmd + run: cmake --build build --config Release -j 2 + + - name: CMake install + run: cmake --install build --config Release + + - name: set MCXTRACE env var + run: echo MCXTRACE=%CD%\install\share\mcxtrace\resources >> %GITHUB_ENV% + + - name: check MCXTRACE env var + run: echo %MCXTRACE% + + - run: type .\install\share\mcxtrace\tools\Python\mccodelib\mccode_config.json + - run: .\install\bin\mxrun -h + - run: .\install\bin\mcxtrace -v + - run: mcpl-config -s + + - name: Prepare rundirs + run: mkdir run_std run_mcpl_output run_mcpl_input run_union + + - name: Prepare std instrument + working-directory: run_std + run: copy ..\install\share\mcxtrace\resources\examples\Tests_optics\Test_CRL\Test_CRL.instr test.instr + + - name: Prepare MCPL_input instrument + working-directory: run_mcpl_input + run: | + copy ..\install\share\mcxtrace\resources\examples\Tests_MCPL_etc\Test_MCPL_input\Test_MCPL_input.instr test.instr + + - name: Prepare MCPL_output instrument + working-directory: run_mcpl_output + run: copy ..\install\share\mcxtrace\resources\examples\Tests_MCPL_etc\Test_MCPL_output\Test_MCPL_output.instr test.instr + + - name: Run std instrument + working-directory: run_std + run: ..\install\bin\mxrun --verbose test.instr -d Single_core LENS=0 + + - name: Run MCPL_output instrument + working-directory: run_mcpl_output + run: ..\install\bin\mxrun --verbose test.instr -d Single_core Ncount=1e3 + + - name: Run MCPL_input instrument + working-directory: run_mcpl_input + run: ..\install\bin\mxrun --verbose test.instr -d Single_core repeat=1 + + - name: Run std instrument MPI + working-directory: run_std + run: ..\install\bin\mxrun --verbose test.instr -d MPI_multicore -c --mpi=auto LENS=0 + + - name: Run MCPL_output instrument MPI + working-directory: run_mcpl_output + run: ..\install\bin\mxrun --verbose test.instr -d MPI_multicore -c --mpi=auto Ncount=1e3 + + - name: Run MCPL_input instrument MPI + working-directory: run_mcpl_input + run: ..\install\bin\mxrun --verbose test.instr -d MPI_multicore -c --mpi=auto repeat=1 + + - name: 'Tar output files' + id: tar-package + if: always() + shell: bash + run: | + set -e + set -u + set -x + tar cvfz mcxtrace-mingw-${{ matrix.os }}_output.tgz run_* + + - name: 'Upload Artifact' + id: tar-upload + uses: actions/upload-artifact@v4 + if: always() + with: + name: mcxtrace-mingw-${{ matrix.os }}_output.tgz + path: "mcxtrace-mingw-${{ matrix.os }}_output.tgz" From 9c2da59fcd7ad23c13ffe3943028b5edc5064b68 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Mon, 24 Mar 2025 09:49:51 +0100 Subject: [PATCH 25/29] Windows has its own basictest track --- .github/workflows/mcstas-basictest.yml | 2 +- .github/workflows/mcxtrace-basictest.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mcstas-basictest.yml b/.github/workflows/mcstas-basictest.yml index ce0a69807b..78f81fabe2 100644 --- a/.github/workflows/mcstas-basictest.yml +++ b/.github/workflows/mcstas-basictest.yml @@ -28,7 +28,7 @@ jobs: - { os: macos-13, CC: clang, CXX: clang++, python: "3.11", mpi: 'openmpi' } - { os: macos-14, CC: clang, CXX: clang++, python: "3.12", mpi: 'openmpi' } - { os: macos-15, CC: clang, CXX: clang++, python: "3.13", mpi: 'openmpi' } - - { os: windows-latest, CC: gcc, CXX: g++, python: "3.12", mpi: 'msmpi' } + #- { os: windows-latest, CC: gcc, CXX: g++, python: "3.12", mpi: 'msmpi' } name: ${{ matrix.os }}.${{ matrix.CC }}.${{ matrix.mpi }}.python-${{ matrix.python }} runs-on: ${{ matrix.os }} diff --git a/.github/workflows/mcxtrace-basictest.yml b/.github/workflows/mcxtrace-basictest.yml index a08ae49593..84eea87abc 100644 --- a/.github/workflows/mcxtrace-basictest.yml +++ b/.github/workflows/mcxtrace-basictest.yml @@ -28,7 +28,7 @@ jobs: - { os: macos-13, CC: clang, CXX: clang++, python: "3.11", mpi: 'openmpi' } - { os: macos-14, CC: clang, CXX: clang++, python: "3.12", mpi: 'openmpi' } - { os: macos-15, CC: clang, CXX: clang++, python: "3.13", mpi: 'openmpi' } - - { os: windows-latest, CC: gcc, CXX: g++, python: "3.12", mpi: 'msmpi' } + #- { os: windows-latest, CC: gcc, CXX: g++, python: "3.12", mpi: 'msmpi' } name: ${{ matrix.os }}.${{ matrix.CC }}.${{ matrix.mpi }}.python-${{ matrix.python }} runs-on: ${{ matrix.os }} From 00decf077229ccf1791dd3f12dacfba1cc9d1243 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Mon, 24 Mar 2025 10:19:55 +0100 Subject: [PATCH 26/29] Add MCPLFLAGS in these config snips --- tools/Python/mctest/mcstas-test/McStas_8GPU/mccode_config.json | 1 + .../Python/mctest/mcxtrace-test/McXtrace_8GPU/mccode_config.json | 1 + 2 files changed, 2 insertions(+) diff --git a/tools/Python/mctest/mcstas-test/McStas_8GPU/mccode_config.json b/tools/Python/mctest/mcstas-test/McStas_8GPU/mccode_config.json index d91da1ad5e..6cca02f5e7 100644 --- a/tools/Python/mctest/mcstas-test/McStas_8GPU/mccode_config.json +++ b/tools/Python/mctest/mcstas-test/McStas_8GPU/mccode_config.json @@ -24,6 +24,7 @@ "OACCFLAGS": "-fast -Minfo=accel -acc=gpu -gpu=mem:managed -DOPENACC", "GSLFLAGS": "-Wl,-rpath,GETPATH(miniconda3/lib) -LGETPATH(miniconda3/lib) -lgsl -lgslcblas -IGETPATH(miniconda3/include)", "NCRYSTALFLAGS": "CMD(ncrystal-config --show buildflags)", + "MCPLFLAGS": "-Wl,-rpath,CMD(mcpl-config --show libdir) -Wl,CMD(mcpl-config --show libpath) -ICMD(mcpl-config --show includedir)", "XRLFLAGS": "", "CC": "gcc", "OACC": "nvc", diff --git a/tools/Python/mctest/mcxtrace-test/McXtrace_8GPU/mccode_config.json b/tools/Python/mctest/mcxtrace-test/McXtrace_8GPU/mccode_config.json index a6e958f3d8..f36cf97271 100644 --- a/tools/Python/mctest/mcxtrace-test/McXtrace_8GPU/mccode_config.json +++ b/tools/Python/mctest/mcxtrace-test/McXtrace_8GPU/mccode_config.json @@ -24,6 +24,7 @@ "OACCFLAGS": "-fast -Minfo=accel -acc=gpu -gpu=mem:managed -DOPENACC", "GSLFLAGS": "-Wl,-rpath,GETPATH(miniconda3/lib) -LGETPATH(miniconda3/lib) -lgsl -lgslcblas -IGETPATH(miniconda3/include)", "NCRYSTALFLAGS": "", + "MCPLFLAGS": "-Wl,-rpath,CMD(mcpl-config --show libdir) -Wl,CMD(mcpl-config --show libpath) -ICMD(mcpl-config --show includedir)", "XRLFLAGS": "-Wl,-rpath,GETPATH(miniconda3/lib) -LGETPATH(miniconda3/lib) -lxrl -IGETPATH(miniconda3/include)", "CC": "gcc", "OACC": "nvc", From 3ee3e86d5ac738dc33fa41699015779b1866c8ba Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Mon, 24 Mar 2025 09:42:33 +0100 Subject: [PATCH 27/29] Configure these builds for -DMCCODE_CONFIG_MCPL2=ON since they work from temporary source of this type --- .github/workflows/mcstas-winbasictest-mingw.yml | 1 + .github/workflows/mcstas-winbasictest-msvc.yml | 1 + .github/workflows/mcxtrace-winbasictest-mingw.yml | 1 + .github/workflows/mcxtrace-winbasictest-msvc.yml | 1 + 4 files changed, 4 insertions(+) diff --git a/.github/workflows/mcstas-winbasictest-mingw.yml b/.github/workflows/mcstas-winbasictest-mingw.yml index 0381e0884f..5d541db2ce 100644 --- a/.github/workflows/mcstas-winbasictest-mingw.yml +++ b/.github/workflows/mcstas-winbasictest-mingw.yml @@ -69,6 +69,7 @@ jobs: -DMCVERSION="3.99.99" -DMCCODE_BUILD_CONDA_PKG=OFF -DMCCODE_BUILD_WINDOWS_MINGW=ON + -DMCCODE_CONFIG_MCPL2=ON -DCMAKE_INSTALL_LIBDIR=lib -DBUILD_MCSTAS=ON -DMCCODE_USE_LEGACY_DESTINATIONS=OFF diff --git a/.github/workflows/mcstas-winbasictest-msvc.yml b/.github/workflows/mcstas-winbasictest-msvc.yml index 4792358415..b9e296f340 100644 --- a/.github/workflows/mcstas-winbasictest-msvc.yml +++ b/.github/workflows/mcstas-winbasictest-msvc.yml @@ -71,6 +71,7 @@ jobs: "-DCMAKE_INSTALL_PREFIX=./install" -DMCVERSION="3.99.99" -DMCCODE_BUILD_CONDA_PKG=OFF + -DMCCODE_CONFIG_MCPL2=ON -DCMAKE_INSTALL_LIBDIR=lib -DBUILD_MCSTAS=ON -DMCCODE_USE_LEGACY_DESTINATIONS=OFF diff --git a/.github/workflows/mcxtrace-winbasictest-mingw.yml b/.github/workflows/mcxtrace-winbasictest-mingw.yml index 3ea61bcb6d..13a6fce60c 100644 --- a/.github/workflows/mcxtrace-winbasictest-mingw.yml +++ b/.github/workflows/mcxtrace-winbasictest-mingw.yml @@ -69,6 +69,7 @@ jobs: -DMCVERSION="3.99.99" -DMCCODE_BUILD_CONDA_PKG=OFF -DMCCODE_BUILD_WINDOWS_MINGW=ON + -DMCCODE_CONFIG_MCPL2=ON -DCMAKE_INSTALL_LIBDIR=lib -DBUILD_MCXTRACE=ON -DMCCODE_USE_LEGACY_DESTINATIONS=OFF diff --git a/.github/workflows/mcxtrace-winbasictest-msvc.yml b/.github/workflows/mcxtrace-winbasictest-msvc.yml index f647781697..ba73d4951e 100644 --- a/.github/workflows/mcxtrace-winbasictest-msvc.yml +++ b/.github/workflows/mcxtrace-winbasictest-msvc.yml @@ -71,6 +71,7 @@ jobs: "-DCMAKE_INSTALL_PREFIX=./install" -DMCVERSION="3.99.99" -DMCCODE_BUILD_CONDA_PKG=OFF + -DMCCODE_CONFIG_MCPL2=ON -DCMAKE_INSTALL_LIBDIR=lib -DBUILD_MCXTRACE=ON -DMCCODE_USE_LEGACY_DESTINATIONS=OFF From 78839aa9aabf51bf86ce9ae7a4cd831006eb582f Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Mon, 24 Mar 2025 09:39:09 +0100 Subject: [PATCH 28/29] Add use of MCPLFLAGS in tool layer --- cmake/Modules/PlatformDefaults.cmake | 14 ++++++++++++-- tools/Python/mccodelib/mccode_config.json.in | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cmake/Modules/PlatformDefaults.cmake b/cmake/Modules/PlatformDefaults.cmake index 7f4c07b8ec..b6f8a400e2 100644 --- a/cmake/Modules/PlatformDefaults.cmake +++ b/cmake/Modules/PlatformDefaults.cmake @@ -78,7 +78,12 @@ function( detect_platform_variables resultvarname ) if ( BUILD_MCSTAS ) set( IDFGEN mcdisplay-mantid ) set( NCRYSTALFLAGS "CMD(ncrystal-config --show buildflags)" ) - set( MCPLFLAGS "CMD(mcpl-config --show buildflags)" ) + # FIXME: Needs correction post release of MCPL v2 + if ( MCCODE_CONFIG_MCPL2 ) + set( MCPLFLAGS "CMD(mcpl-config --show buildflags)" ) + else() + set( MCPLFLAGS "-Wl,-rpath,CMD(mcpl-config --show libdir) -Wl,CMD(mcpl-config --show libpath) -ICMD(mcpl-config --show includedir)" ) + endif() # Temporary solution for NCrystal on Windows 'MingW cross-compiled' systems if ( WINDOWS AND MCCODE_BUILD_WINDOWS_MINGW ) set( NCRYSTALFLAGS "-Wl,-rpath,CMD(ncrystal-config --show libdir) -Wl,CMD(ncrystal-config --show libpath) -ICMD(ncrystal-config --show includedir)" ) @@ -87,7 +92,12 @@ function( detect_platform_variables resultvarname ) else() set( IDFGEN "" ) set( NCRYSTALFLAGS "") - set( MCPLFLAGS "CMD(mcpl-config --show buildflags)" ) + # FIXME: Needs correction post release of MCPL v2 + if ( MCCODE_CONFIG_MCPL2 ) + set( MCPLFLAGS "CMD(mcpl-config --show buildflags)" ) + else() + set( MCPLFLAGS "-Wl,-rpath,CMD(mcpl-config --show libdir) -Wl,CMD(mcpl-config --show libpath) -ICMD(mcpl-config --show includedir)" ) + endif() # Temporary solution for NCrystal on Windows 'MingW cross-compiled' systems if ( WINDOWS AND MCCODE_BUILD_WINDOWS_MINGW ) set( MCPLFLAGS "-Wl,-rpath,CMD(mcpl-config --show libdir) -Wl,CMD(mcpl-config --show libpath) -ICMD(mcpl-config --show includedir)" ) diff --git a/tools/Python/mccodelib/mccode_config.json.in b/tools/Python/mccodelib/mccode_config.json.in index e71adfb335..d40fa99262 100644 --- a/tools/Python/mccodelib/mccode_config.json.in +++ b/tools/Python/mccodelib/mccode_config.json.in @@ -26,7 +26,7 @@ "MPIFLAGS": "@MCCODE_FINAL_MPIFLAGS@", "GSLFLAGS": "@MCCODE_FINAL_GSLFLAGS@", "NCRYSTALFLAGS": "@MCCODE_FINAL_NCRYSTALFLAGS@", - "MCPLFLAGS": "@MCCODE_FINAL_MCPLFLAGS@", + "MCPLFLAGS": "@MCCODE_FINAL_MCPLFLAGS@", "XRLFLAGS": "@MCCODE_FINAL_XRLFLAGS@", "OACCFLAGS": "@MCCODE_FINAL_OACCFLAGS@", "CC": "@MCCODE_FINAL_TOOLS_CC@", From 33c78ad7f8ed54f69490eec7333b7854a9a9a245 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Mon, 24 Mar 2025 09:47:21 +0100 Subject: [PATCH 29/29] Consequence-edit: McXtrace MCPL examples moved. --- .github/workflows/mcxtrace-basictest.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mcxtrace-basictest.yml b/.github/workflows/mcxtrace-basictest.yml index 84eea87abc..dfe21cb373 100644 --- a/.github/workflows/mcxtrace-basictest.yml +++ b/.github/workflows/mcxtrace-basictest.yml @@ -216,7 +216,7 @@ jobs: test -f ./install_mcxtrace/bin/${MCXTRACE_EXECUTABLE} ./install_mcxtrace/bin/${MCXTRACE_EXECUTABLE} --version mkdir run_Test_MCPL_input && cd run_Test_MCPL_input - cp ../install_mcxtrace/share/mcxtrace/resources/examples/Tests/Test_MCPL_input/Test_MCPL_input.instr . + cp ../install_mcxtrace/share/mcxtrace/resources/examples/Tests_MCPL_etc/Test_MCPL_input/Test_MCPL_input.instr . ../install_mcxtrace/bin/${MXRUN_EXECUTABLE} Test_MCPL_input.instr repeat=10 - name: Launch MCPL test instrument (MPI) @@ -236,7 +236,7 @@ jobs: test -f ./install_mcxtrace/bin/${MCXTRACE_EXECUTABLE} ./install_mcxtrace/bin/${MCXTRACE_EXECUTABLE} --version mkdir run_Test_MCPL_input_mpi && cd run_Test_MCPL_input_mpi - cp ../install_mcxtrace/share/mcxtrace/resources/examples/Tests/Test_MCPL_input/Test_MCPL_input.instr . + cp ../install_mcxtrace/share/mcxtrace/resources/examples/Tests_MCPL_etc/Test_MCPL_input/Test_MCPL_input.instr . ../install_mcxtrace/bin/${MXRUN_EXECUTABLE} --verbose --mpi=2 Test_MCPL_input.instr repeat=20 - name: 'Tar output files'