Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions openmp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
# Add path for custom modules
list(INSERT CMAKE_MODULE_PATH 0
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
"${LLVM_COMMON_CMAKE_UTILS}/Modules"
)

Expand Down Expand Up @@ -95,6 +96,25 @@ endif()
# Check and set up common compiler flags.
include(config-ix)
include(HandleOpenMPOptions)
include(LibompUtils)
include(LibompHandleFlags)


# Set libomp version
set(LIBOMP_VERSION_MAJOR 5)
set(LIBOMP_VERSION_MINOR 0)

# Set the OpenMP Year and Month associated with version
set(LIBOMP_OMP_YEAR_MONTH 201611)

# Get the build number from kmp_version.cpp
libomp_get_build_number("${CMAKE_CURRENT_SOURCE_DIR}/runtime" LIBOMP_VERSION_BUILD)
math(EXPR LIBOMP_VERSION_BUILD_YEAR "${LIBOMP_VERSION_BUILD}/10000")
math(EXPR LIBOMP_VERSION_BUILD_MONTH_DAY "${LIBOMP_VERSION_BUILD}%10000")

# Currently don't record any timestamps
set(LIBOMP_BUILD_DATE "No_Timestamp")


# Check for flang
set(OPENMP_TEST_Fortran_COMPILER_default "")
Expand All @@ -104,6 +124,9 @@ endif ()
set(OPENMP_TEST_Fortran_COMPILER "${OPENMP_TEST_Fortran_COMPILER_default}" CACHE STRING
"Fortran compiler to use for testing OpenMP runtime libraries.")

set(LIBOMP_FORTRAN_MODULES FALSE CACHE BOOL
"Create Fortran module files? (requires fortran compiler)")

# Set up testing infrastructure.
include(OpenMPTesting)

Expand Down Expand Up @@ -139,6 +162,8 @@ if("${LLVM_DEFAULT_TARGET_TRIPLE}" MATCHES "^amdgcn|^nvptx" OR
"${CMAKE_CXX_COMPILER_TARGET}" MATCHES "^amdgcn|^nvptx")
add_subdirectory(device)
else()
add_subdirectory(module)

# Build host runtime library, after LIBOMPTARGET variables are set since they
# are needed to enable time profiling support in the OpenMP runtime.
add_subdirectory(runtime)
Expand Down
76 changes: 76 additions & 0 deletions openmp/module/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#//===----------------------------------------------------------------------===//
#//
#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
#// See https://llvm.org/LICENSE.txt for license information.
#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#//
#//===----------------------------------------------------------------------===//

include(LibompCheckFortranFlag)

set(LIBOMP_FFLAGS "" CACHE STRING
"Appended user specified Fortran compiler flags. These are only used if LIBOMP_FORTRAN_MODULES==TRUE.")

# Enabling Fortran if it is needed
if (LIBOMP_FORTRAN_MODULES)
enable_language(Fortran)

libomp_check_fortran_flag(-m32 LIBOMP_HAVE_M32_FORTRAN_FLAG)
endif ()

# Building the Fortran module files
# One compilation step creates both omp_lib.mod and omp_lib_kinds.mod
configure_file(omp_lib.F90.var omp_lib.F90 @ONLY)
configure_file(omp_lib.h.var "${CMAKE_CURRENT_BINARY_DIR}/../runtime/src/omp_lib.h" @ONLY)

