Skip to content

Commit d520629

Browse files
authored
Merge pull request #239 from aglowacki/master
bug fixes
2 parents 1f92adc + 87ab115 commit d520629

60 files changed

Lines changed: 3568 additions & 6331 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@
77
[submodule "vcpkg"]
88
path = vcpkg
99
url = https://github.com/Microsoft/vcpkg
10+
[submodule "src/support/MDA_Utilities"]
11+
path = src/support/MDA_Utilities
12+
url = https://github.com/BCDA-APS/MDA_Utilities.git

CMakeLists.txt

Lines changed: 138 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,15 @@ set(EIGEN3_INCLUDES "${PROJECT_SOURCE_DIR}/src/support/eigen-git-mirror" CACHE P
7979
# option(BUILD_WITH_OPENCL "Build with OPENCL support" OFF)
8080
option(BUILD_WITH_PYBIND11 "Build python binding with PyBind11" OFF)
8181
option(BUILD_WITH_ZMQ "Build with ZeroMQ" OFF)
82-
option(BUILD_FOR_PHI "Build for Intel Phi" OFF)
8382
option(BUILD_WITH_QT "Build with QT" OFF)
84-
option(STATIC_BUILD "Static build libxrf_io and libxrf_fit" OFF)
83+
option(BUILD_STATIC "Static build libxrf_io and libxrf_fit" OFF)
8584
# If compiled on some intel mahcines this causes crashes so let user set it for compile
8685
option(AVX512 "Compule with arch AVX512 on MSVC" OFF)
8786
option(AVX2 "Compule with arch AVX2 on MSVC" OFF)
8887
option(AVX "Compule with arch AVX on MSVC" OFF)
8988
option(SSE2 "Compule with arch SSE2 on MSVC" OFF)
9089
option(MSVC_DEBUG_INFO_REL "Compule with debug info in Release build for MSVC" OFF)
9190

92-
93-
9491
# generate_git_hash_header.cmake
9592
# This script is run by add_custom_command to generate the header file.
9693

@@ -174,13 +171,8 @@ IF (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU"
174171
# Enable C++11 mode on C++ / Clang
175172
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20 -D__Unix__ -fPIC -g")
176173
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__Unix__ -fPIC")
177-
IF(BUILD_FOR_PHI AND CMAKE_CXX_COMPILER_ID MATCHES "Intel" )
178-
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -xMIC-AVX512")
179-
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -xMIC-AVX512")
180-
ELSE()
181-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
182-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
183-
ENDIF()
174+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
175+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
184176
#set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra")
185177
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Waddress -Warray-bounds=1 -Wbool-compare -Wbool-operation -Wc++17-compat -Wcatch-value -Wchar-subscripts -Wcomment -Wenum-compare -Wformat -Winit-self -Wlogical-not-parentheses -Wmain -Wmaybe-uninitialized -Wmemset-elt-size -Wmemset-transposed-args -Wmisleading-indentation -Wmissing-attributes -Wmissing-braces -Wmultistatement-macros -Wnarrowing -Wnonnull -Wnonnull-compare -Wopenmp-simd -Wparentheses -Wreorder -Wrestrict -Wreturn-type -Wsequence-point -Wsign-compare -Wsizeof-pointer-div -Wsizeof-pointer-memaccess -Wstrict-aliasing -Wstrict-overflow=1 -Wswitch -Wtautological-compare -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunused-function -Wunused-label -Wunused-value -Wvolatile-register-var")
186178
ELSEIF(MSVC)
@@ -238,7 +230,7 @@ ENDIF()
238230

239231
# Visual Studio specific include and source
240232
IF(MSVC)
241-
set(XDR_HACK src/support/mdautils-1.4.1/xdr_hack.c src/support/mdautils-1.4.1/xdr_hack.h )
233+
set(XDR_HACK src/support/MDA_Utilities/src/xdr_hack.c src/support/MDA_Utilities/src/xdr_hack.h )
242234
include_directories(src/support/direct)
243235
add_compile_options(/bigobj)
244236
ELSE()
@@ -305,7 +297,7 @@ set(libxrf_fit_SOURCE
305297
#--------------- start xrf io lib -----------------
306298
set(XRF_IO_HEADERS
307299
src/core/mem_info.h
308-
src/support/mdautils-1.4.1/mda-load.h
300+
src/support/MDA_Utilities/src/mda-load.h
309301
src/io/file/file_scan.h
310302
src/io/file/mda_io.h
311303
src/io/file/mca_io.h
@@ -334,7 +326,7 @@ set(XRF_IO_SOURCE
334326
${VISUAL_INC}
335327
src/core/mem_info.cpp
336328
src/io/file/file_scan.cpp
337-
src/support/mdautils-1.4.1/mda_loader.c
329+
src/support/MDA_Utilities/src/mda_loader.c
338330
src/io/file/aps/aps_fit_params_import.cpp
339331
src/io/file/mda_io.cpp
340332
src/io/file/hdf5_io.cpp
@@ -351,14 +343,14 @@ set(XRF_IO_SOURCE
351343
src/core/process_whole.cpp
352344
)
353345

354-
IF(BUILD_FOR_PHI)
346+
IF(BUILD_STATIC)
355347
add_library(libxrf_fit STATIC
356348
${libxrf_fit_HEADERS}
357349
${libxrf_fit_SOURCE}
358350
)
359351
add_library(libxrf_io STATIC
360-
${XRF_IO_HEADERS}
361352
${XDR_HACK}
353+
${XRF_IO_HEADERS}
362354
${XRF_IO_SOURCE}
363355
)
364356
ELSE()
@@ -367,8 +359,8 @@ ELSE()
367359
${libxrf_fit_SOURCE}
368360
)
369361
add_library(libxrf_io SHARED
370-
${XRF_IO_HEADERS}
371-
${XDR_HACK}
362+
${XDR_HACK}
363+
${XRF_IO_HEADERS}
372364
${XRF_IO_SOURCE}
373365
)
374366
ENDIF()
@@ -504,14 +496,11 @@ ELSEIF (UNIX)
504496
add_custom_command(TARGET libxrf_io POST_BUILD COMMAND strip -u -r ${PROJECT_SOURCE_DIR}/bin/libxrf_io.dylib)
505497
ENDIF()
506498
ELSE()
507-
#if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Intel")
508-
IF(NOT BUILD_FOR_PHI)
509-
IF(NOT STATIC_BUILD)
510-
set_target_properties(libxrf_fit libxrf_io PROPERTIES SUFFIX ".so")
511-
IF (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG)
512-
add_custom_command(TARGET libxrf_fit POST_BUILD COMMAND strip ${PROJECT_SOURCE_DIR}/bin/libxrf_fit.so)
513-
add_custom_command(TARGET libxrf_io POST_BUILD COMMAND strip ${PROJECT_SOURCE_DIR}/bin/libxrf_io.so)
514-
ENDIF()
499+
IF(NOT BUILD_STATIC)
500+
set_target_properties(libxrf_fit libxrf_io PROPERTIES SUFFIX ".so")
501+
IF (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG)
502+
add_custom_command(TARGET libxrf_fit POST_BUILD COMMAND strip ${PROJECT_SOURCE_DIR}/bin/libxrf_fit.so)
503+
add_custom_command(TARGET libxrf_io POST_BUILD COMMAND strip ${PROJECT_SOURCE_DIR}/bin/libxrf_io.so)
515504
ENDIF()
516505
ENDIF()
517506
ENDIF()
@@ -556,3 +545,126 @@ install(EXPORT xrfmaps-export
556545
NAMESPACE XRF_Maps::
557546
DESTINATION lib/cmake/xrfmaps
558547
)
548+
549+
# ---- Unit tests (opt-in) ----------------------------------------
550+
option(BUILD_TESTS "Build unit tests with Google Test" OFF)
551+
552+
if(BUILD_TESTS)
553+
include(CTest)
554+
enable_testing()
555+
556+
include(FetchContent)
557+
FetchContent_Declare(
558+
googletest
559+
URL https://github.com/google/googletest/archive/refs/tags/v1.15.2.zip
560+
DOWNLOAD_EXTRACT_TIMESTAMP ON
561+
)
562+
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
563+
FetchContent_MakeAvailable(googletest)
564+
565+
add_executable(test_netcdf_io test/unit/test_netcdf_io.cpp)
566+
567+
set_target_properties(test_netcdf_io PROPERTIES
568+
CXX_STANDARD 20
569+
CXX_STANDARD_REQUIRED YES
570+
CXX_EXTENSIONS NO
571+
)
572+
573+
foreach(CompilerFlag ${CompilerFlags})
574+
set_target_properties(test_netcdf_io PROPERTIES ${CompilerFlag} ${PROJECT_SOURCE_DIR}/bin)
575+
endforeach()
576+
577+
IF (APPLE)
578+
set_target_properties(test_netcdf_io PROPERTIES MACOSX_RPATH "$ORIGIN")
579+
ENDIF()
580+
581+
target_link_libraries(test_netcdf_io
582+
PRIVATE
583+
GTest::gtest_main
584+
libxrf_io
585+
libxrf_fit
586+
netCDF::netcdf
587+
${CMAKE_THREAD_LIBS_INIT}
588+
)
589+
590+
include(GoogleTest)
591+
gtest_discover_tests(test_netcdf_io)
592+
593+
add_executable(test_hdf5_io test/unit/test_hdf5_io.cpp)
594+
595+
set_target_properties(test_hdf5_io PROPERTIES
596+
CXX_STANDARD 20
597+
CXX_STANDARD_REQUIRED YES
598+
CXX_EXTENSIONS NO
599+
)
600+
601+
foreach(CompilerFlag ${CompilerFlags})
602+
set_target_properties(test_hdf5_io PROPERTIES ${CompilerFlag} ${PROJECT_SOURCE_DIR}/bin)
603+
endforeach()
604+
605+
IF (APPLE)
606+
set_target_properties(test_hdf5_io PROPERTIES MACOSX_RPATH "$ORIGIN")
607+
ENDIF()
608+
609+
target_link_libraries(test_hdf5_io
610+
PRIVATE
611+
GTest::gtest_main
612+
libxrf_io
613+
libxrf_fit
614+
hdf5::hdf5-shared
615+
${CMAKE_THREAD_LIBS_INIT}
616+
)
617+
618+
gtest_discover_tests(test_hdf5_io)
619+
620+
add_executable(test_hl_file_io test/unit/test_hl_file_io.cpp)
621+
622+
set_target_properties(test_hl_file_io PROPERTIES
623+
CXX_STANDARD 20
624+
CXX_STANDARD_REQUIRED YES
625+
CXX_EXTENSIONS NO
626+
)
627+
628+
foreach(CompilerFlag ${CompilerFlags})
629+
set_target_properties(test_hl_file_io PROPERTIES ${CompilerFlag} ${PROJECT_SOURCE_DIR}/bin)
630+
endforeach()
631+
632+
IF (APPLE)
633+
set_target_properties(test_hl_file_io PROPERTIES MACOSX_RPATH "$ORIGIN")
634+
ENDIF()
635+
636+
target_link_libraries(test_hl_file_io
637+
PRIVATE
638+
GTest::gtest_main
639+
libxrf_io
640+
libxrf_fit
641+
${CMAKE_THREAD_LIBS_INIT}
642+
)
643+
644+
gtest_discover_tests(test_hl_file_io)
645+
646+
add_executable(test_spectra test/unit/test_spectra.cpp)
647+
648+
set_target_properties(test_spectra PROPERTIES
649+
CXX_STANDARD 20
650+
CXX_STANDARD_REQUIRED YES
651+
CXX_EXTENSIONS NO
652+
)
653+
654+
foreach(CompilerFlag ${CompilerFlags})
655+
set_target_properties(test_spectra PROPERTIES ${CompilerFlag} ${PROJECT_SOURCE_DIR}/bin)
656+
endforeach()
657+
658+
IF (APPLE)
659+
set_target_properties(test_spectra PROPERTIES MACOSX_RPATH "$ORIGIN")
660+
ENDIF()
661+
662+
target_link_libraries(test_spectra
663+
PRIVATE
664+
GTest::gtest_main
665+
libxrf_fit
666+
${CMAKE_THREAD_LIBS_INIT}
667+
)
668+
669+
gtest_discover_tests(test_spectra)
670+
endif()

Compile.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,18 @@
2525

2626
## Linux HPC
2727
### Nersc Cori
28-
#### Intel Phi
2928
* module swap craype-haswell craype-mic-knl
3029
* module add gcc/9.3.0
3130
* module add netcdf/4.6.1
3231
* module add hdf5/1.10.1
3332
* mkdir build
3433
* cd build
35-
* CC=icc CXX=icpc cmake -DBUILD_FOR_PHI=ON -DEIGEN3_INCLUDES=/usr/common/software/eigen3/3.3.3/include/eigen3/ ../
34+
* CC=icc CXX=icpc cmake -DEIGEN3_INCLUDES=/usr/common/software/eigen3/3.3.3/include/eigen3/ ../
3635
* cmake --build . --config Release
3736
### ALCF Theta
38-
#### Intel Phi
3937
* module add cmake/3.18.0
4038
* module add cray-hdf5-parallel/1.10.6.0
4139
* module add cray-netcdf-hdf5parallel/4.7.3.3
4240
* mkdir build
4341
* cd build
44-
* cmake -DBUILD_FOR_PHI=ON ../
4542
* cmake --build . --config Release

src/core/defines.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ T_real parse_input_real(std::string value)
111111
}
112112
}
113113

114-
constexpr auto CALIBRATION_CURVE_SIZE = 92;
114+
constexpr auto CALIBRATION_CURVE_SIZE = 100;
115115

116116
//namespace keys
117117
//{
@@ -341,6 +341,13 @@ const std::string STR_FIT = "fit";
341341

342342
const std::string STR_CUSTOM_EL_REGION = "CUSTOM_ELEMENT_REGION";
343343

344+
const std::string STR_ABS_IC = "abs_ic";
345+
const std::string STR_ABS_CFG = "abs_cfg";
346+
const std::string STR_H_DPC_CFG = "H_dpc_cfg";
347+
const std::string STR_V_DPC_CFG = "V_dpc_cfg";
348+
const std::string STR_DIA1_DPC_CFG = "dia1_dpc_cfg";
349+
const std::string STR_DIA2_DPC_CFG = "dia2_dpc_cfg";
350+
344351
// ROI
345352
const std::string STR_MAPS_ROIS = "MAPS_ROIS";
346353
const std::string STR_MAP_ROI_NAME = "Name";

0 commit comments

Comments
 (0)