Skip to content

Commit

Permalink
Adapt cmake backend to support new datapar backend EVE
Browse files Browse the repository at this point in the history
This enables to choose datapar backend for vectorization by passing flags -DHPX_WITH_DATAPAR_BACKEND=${BACKEND}

${BACKEND} can be DATAPAR_VC OR DATAPAR_STD_EXPERIMENTAL_SIMD OR DATAPAR_EVE
  • Loading branch information
srinivasyadav18 committed Jun 17, 2022
1 parent 2a665ca commit 0acc2bf
Show file tree
Hide file tree
Showing 10 changed files with 241 additions and 23 deletions.
112 changes: 94 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -569,33 +569,84 @@ hpx_option(
# ##############################################################################
# HPX datapar configuration
# ##############################################################################
set(DATAPAR_BACKEND "NONE")
hpx_option(
HPX_WITH_DATAPAR_VC
BOOL
"Enable data parallel algorithm support using the external Vc library (default: OFF)"
OFF
ADVANCED
HPX_WITH_DATAPAR_BACKEND
STRING
"Define which vectorization library should be used. Options are: DATAPAR_VC, DATAPAR_EVE, DATAPAR_STD_EXPERIMENTAL_SIMD"
${DATAPAR_BACKEND}
STRINGS "DATAPAR_VC;DATAPAR_EVE;DATAPAR_STD_EXPERIMENTAL_SIMD"
)
if(HPX_WITH_DATAPAR_VC)

# ##############################################################################
# HPX Vc configuration
# ##############################################################################
if ("${HPX_WITH_DATAPAR_BACKEND}" STREQUAL "DATAPAR_VC")
hpx_option(
HPX_WITH_DATAPAR_VC_NO_LIBRARY BOOL
"Don't link with the Vc static library (default: OFF)" OFF ADVANCED
HPX_WITH_DATAPAR_VC
BOOL
"Enable data parallel algorithm support using the external Vc library (default: ON)"
ON
ADVANCED
)
if(HPX_WITH_DATAPAR_VC)
hpx_option(
HPX_WITH_DATAPAR_VC_NO_LIBRARY BOOL
"Don't link with the Vc static library (default: OFF)" OFF ADVANCED
)
endif()

if(HPX_WITH_DATAPAR_VC)
hpx_warn(
"Vc support is deprecated. This option will be removed in a future release. It will be replaced with SIMD support from the C++ standard library"
)
include(HPX_SetupVc)
hpx_option(
HPX_WITH_DATAPAR BOOL
"Enable data parallel algorithm support using Vc library (default: ON)" ON ADVANCED
)
endif()
endif()

if(HPX_WITH_DATAPAR_VC)
hpx_warn(
"Vc support is deprecated. This option will be removed in a future release. It will be replaced with SIMD support from the C++ standard library"
# ##############################################################################
# HPX Eve configuration
# ##############################################################################
if ("${HPX_WITH_DATAPAR_BACKEND}" STREQUAL "DATAPAR_EVE")
hpx_option(
HPX_WITH_DATAPAR_EVE
BOOL
"Use Eve as datapar library (default: ON)"
ON
CATEGORY "Build Targets"
ADVANCED
)
include(HPX_SetupVc)
endif()
if(NOT HPX_WITH_DATAPAR_VC)
hpx_info("No vectorization library configured")
else()
hpx_option(
HPX_WITH_DATAPAR BOOL
"Enable data parallel algorithm support (default: ON)" ON ADVANCED
HPX_WITH_FETCH_DATAPAR_EVE
BOOL
"Use FetchContent to fetch Eve. By default an installed Eve will be used. (default: OFF)"
OFF
CATEGORY "Build Targets"
ADVANCED
)
hpx_option(
HPX_WITH_DATAPAR_EVE_TAG STRING "Eve repository tag or branch" "develop"
CATEGORY "Build Targets"
ADVANCED
)

if (HPX_WITH_DATAPAR_EVE)
if(HPX_WITH_FETCH_DATAPAR_EVE)
include(HPX_SetupEve)
else()
find_package(Eve)
endif()
hpx_option(
HPX_WITH_DATAPAR BOOL
"Enable data parallel algorithm support using Eve library (default: ON)" ON ADVANCED
)
hpx_add_config_define(HPX_HAVE_DATAPAR_EVE)
hpx_add_config_define(HPX_HAVE_DATAPAR)
endif()
endif()

# ##############################################################################
Expand Down Expand Up @@ -2051,6 +2102,31 @@ if(HPX_ITERATOR_SUPPORT_WITH_BOOST_ITERATOR_TRAVERSAL_TAG_COMPATIBILITY)
)
endif()

if ("${HPX_WITH_DATAPAR_BACKEND}" STREQUAL "DATAPAR_STD_EXPERIMENTAL_SIMD")
if (HPX_WITH_CXX20_EXPERIMENTAL_SIMD)
hpx_option(
HPX_WITH_DATAPAR_STD_EXPERIMENTAL_SIMD
BOOL
"Use STD_EXPERIMENTAL_SIMD as datapar library (default: ON)"
ON
CATEGORY "Build Targets"
ADVANCED
)
hpx_option(
HPX_WITH_DATAPAR BOOL
"Enable data parallel algorithm support using std experimental/simd (default: ON)" ON ADVANCED
)
hpx_add_config_define(HPX_HAVE_DATAPAR_STD_EXPERIMENTAL_SIMD)
hpx_add_config_define(HPX_HAVE_DATAPAR)
else()
hpx_error("Could not find std experimental/simd. Use CXX COMPILER GCC 11 OR CLANG 12 AND ABOVE ")
endif()
endif()

if (HPX_WITH_DATAPAR)
hpx_info("Using datapar backend: ${HPX_WITH_DATAPAR_BACKEND}")
endif()

# ##############################################################################
# Find Our dependencies: These are all dependencies needed to build the core
# library. Dependencies that are only needed by plugins, examples or tests
Expand Down
61 changes: 61 additions & 0 deletions cmake/FindEve.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright (c) 2022 Srinivas Yadav
#
# SPDX-License-Identifier: BSL-1.0
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

if(NOT TARGET Eve::eve)
find_path(
EVE_INCLUDE_DIR eve/eve.hpp
HINTS "${EVE_ROOT}" ENV EVE_ROOT "${HPX_EVE_ROOT}"
PATH_SUFFIXES include
)

if(NOT EVE_INCLUDE_DIR)
hpx_error(
"Could not find Eve. Set EVE_ROOT as a CMake or environment variable to point to the Eve root install directory. Alternatively, set HPX_WITH_FETCH_DATAPAR_EVE=ON to fetch Eve using CMake's FetchContent (when using this option Eve will be installed together with HPX, be careful about conflicts with separately installed versions of Eve)."
)
endif()

# Set EVE_ROOT in case the other hints are used
if(EVE_ROOT)
# The call to file is for compatibility with windows paths
file(TO_CMAKE_PATH ${EVE_ROOT} EVE_ROOT)
elseif("$ENV{EVE_ROOT}")
file(TO_CMAKE_PATH $ENV{EVE_ROOT} EVE_ROOT)
else()
file(TO_CMAKE_PATH "${EVE_INCLUDE_DIR}" EVE_INCLUDE_DIR)
string(REPLACE "/include" "" EVE_ROOT "${EVE_INCLUDE_DIR}")
endif()

if(EVE_INCLUDE_DIR AND EXISTS "${EVE_INCLUDE_DIR}/eve/version.hpp")
# Matches a line of the form:
#
# #define EVE_VERSION "AA.BB.CC.DD"
#
# with arbitrary whitespace between the tokens
file(
STRINGS "${EVE_INCLUDE_DIR}/eve/version.hpp" EVE_VERSION_DEFINE_LINE
REGEX
"#define[ \t]+EVE_LIB_VERSION[ \t]+\"+[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\"[ \t]*"
)
# Extracts the dotted version number in quotation marks as
# EVE_VERSION_STRING
string(REGEX
REPLACE "#define EVE_LIB_VERSION \"([0-9]+\.[0-9]+\.[0-9]+\.[0-9])\""
"\\1" EVE_VERSION_STRING "${EVE_VERSION_DEFINE_LINE}"
)
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
Eve
REQUIRED_VARS EVE_INCLUDE_DIR
VERSION_VAR EVE_VERSION_STRING
)