set(BUILD_FORTRAN_MODULES False)
if (LIBOMP_FORTRAN_MODULES_COMPILER)
# If libomp is built as an LLVM runtime and the flang compiler is available,
# compile the Fortran module files.
message(STATUS "configuring openmp to build Fortran module files using '${LIBOMP_FORTRAN_MODULES_COMPILER}'")
set(LIBOMP_FORTRAN_SOURCE_FILE omp_lib.F90)
add_custom_target(libomp-mod ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/../runtime/src/omp_lib.mod" "${CMAKE_CURRENT_BINARY_DIR}/../runtime/src/omp_lib_kinds.mod")
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/../runtime/src/omp_lib.mod" "${CMAKE_CURRENT_BINARY_DIR}/../runtime/src/omp_lib_kinds.mod"
COMMAND ${LIBOMP_FORTRAN_MODULES_COMPILER} -cpp -fsyntax-only ${LIBOMP_FORTRAN_SOURCE_FILE} "-J${CMAKE_CURRENT_BINARY_DIR}/../runtime/src"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${LIBOMP_FORTRAN_SOURCE_FILE}"
)
set(BUILD_FORTRAN_MODULES True)
elseif (LIBOMP_FORTRAN_MODULES)
# The following requests explicit building of the Fortran module files
# Workaround for gfortran to build modules with the
# omp_sched_monotonic integer parameter
if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
set(ADDITIONAL_Fortran_FLAGS "-fno-range-check")
endif ()
add_custom_target(libomp-mod ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/../runtime/src/omp_lib.mod" "${CMAKE_CURRENT_BINARY_DIR}/../runtime/src/omp_lib_kinds.mod")
set_target_properties(libomp-mod PROPERTIES FOLDER "OpenMP/Misc")
libomp_get_fflags(LIBOMP_CONFIGURED_FFLAGS)
if (CMAKE_Fortran_COMPILER_SUPPORTS_F90)
set(LIBOMP_FORTRAN_SOURCE_FILE omp_lib.F90)
else ()
message(FATAL_ERROR "Fortran module build requires Fortran 90 compiler")
endif ()
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/../runtime/src/omp_lib.mod" "${CMAKE_CURRENT_BINARY_DIR}/../runtime/src/omp_lib_kinds.mod"
COMMAND ${CMAKE_Fortran_COMPILER} -c ${ADDITIONAL_Fortran_FLAGS}
${LIBOMP_CONFIGURED_FFLAGS} ${LIBOMP_FORTRAN_SOURCE_FILE} "-J${CMAKE_CURRENT_BINARY_DIR}/../runtime/src"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${LIBOMP_FORTRAN_SOURCE_FILE}"
)
set_property(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../runtime/src" PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "omp_lib${CMAKE_C_OUTPUT_EXTENSION}")
set(BUILD_FORTRAN_MODULES True)
endif ()


if (BUILD_FORTRAN_MODULES)
set(destination "${LIBOMP_HEADERS_INSTALL_PATH}")
if (LIBOMP_MODULES_INSTALL_PATH)
set(destination "${LIBOMP_MODULES_INSTALL_PATH}")
endif ()
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/../runtime/src/omp_lib.mod"
"${CMAKE_CURRENT_BINARY_DIR}/../runtime/src/omp_lib_kinds.mod"
"${CMAKE_CURRENT_BINARY_DIR}/../runtime/src/omp_lib.h"
DESTINATION ${destination}
)
endif ()
File renamed without changes.
25 changes: 1 addition & 24 deletions openmp/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,8 @@ endif()
# Add cmake directory to search for custom cmake functions
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})

# Set libomp version
set(LIBOMP_VERSION_MAJOR 5)
set(LIBOMP_VERSION_MINOR 0)

# These include files are in the cmake/ subdirectory
include(LibompUtils)
include(LibompGetArchitecture)
include(LibompHandleFlags)
include(LibompDefinitions)

# Determine the target architecture
Expand Down Expand Up @@ -102,15 +96,12 @@ libomp_check_variable(LIBOMP_ARCH 32e x86_64 32 i386 arm ppc ppc64 ppc64le aarch
set(LIBOMP_LIB_TYPE normal CACHE STRING
"Performance,Profiling,Stubs library (normal/profile/stubs)")
libomp_check_variable(LIBOMP_LIB_TYPE normal profile stubs)
# Set the OpenMP Year and Month associated with version
set(LIBOMP_OMP_YEAR_MONTH 201611)
set(LIBOMP_MIC_ARCH knc CACHE STRING
"Intel(R) Many Integrated Core Architecture (Intel(R) MIC Architecture) (knf/knc). Ignored if not Intel(R) MIC Architecture build.")
if("${LIBOMP_ARCH}" STREQUAL "mic")
libomp_check_variable(LIBOMP_MIC_ARCH knf knc)
endif()
set(LIBOMP_FORTRAN_MODULES FALSE CACHE BOOL
"Create Fortran module files? (requires fortran compiler)")


# - Support for universal fat binary builds on Mac
# - Having this extra variable allows people to build this library as a universal library
Expand Down Expand Up @@ -147,8 +138,6 @@ else()
set(LIBOMP_LIBFLAGS "" CACHE STRING
"Appended user specified linked libs flags. (e.g., -lm)")
endif()
set(LIBOMP_FFLAGS "" CACHE STRING
"Appended user specified Fortran compiler flags. These are only used if LIBOMP_FORTRAN_MODULES==TRUE.")

# Should the libomp library and generated headers be copied into the original source exports/ directory
# Turning this to FALSE aids parallel builds to not interfere with each other.
Expand All @@ -163,14 +152,6 @@ set(LIBOMP_USE_HWLOC FALSE CACHE BOOL
set(LIBOMP_HWLOC_INSTALL_DIR /usr/local CACHE PATH
"Install path for hwloc library")

# Get the build number from kmp_version.cpp
libomp_get_build_number("${CMAKE_CURRENT_SOURCE_DIR}" LIBOMP_VERSION_BUILD)
math(EXPR LIBOMP_VERSION_BUILD_YEAR "${LIBOMP_VERSION_BUILD}/10000")
math(EXPR LIBOMP_VERSION_BUILD_MONTH_DAY "${LIBOMP_VERSION_BUILD}%10000")

# Currently don't record any timestamps
set(LIBOMP_BUILD_DATE "No_Timestamp")

# Architecture
set(IA32 FALSE)
set(INTEL64 FALSE)
Expand Down Expand Up @@ -272,10 +253,6 @@ set(LIBOMP_TOOLS_DIR ${LIBOMP_BASE_DIR}/tools)
set(LIBOMP_INC_DIR ${LIBOMP_SRC_DIR}/include)
set(LIBOMP_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})

# Enabling Fortran if it is needed
if(${LIBOMP_FORTRAN_MODULES})
enable_language(Fortran)
endif()
# Enable MASM Compiler if it is needed (Windows only)
if(WIN32)
enable_language(ASM_MASM)
Expand Down
5 changes: 4 additions & 1 deletion openmp/runtime/cmake/LibompExports.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,14 @@ if(${LIBOMP_OMPT_SUPPORT})
)
endif()
if(${LIBOMP_FORTRAN_MODULES})
add_custom_command(TARGET libomp-mod POST_BUILD
# We cannot attach a POST_BUILD command to libomp-mod, so instead attach it
# to omp and ensure that libomp-mod is built before by adding a dependency
add_custom_command(TARGET omp POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBOMP_EXPORTS_MOD_DIR}
COMMAND ${CMAKE_COMMAND} -E copy omp_lib.mod ${LIBOMP_EXPORTS_MOD_DIR}
COMMAND ${CMAKE_COMMAND} -E copy omp_lib_kinds.mod ${LIBOMP_EXPORTS_MOD_DIR}
)
add_dependencies(omp libomp-mod)
add_custom_command(TARGET omp POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy omp_lib.h ${LIBOMP_EXPORTS_CMN_DIR}
)
Expand Down
4 changes: 0 additions & 4 deletions openmp/runtime/cmake/config-ix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ include(CheckIncludeFile)
include(CheckLibraryExists)
include(CheckIncludeFiles)
include(CheckSymbolExists)
include(LibompCheckFortranFlag)
include(LLVMCheckCompilerLinkerFlag)

# Check for versioned symbols
Expand Down Expand Up @@ -97,9 +96,6 @@ if(WIN32)
endforeach()
endforeach()
endif()
if(${LIBOMP_FORTRAN_MODULES})
libomp_check_fortran_flag(-m32 LIBOMP_HAVE_M32_FORTRAN_FLAG)
endif()

# Check non-posix pthread API here before CMAKE_REQUIRED_DEFINITIONS gets messed up
check_symbol_exists(pthread_setname_np "pthread.h" LIBOMP_HAVE_PTHREAD_SETNAME_NP)
Expand Down
57 changes: 0 additions & 57 deletions openmp/runtime/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -377,51 +377,6 @@ if(WIN32)
endif()
endif()

