Skip to content

Commit

Permalink
Merge 617f524 into 962288c
Browse files Browse the repository at this point in the history
  • Loading branch information
Johan511 authored Aug 29, 2023
2 parents 962288c + 617f524 commit b60c175
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 0 deletions.
31 changes: 31 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,37 @@ hpx_option(
ADVANCED
)

hpx_option(
HPX_WITH_FETCH_SIMD_SORT
BOOL
"Use FetchContent to fetch x86-simd-sort. By default an installed x86-simd-sort will be used. (default: On). It has support only for AVX-512 registers. If the architecture has no AVX-512 registers, simd-sort won't be used"
ON
CATEGORY "Build Targets"
ADVANCED
)
hpx_option(
HPX_WITH_SIMD_SORT_TAG STRING "x86-simd-sort repository tag or branch" "v2.0"
CATEGORY "Build Targets"
ADVANCED
)

# simd sort supports only avx-512 registers
if(__AVX512F__)
set(HPX_WITH_SIMD_SORT ON)
if(HPX_WITH_FETCH_SIMD_SORT)
include(HPX_SetupSimdSort)
else()
find_package(SimdSort)
endif()
else()
set(HPX_WITH_SIMD_SORT OFF)
set(HPX_WITH_FETCH_SIMD_SORT OFF)
endif()

# debug message to be removed before merge
message(WARNING "HPX_WITH_SIMD_SORT : ${HPX_WITH_SIMD_SORT}")
message(WARNING "HPX_WITH_FETCH_SIMD_SORT : ${HPX_WITH_FETCH_SIMD_SORT}")

# ##############################################################################
# HPX CUDA configuration
# ##############################################################################
Expand Down
42 changes: 42 additions & 0 deletions cmake/FindSimdSort.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright (c) 2023 Hari Hara Naveen S
#
# 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 SimdSort::simdsort)
find_path(SIMD_SORT_INCLUDE_DIR avx512-16bit-qsort.hpp
HINTS "${SIMD_SORT_ROOT}" ENV SIMD_SORT_ROOT
"${HPX_SIMD_SORT_ROOT}"
)

if(NOT SIMD_SORT_INCLUDE_DIR)
hpx_error("Simd Sort not found")
endif()

if(SIMD_SORT)
# The call to file is for compatibility with windows paths
file(TO_CMAKE_PATH ${SIMD_SORT} SIMD_SORT)
elseif("$ENV{SIMD_SORT}")
file(TO_CMAKE_PATH $ENV{SIMD_SORT} SIMD_SORT)
else()
file(TO_CMAKE_PATH "${SIMD_SORT_INCLUDE_DIR}" SIMD_SORT_INCLUDE_DIR)
string(REPLACE "/src" "" SIMD_SORT_ROOT "${SIMD_SORT_INCLUDE_DIR}")
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
SimdSort
REQUIRED_VARS SIMD_SORT_INCLUDE_DIR
VERSION_VAR SIMD_SORT_VERSION_STRING
)

add_library(SimdSort::simdsort INTERFACE IMPORTED)
target_include_directories(
SimdSort::simdsort SYSTEM INTERFACE ${SIMD_SORT_INCLUDE_DIR}
)

mark_as_advanced(
SIMD_SORT_ROOT SIMD_SORT_INCLUDE_DIR SIMD_SORT_VERSION_STRING
)
endif()
67 changes: 67 additions & 0 deletions cmake/HPX_SetupSimdSort.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Copyright (c) 2023 Hari Hara Naveen S
#
# 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_SIMD_SORT)
if(FETCHCONTENT_SOURCE_DIR_SIMD_SORT)
hpx_info(
"HPX_WITH_FETCH_SIMD_SORT=${HPX_WITH_FETCH_SIMD_SORT}, x86-simd-sort will be used through CMake's FetchContent and installed alongside HPX (FETCHCONTENT_SOURCE_DIR_SIMD_SORT=${FETCHCONTENT_SOURCE_DIR_SIMD_SORT})"
)
else()
hpx_info(
"HPX_WITH_FETCH_SIMD_SORT=${HPX_WITH_FETCH_SIMD_SORT}, x86-simd-sort will be fetched using CMake's FetchContent and installed alongside HPX (HPX_WITH_SIMD_SORT_TAG=${HPX_WITH_SIMD_SORT_TAG})"
)
endif()

include(FetchContent)
fetchcontent_declare(
simdsort
GIT_REPOSITORY https://github.com/intel/x86-simd-sort
GIT_TAG ${HPX_WITH_SIMD_SORT_TAG}
)

fetchcontent_getproperties(simdsort)
if(NOT simdsort_POPULATED)
fetchcontent_populate(simdsort)
endif()
set(SIMD_SORT_ROOT ${simdsort_SOURCE_DIR})

add_library(simdsort INTERFACE)
target_include_directories(
simdsort SYSTEM INTERFACE $<BUILD_INTERFACE:${SIMD_SORT_ROOT}/src/>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

install(
TARGETS simdsort
EXPORT HPXSimdSortTarget
COMPONENT core
)

install(
DIRECTORY ${SIMD_SORT_ROOT}/src/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT core
FILES_MATCHING
PATTERN "*.hpp"
PATTERN "*.h"
)

export(
TARGETS simdsort
NAMESPACE SimdSort::
FILE "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/${HPX_PACKAGE_NAME}/HPXSimdSortTarget.cmake"
)

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

add_library(SimdSort::simdsort ALIAS simdsort)

endif()
4 changes: 4 additions & 0 deletions libs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,10 @@ if("${HPX_WITH_DATAPAR_BACKEND}" STREQUAL "SVE")
target_link_libraries(hpx_core PUBLIC SVE::sve)
endif()

if(HPX_WITH_SIMD_SORT)
target_link_libraries(hpx_core PUBLIC SimdSort::simdsort)
endif()

if(HPX_WITH_ITTNOTIFY)
target_link_libraries(hpx_core PUBLIC Amplifier::amplifier)
endif()
Expand Down
1 change: 1 addition & 0 deletions libs/core/algorithms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ set(algorithms_headers
hpx/parallel/algorithms/detail/dispatch.hpp
hpx/parallel/algorithms/detail/distance.hpp
hpx/parallel/algorithms/detail/equal.hpp
hpx/parallel/algorithms/detail/simd_sort.hpp
hpx/parallel/algorithms/detail/fill.hpp
hpx/parallel/algorithms/detail/find.hpp
hpx/parallel/algorithms/detail/generate.hpp
Expand Down
Empty file.

0 comments on commit b60c175

Please sign in to comment.