add_library(Eve::eve INTERFACE IMPORTED)
target_include_directories(Eve::eve SYSTEM INTERFACE ${EVE_INCLUDE_DIR})

mark_as_advanced(EVE_ROOT EVE_INCLUDE_DIR EVE_VERSION_STRING)
endif()
2 changes: 1 addition & 1 deletion cmake/HPX_PerformCxxFeatureTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function(hpx_perform_cxx_feature_tests)
hpx_check_for_cxx20_coroutines(DEFINITIONS HPX_HAVE_CXX20_COROUTINES)

hpx_check_for_cxx20_experimental_simd(
DEFINITIONS HPX_HAVE_CXX20_EXPERIMENTAL_SIMD HPX_HAVE_DATAPAR
DEFINITIONS HPX_HAVE_CXX20_EXPERIMENTAL_SIMD
)

hpx_check_for_cxx20_lambda_capture(
Expand Down
66 changes: 66 additions & 0 deletions cmake/HPX_SetupEve.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Copyright (c) 2022 Srinivas Yadav
#
# SPDX-License-Identifier: BSL-1.0
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

if(HPX_WITH_FETCH_DATAPAR_EVE)
if(FETCHCONTENT_SOURCE_DIR_EVE)
hpx_info(
"HPX_WITH_FETCH_DATAPAR_EVE=${HPX_WITH_FETCH_DATAPAR_EVE}, EVE will be used through CMake's FetchContent and installed alongside HPX (FETCHCONTENT_SOURCE_DIR_EVE=${FETCHCONTENT_SOURCE_DIR_EVE})"
)
else()
hpx_info(
"HPX_WITH_FETCH_DATAPAR_EVE=${HPX_WITH_FETCH_DATAPAR_EVE}, EVE will be fetched using CMake's FetchContent and installed alongside HPX (HPX_WITH_DATAPAR_EVE_TAG=${HPX_WITH_DATAPAR_EVE_TAG})"
)
endif()
include(FetchContent)
FetchContent_Declare(
eve
GIT_REPOSITORY https://github.com/jfalcou/eve.git
GIT_TAG ${HPX_WITH_DATAPAR_EVE_TAG}
)

fetchcontent_getproperties(eve)
if(NOT eve_POPULATED)
fetchcontent_populate(eve)
endif()
set(EVE_ROOT ${eve_SOURCE_DIR})

add_library(eve INTERFACE)
target_include_directories(
eve SYSTEM INTERFACE $<BUILD_INTERFACE:${EVE_ROOT}/include/>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

install(
TARGETS eve
EXPORT HPXEveTarget
COMPONENT core
)

install(
DIRECTORY ${EVE_ROOT}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT core
FILES_MATCHING
PATTERN "*.hpp"
PATTERN "*.ipp"
)

export(
TARGETS eve
NAMESPACE Eve::
FILE "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/${HPX_PACKAGE_NAME}/HPXEveTarget.cmake"
)

install(
EXPORT HPXEveTarget
NAMESPACE Eve::
FILE HPXEveTarget.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${HPX_PACKAGE_NAME}
)

add_library(Eve::eve ALIAS eve)

endif()
11 changes: 11 additions & 0 deletions cmake/templates/HPXConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ else()
endif()
endif()

# Eve can be installed by HPX or externally installed. In the first case we use
# exported targets, in the second we find Eve again using find_package.
if("${HPX_WITH_DATAPAR_BACKEND}" STREQUAL "DATAPAR_EVE")
if(HPX_WITH_FETCH_DATAPAR_EVE)
include("${CMAKE_CURRENT_LIST_DIR}/HPXEveTarget.cmake")
else()
set(HPX_EVE_ROOT "@EVE_ROOT@")
include(HPX_SetupEVE)
endif()
endif()

include("${CMAKE_CURRENT_LIST_DIR}/HPXInternalTargets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/HPXTargets.cmake")

Expand Down
4 changes: 4 additions & 0 deletions libs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ if(HPX_WITH_DATAPAR_VC)
target_link_libraries(hpx_core PUBLIC Vc::vc)
endif()

if(HPX_WITH_DATAPAR_EVE)
target_link_libraries(hpx_core PUBLIC Eve::eve)
endif()

if(HPX_WITH_ITTNOTIFY)
target_link_libraries(hpx_core PUBLIC Amplifier::amplifier)
endif()
Expand Down
2 changes: 1 addition & 1 deletion libs/core/algorithms/tests/regressions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ set(tests
ranges_facilities
)

if(HPX_WITH_DATAPAR_VC OR HPX_WITH_CXX20_EXPERIMENTAL_SIMD)
if(HPX_WITH_DATAPAR)
list(APPEND tests for_each_datapar)
endif()

Expand Down
2 changes: 1 addition & 1 deletion libs/core/algorithms/tests/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# add subdirectories
set(subdirs algorithms block container_algorithms)

if(HPX_WITH_DATAPAR_VC OR HPX_WITH_CXX20_EXPERIMENTAL_SIMD)
if(HPX_WITH_DATAPAR)
set(subdirs ${subdirs} datapar_algorithms)
endif()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

set(tests)

if(HPX_WITH_DATAPAR_VC OR HPX_WITH_CXX20_EXPERIMENTAL_SIMD)
if(HPX_WITH_DATAPAR)
set(tests
${tests}
adjacentfind_datapar
Expand Down
2 changes: 1 addition & 1 deletion tests/performance/local/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if(HPX_WITH_LIBCDS)
set(libcds_hazard_pointer_overhead_FLAGS DEPENDENCIES iostreams_component)
endif()

if(HPX_WITH_CXX20_EXPERIMENTAL_SIMD OR HPX_WITH_DATAPAR_VC)
if(HPX_WITH_DATAPAR)
list(APPEND benchmarks transform_reduce_binary_scaling)
set(transform_reduce_binary_scaling_FLAGS DEPENDENCIES iostreams_component)
endif()
Expand Down

0 comments on commit 0acc2bf

Please sign in to comment.