# Building the Fortran module files
# One compilation step creates both omp_lib.mod and omp_lib_kinds.mod
configure_file(${LIBOMP_INC_DIR}/omp_lib.h.var omp_lib.h @ONLY)
configure_file(${LIBOMP_INC_DIR}/omp_lib.F90.var omp_lib.F90 @ONLY)

set(BUILD_FORTRAN_MODULES False)
if (NOT ${LIBOMP_FORTRAN_MODULES_COMPILER} STREQUAL "")
# If libomp is built as an LLVM runtime and the flang compiler is available,
# compile the Fortran module files.
message(STATUS "configuring openmp to build Fortran module files using ${LIBOMP_FORTRAN_MODULES_COMPILER}")
set(LIBOMP_FORTRAN_SOURCE_FILE omp_lib.F90)
add_custom_target(libomp-mod ALL DEPENDS omp_lib.mod omp_lib_kinds.mod)
add_custom_command(
OUTPUT omp_lib.mod omp_lib_kinds.mod
COMMAND ${LIBOMP_FORTRAN_MODULES_COMPILER} -cpp -fsyntax-only ${LIBOMP_FORTRAN_SOURCE_FILE}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${LIBOMP_FORTRAN_SOURCE_FILE}
${CMAKE_CURRENT_BINARY_DIR}/omp_lib.h
)
set(BUILD_FORTRAN_MODULES True)
elseif(${LIBOMP_FORTRAN_MODULES})
# The following requests explicit building of the Fortran module files
# Workaround for gfortran to build modules with the
# omp_sched_monotonic integer parameter
if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
set(ADDITIONAL_Fortran_FLAGS "-fno-range-check")
endif()
add_custom_target(libomp-mod ALL DEPENDS omp_lib.mod omp_lib_kinds.mod)
set_target_properties(libomp-mod PROPERTIES FOLDER "OpenMP/Misc")
libomp_get_fflags(LIBOMP_CONFIGURED_FFLAGS)
if(CMAKE_Fortran_COMPILER_SUPPORTS_F90)
set(LIBOMP_FORTRAN_SOURCE_FILE omp_lib.F90)
else()
message(FATAL_ERROR "Fortran module build requires Fortran 90 compiler")
endif()
add_custom_command(
OUTPUT omp_lib.mod omp_lib_kinds.mod
COMMAND ${CMAKE_Fortran_COMPILER} -c ${ADDITIONAL_Fortran_FLAGS}
${LIBOMP_CONFIGURED_FFLAGS} ${LIBOMP_FORTRAN_SOURCE_FILE}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${LIBOMP_FORTRAN_SOURCE_FILE}
${CMAKE_CURRENT_BINARY_DIR}/omp_lib.h
)
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES omp_lib${CMAKE_C_OUTPUT_EXTENSION})
set(BUILD_FORTRAN_MODULES True)
endif()

# Move files to exports/ directory if requested
if(${LIBOMP_COPY_EXPORTS})
include(LibompExports)
Expand Down Expand Up @@ -502,15 +457,3 @@ if(${LIBOMP_OMPT_SUPPORT})
install(FILES ${LIBOMP_HEADERS_INTDIR}/omp-tools.h DESTINATION ${LIBOMP_HEADERS_INSTALL_PATH} RENAME ompt.h)
set(LIBOMP_OMP_TOOLS_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
endif()
if(${BUILD_FORTRAN_MODULES})
set (destination ${LIBOMP_HEADERS_INSTALL_PATH})
if (NOT ${LIBOMP_MODULES_INSTALL_PATH} STREQUAL "")
set (destination ${LIBOMP_MODULES_INSTALL_PATH})
endif()
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/omp_lib.h
${CMAKE_CURRENT_BINARY_DIR}/omp_lib.mod
${CMAKE_CURRENT_BINARY_DIR}/omp_lib_kinds.mod
DESTINATION ${destination}
)
endif()
Loading