-
-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
215 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
libs/core/algorithms/include/hpx/parallel/algorithms/detail/simd_sort.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// 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) | ||
|
||
#include <type_traits> | ||
|
||
#pragma once | ||
|
||
namespace hpx::parallel::util { | ||
// TODO : add support for _Float16 | ||
// need compile time test as _Float16 is not always supported | ||
template <class T> | ||
struct is_simd_sortable | ||
: std::integral_constant<bool, | ||
std::is_same<uint16_t, | ||
typename std::remove_volatile<T>::type>::value || | ||
std::is_same<int16_t, | ||
typename std::remove_volatile<T>::type>::value || | ||
std::is_same<uint32_t, | ||
typename std::remove_volatile<T>::type>::value || | ||
std::is_same<int32_t, | ||
typename std::remove_volatile<T>::type>::value || | ||
std::is_same<float, | ||
typename std::remove_volatile<T>::type>::value || | ||
std::is_same<uint64_t, | ||
typename std::remove_volatile<T>::type>::value || | ||
std::is_same<int64_t, | ||
typename std::remove_volatile<T>::type>::value || | ||
std::is_same<double, | ||
typename std::remove_volatile<T>::type>::value> | ||
{ | ||
}; | ||
|
||
template <class T> | ||
constexpr bool is_simd_sortable_v = is_simd_sortable<T>::value; | ||
} // namespace hpx::parallel::util | ||
|
||
#if (HPX_WITH_SIMD_SORT) | ||
|
||
namespace hpx::parallel::util { | ||
template <typename T> | ||
void simd_quicksort(T* arr, int64_t arrsize) | ||
{ | ||
static_assert(hpx::parallel::util::is_simd_sortable_v<T>); | ||
return avx512_qsort(arr, arrsize); | ||
} | ||
} // namespace hpx::parallel::util | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters