Commit 5e841bfe authored by Richard Berger's avatar Richard Berger
Browse files

Added USER-OMP support to CMake build

parent b8597950
Loading
Loading
Loading
Loading
+26 −2
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ foreach(PKG ${PACKAGES})
  option(ENABLE_${PKG} "Build ${PKG} Package" OFF)
endforeach()

set(ACCEL_PACKAGES USER-OMP)
set(ACCEL_PACKAGES USER_OMP)
foreach(PKG ${ACCEL_PACKAGES})
  option(ENABLE_${PKG} "Build ${PKG} Package" OFF)
endforeach()
@@ -139,7 +139,31 @@ endforeach()
# packages which selectively include variants based on enabled styles
# e.g. accelerator packages

# TODO
if(ENABLE_USER_OMP)
    find_package(OpenMP REQUIRED)
    if (OPENMP_FOUND)
        set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
        set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
    else()
        message(FATAL_ERROR "USER-OMP requires a compiler with OpenMP support")
    endif()

    set(USER_OMP_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/USER-OMP)
    set(USER_OMP_SOURCES ${USER_OMP_SOURCES_DIR}/thr_data.cpp
                         ${USER_OMP_SOURCES_DIR}/thr_omp.cpp
                         ${USER_OMP_SOURCES_DIR}/fix_nh_omp.cpp
                         ${USER_OMP_SOURCES_DIR}/fix_nh_sphere_omp.cpp)
    set_property(GLOBAL PROPERTY "OMP_SOURCES" "${USER_OMP_SOURCES}")

    # detects styles which have USER-OMP version
    RegisterStylesExt(${USER_OMP_SOURCES_DIR} omp OMP_SOURCES)

    get_property(USER_OMP_SOURCES GLOBAL PROPERTY OMP_SOURCES)

    list(APPEND LIB_SOURCES ${USER_OMP_SOURCES})
    include_directories(${USER_OMP_SOURCES_DIR})
endif()


if(ENABLE_REAX)
  enable_language(Fortran)
+50 −0
Original line number Diff line number Diff line
@@ -11,6 +11,33 @@ function(FindStyleHeaders path style_class file_pattern headers)
    set_property(GLOBAL PROPERTY ${headers} "${hlist}")
endfunction(FindStyleHeaders)

function(FindStyleHeadersExt path style_class extension headers sources)
    get_property(hlist GLOBAL PROPERTY ${headers})
    get_property(slist GLOBAL PROPERTY ${sources})
    set(ext_list)
    get_filename_component(abs_path "${path}" ABSOLUTE)

    foreach(file_name ${hlist})
        get_filename_component(basename ${file_name} NAME_WE)
        set(ext_file_name "${abs_path}/${basename}_${extension}.h")
        if(EXISTS "${ext_file_name}")
            file(STRINGS ${ext_file_name} is_style LIMIT_COUNT 1 REGEX ${style_class})
            if(is_style)
                list(APPEND ext_list ${ext_file_name})

                set(source_file_name "${abs_path}/${basename}_${extension}.cpp")
                if(EXISTS "${source_file_name}")
                    list(APPEND slist ${source_file_name})
                endif()
            endif()
        endif()
    endforeach()

    list(APPEND hlist ${ext_list})
    set_property(GLOBAL PROPERTY ${headers} "${hlist}")
    set_property(GLOBAL PROPERTY ${sources} "${slist}")
endfunction(FindStyleHeadersExt)

function(CreateStyleHeader path filename)
    math(EXPR N "${ARGC}-2")

@@ -57,6 +84,29 @@ function(RegisterStyles search_path)
    FindStyleHeaders(${search_path} REGION_CLASS    region_    REGION    ) # region    ) # domain
endfunction(RegisterStyles)

function(RegisterStylesExt search_path extension sources)
    FindStyleHeadersExt(${search_path} ANGLE_CLASS     ${extension}  ANGLE     ${sources})
    FindStyleHeadersExt(${search_path} ATOM_CLASS      ${extension}  ATOM_VEC  ${sources})
    FindStyleHeadersExt(${search_path} BODY_CLASS      ${extension}  BODY      ${sources})
    FindStyleHeadersExt(${search_path} BOND_CLASS      ${extension}  BOND      ${sources})
    FindStyleHeadersExt(${search_path} COMMAND_CLASS   ${extension}  COMMAND   ${sources})
    FindStyleHeadersExt(${search_path} COMPUTE_CLASS   ${extension}  COMPUTE   ${sources})
    FindStyleHeadersExt(${search_path} DIHEDRAL_CLASS  ${extension}  DIHEDRAL  ${sources})
    FindStyleHeadersExt(${search_path} DUMP_CLASS      ${extension}  DUMP      ${sources})
    FindStyleHeadersExt(${search_path} FIX_CLASS       ${extension}  FIX       ${sources})
    FindStyleHeadersExt(${search_path} IMPROPER_CLASS  ${extension}  IMPROPER  ${sources})
    FindStyleHeadersExt(${search_path} INTEGRATE_CLASS ${extension}  INTEGRATE ${sources})
    FindStyleHeadersExt(${search_path} KSPACE_CLASS    ${extension}  KSPACE    ${sources})
    FindStyleHeadersExt(${search_path} MINIMIZE_CLASS  ${extension}  MINIMIZE  ${sources})
    FindStyleHeadersExt(${search_path} NBIN_CLASS      ${extension}  NBIN      ${sources})
    FindStyleHeadersExt(${search_path} NPAIR_CLASS     ${extension}  NPAIR     ${sources})
    FindStyleHeadersExt(${search_path} NSTENCIL_CLASS  ${extension}  NSTENCIL  ${sources})
    FindStyleHeadersExt(${search_path} NTOPO_CLASS     ${extension}  NTOPO     ${sources})
    FindStyleHeadersExt(${search_path} PAIR_CLASS      ${extension}  PAIR      ${sources})
    FindStyleHeadersExt(${search_path} READER_CLASS    ${extension}  READER    ${sources})
    FindStyleHeadersExt(${search_path} REGION_CLASS    ${extension}  REGION    ${sources})
endfunction(RegisterStylesExt)

function(GenerateStyleHeaders output_path)
    GenerateStyleHeader(${output_path} ANGLE      angle     ) # force
    GenerateStyleHeader(${output_path} ATOM_VEC   atom      ) # atom      atom_vec_hybrid