Skip to content
Merged
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
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -659,9 +659,6 @@ if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_INSTALL_PREFIX)
cmake/modules/RootMacros.cmake
cmake/modules/RootTestDriver.cmake
DESTINATION ${CMAKE_INSTALL_CMAKEDIR})
install(FILES
"cmake/modules/FindVdt.cmake"
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}/modules")
endif()

#---Add configuration files for kernel and jupyter----------------------------------------------
Expand Down
27 changes: 9 additions & 18 deletions builtins/vdt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
set(VDT_INSTALL_DIR ${CMAKE_BINARY_DIR}/builtins/vdt/install/)
set(ROOT_VDT_VERSION 0.4.6)
set(VDT_FOUND True)
set(VDT_LIBRARIES "${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}vdt${CMAKE_SHARED_LIBRARY_SUFFIX}")
set(VDT_LIBRARIES "${VDT_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}vdt${CMAKE_SHARED_LIBRARY_SUFFIX}")
ExternalProject_Add(
BUILTIN_VDT
URL ${lcgpackages}/vdt-${ROOT_VDT_VERSION}.tar.gz
URL_HASH SHA256=1820feae446780763ec8bbb60a0dbcf3ae1ee548bdd01415b1fb905fd4f90c54
INSTALL_DIR ${CMAKE_BINARY_DIR}
INSTALL_DIR ${VDT_INSTALL_DIR}
CMAKE_ARGS
-DCMAKE_POLICY_VERSION_MINIMUM=3.5
-DSSE=OFF # breaks on ARM without this
Expand All @@ -19,24 +20,14 @@ ExternalProject_Add(
BUILD_BYPRODUCTS ${VDT_LIBRARIES}
TIMEOUT 600
)
ExternalProject_Add_Step(
BUILTIN_VDT copy2externals
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/include/vdt ${CMAKE_BINARY_DIR}/ginclude/vdt
DEPENDEES install
)
set(VDT_INCLUDE_DIR ${CMAKE_BINARY_DIR}/ginclude)
set(VDT_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/ginclude)
set(VDT_INCLUDE_DIR ${VDT_INSTALL_DIR}/include)
set(VDT_INCLUDE_DIRS ${VDT_INSTALL_DIR}/include)

add_library(VDT::VDT SHARED IMPORTED GLOBAL)
file(MAKE_DIRECTORY ${VDT_INCLUDE_DIR})
# Try to use VDT header only, and only PRIVATE. This will simplify installing it
add_library(VDT::VDT INTERFACE IMPORTED GLOBAL)
add_dependencies(VDT::VDT BUILTIN_VDT)
set_target_properties(VDT::VDT PROPERTIES IMPORTED_LOCATION ${VDT_LIBRARIES})
target_include_directories(VDT::VDT INTERFACE $<BUILD_INTERFACE:${VDT_INCLUDE_DIR}> $<INSTALL_INTERFACE:include/>)

install(FILES ${VDT_LIBRARIES}
DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
install(DIRECTORY ${CMAKE_BINARY_DIR}/include/vdt
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT extra-headers)
set_property(GLOBAL APPEND PROPERTY ROOT_BUILTIN_TARGETS VDT::VDT)
target_include_directories(VDT::VDT INTERFACE $<BUILD_INTERFACE:${VDT_INCLUDE_DIR}>)

set(VDT_VERSION ${ROOT_VDT_VERSION} PARENT_SCOPE)
set(VDT_FOUND ${VDT_FOUND} PARENT_SCOPE)
Expand Down
12 changes: 0 additions & 12 deletions cmake/scripts/ROOTConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,6 @@ if(ROOT_minuit2_omp_FOUND)
find_dependency(OpenMP)
find_dependency(Threads)
endif()
if(ROOT_vdt_FOUND AND NOT TARGET VDT::VDT)
if(ROOT_builtin_vdt_FOUND)
function(find_builtin_vdt)
# the function is to create a scope (could use block() but requires CMake>=3.25)
set(CMAKE_PREFIX_PATH ${ROOT_INCLUDE_DIRS} ${ROOT_LIBRARY_DIR})
find_dependency(Vdt)
endfunction()
find_builtin_vdt()
else()
find_dependency(Vdt)
endif()
endif()

#----------------------------------------------------------------------------
# Now set them to ROOT_LIBRARIES
Expand Down
2 changes: 1 addition & 1 deletion math/vecops/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ROOT_STANDARD_LIBRARY_PACKAGE(ROOTVecOps
)

if(builtin_vdt OR vdt)
target_link_libraries(ROOTVecOps PUBLIC VDT::VDT)
target_link_libraries(ROOTVecOps PRIVATE VDT::VDT)
endif()

include(CheckCXXSymbolExists)
Expand Down
70 changes: 19 additions & 51 deletions math/vecops/inc/ROOT/RVec.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,15 @@
#include <iterator> // for std::make_move_iterator
#include <limits> // for numeric_limits
#include <memory> // uninitialized_value_construct
#include <new>
#include <numeric> // for inner_product
#include <sstream>
#include <ostream>
#include <stdexcept>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

#ifdef R__HAS_VDT
#include <vdt/vdtMath.h>
#endif


namespace ROOT {

namespace VecOps {
Expand Down Expand Up @@ -1867,26 +1861,24 @@ RVEC_STD_UNARY_FUNCTION(tgamma)
///@{

#ifdef R__HAS_VDT
#define RVEC_VDT_UNARY_FUNCTION(F) RVEC_UNARY_FUNCTION(F, vdt::F)

RVEC_VDT_UNARY_FUNCTION(fast_expf)
RVEC_VDT_UNARY_FUNCTION(fast_logf)
RVEC_VDT_UNARY_FUNCTION(fast_sinf)
RVEC_VDT_UNARY_FUNCTION(fast_cosf)
RVEC_VDT_UNARY_FUNCTION(fast_tanf)
RVEC_VDT_UNARY_FUNCTION(fast_asinf)
RVEC_VDT_UNARY_FUNCTION(fast_acosf)
RVEC_VDT_UNARY_FUNCTION(fast_atanf)

RVEC_VDT_UNARY_FUNCTION(fast_exp)
RVEC_VDT_UNARY_FUNCTION(fast_log)
RVEC_VDT_UNARY_FUNCTION(fast_sin)
RVEC_VDT_UNARY_FUNCTION(fast_cos)
RVEC_VDT_UNARY_FUNCTION(fast_tan)
RVEC_VDT_UNARY_FUNCTION(fast_asin)
RVEC_VDT_UNARY_FUNCTION(fast_acos)
RVEC_VDT_UNARY_FUNCTION(fast_atan)
#undef RVEC_VDT_UNARY_FUNCTION

RVec<float> fast_expf(const RVec<float> &v);
RVec<float> fast_logf(const RVec<float> &v);
RVec<float> fast_sinf(const RVec<float> &v);
RVec<float> fast_cosf(const RVec<float> &v);
RVec<float> fast_tanf(const RVec<float> &v);
RVec<float> fast_asinf(const RVec<float> &v);
RVec<float> fast_acosf(const RVec<float> &v);
RVec<float> fast_atanf(const RVec<float> &v);

RVec<double> fast_exp(const RVec<double> &v);
RVec<double> fast_log(const RVec<double> &v);
RVec<double> fast_sin(const RVec<double> &v);
RVec<double> fast_cos(const RVec<double> &v);
RVec<double> fast_tan(const RVec<double> &v);
RVec<double> fast_asin(const RVec<double> &v);
RVec<double> fast_acos(const RVec<double> &v);
RVec<double> fast_atan(const RVec<double> &v);

#endif // R__HAS_VDT

Expand Down Expand Up @@ -3742,30 +3734,6 @@ RVEC_EXTERN_STD_FUNCTIONS(double)
#undef RVEC_EXTERN_STD_BINARY_FUNCTION
#undef RVEC_EXTERN_STD_UNARY_FUNCTIONS

#ifdef R__HAS_VDT

#define RVEC_EXTERN_VDT_UNARY_FUNCTION(T, F) RVEC_EXTERN_UNARY_FUNCTION(T, F, vdt::F)

RVEC_EXTERN_VDT_UNARY_FUNCTION(float, fast_expf)
RVEC_EXTERN_VDT_UNARY_FUNCTION(float, fast_logf)
RVEC_EXTERN_VDT_UNARY_FUNCTION(float, fast_sinf)
RVEC_EXTERN_VDT_UNARY_FUNCTION(float, fast_cosf)
RVEC_EXTERN_VDT_UNARY_FUNCTION(float, fast_tanf)
RVEC_EXTERN_VDT_UNARY_FUNCTION(float, fast_asinf)
RVEC_EXTERN_VDT_UNARY_FUNCTION(float, fast_acosf)
RVEC_EXTERN_VDT_UNARY_FUNCTION(float, fast_atanf)

RVEC_EXTERN_VDT_UNARY_FUNCTION(double, fast_exp)
RVEC_EXTERN_VDT_UNARY_FUNCTION(double, fast_log)
RVEC_EXTERN_VDT_UNARY_FUNCTION(double, fast_sin)
RVEC_EXTERN_VDT_UNARY_FUNCTION(double, fast_cos)
RVEC_EXTERN_VDT_UNARY_FUNCTION(double, fast_tan)
RVEC_EXTERN_VDT_UNARY_FUNCTION(double, fast_asin)
RVEC_EXTERN_VDT_UNARY_FUNCTION(double, fast_acos)
RVEC_EXTERN_VDT_UNARY_FUNCTION(double, fast_atan)

#endif // R__HAS_VDT

#endif // _VECOPS_USE_EXTERN_TEMPLATES

/** @} */ // end of Doxygen group vecops
Expand Down
51 changes: 31 additions & 20 deletions math/vecops/src/RVec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
#include "ROOT/RVec.hxx"
using namespace ROOT::VecOps;

#ifdef R__HAS_VDT
#include "vdt/vdtMath.h"
#endif

// Check that no bytes are wasted and everything is well-aligned.
namespace {
struct Struct16B {
Expand Down Expand Up @@ -236,26 +240,33 @@ RVEC_DECLARE_STD_FUNCTIONS(double)

#ifdef R__HAS_VDT

#define RVEC_DECLARE_VDT_UNARY_FUNCTION(T, F) \
RVEC_DECLARE_UNARY_FUNCTION(T, F, vdt::F)

RVEC_DECLARE_VDT_UNARY_FUNCTION(float, fast_expf)
RVEC_DECLARE_VDT_UNARY_FUNCTION(float, fast_logf)
RVEC_DECLARE_VDT_UNARY_FUNCTION(float, fast_sinf)
RVEC_DECLARE_VDT_UNARY_FUNCTION(float, fast_cosf)
RVEC_DECLARE_VDT_UNARY_FUNCTION(float, fast_tanf)
RVEC_DECLARE_VDT_UNARY_FUNCTION(float, fast_asinf)
RVEC_DECLARE_VDT_UNARY_FUNCTION(float, fast_acosf)
RVEC_DECLARE_VDT_UNARY_FUNCTION(float, fast_atanf)

RVEC_DECLARE_VDT_UNARY_FUNCTION(double, fast_exp)
RVEC_DECLARE_VDT_UNARY_FUNCTION(double, fast_log)
RVEC_DECLARE_VDT_UNARY_FUNCTION(double, fast_sin)
RVEC_DECLARE_VDT_UNARY_FUNCTION(double, fast_cos)
RVEC_DECLARE_VDT_UNARY_FUNCTION(double, fast_tan)
RVEC_DECLARE_VDT_UNARY_FUNCTION(double, fast_asin)
RVEC_DECLARE_VDT_UNARY_FUNCTION(double, fast_acos)
RVEC_DECLARE_VDT_UNARY_FUNCTION(double, fast_atan)
#define RVEC_IMPLEMENT_VDT_UNARY_FUNCTION(FP, FUNC) \
RVec<FP> FUNC(RVec<FP> const &in) \
{ \
RVec<FP> out(in.size()); \
for (unsigned int i = 0; i < in.size(); ++i) { \
out[i] = vdt::FUNC(in[i]); \
} \
return out; \
}

RVEC_IMPLEMENT_VDT_UNARY_FUNCTION(float, fast_expf)
RVEC_IMPLEMENT_VDT_UNARY_FUNCTION(float, fast_logf)
RVEC_IMPLEMENT_VDT_UNARY_FUNCTION(float, fast_sinf)
RVEC_IMPLEMENT_VDT_UNARY_FUNCTION(float, fast_cosf)
RVEC_IMPLEMENT_VDT_UNARY_FUNCTION(float, fast_tanf)
RVEC_IMPLEMENT_VDT_UNARY_FUNCTION(float, fast_asinf)
RVEC_IMPLEMENT_VDT_UNARY_FUNCTION(float, fast_acosf)
RVEC_IMPLEMENT_VDT_UNARY_FUNCTION(float, fast_atanf)

RVEC_IMPLEMENT_VDT_UNARY_FUNCTION(double, fast_exp)
RVEC_IMPLEMENT_VDT_UNARY_FUNCTION(double, fast_log)
RVEC_IMPLEMENT_VDT_UNARY_FUNCTION(double, fast_sin)
RVEC_IMPLEMENT_VDT_UNARY_FUNCTION(double, fast_cos)
RVEC_IMPLEMENT_VDT_UNARY_FUNCTION(double, fast_tan)
RVEC_IMPLEMENT_VDT_UNARY_FUNCTION(double, fast_asin)
RVEC_IMPLEMENT_VDT_UNARY_FUNCTION(double, fast_acos)
RVEC_IMPLEMENT_VDT_UNARY_FUNCTION(double, fast_atan)

#endif // R__HAS_VDT

Expand Down
4 changes: 4 additions & 0 deletions math/vecops/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
# For the list of contributors see $ROOTSYS/README/CREDITS.

ROOT_ADD_GTEST(vecops_rvec vecops_rvec.cxx LIBRARIES Physics ROOTVecOps GenVector RIO Tree)

if(TARGET VDT::VDT)
target_link_libraries(vecops_rvec PRIVATE VDT::VDT)
endif()
6 changes: 6 additions & 0 deletions test/PostInstall/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,10 @@ if(BUILD_TESTING)
)

endif()

if(TARGET ROOT::ROOTVecOps)
add_executable(RVec testRVec.cxx)
target_link_libraries(RVec PUBLIC ROOT::ROOTVecOps)
add_test(NAME RVec COMMAND $<TARGET_FILE:RVec>)
endif()
endif()
34 changes: 34 additions & 0 deletions test/PostInstall/testRVec.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
Comment thread
hageboeck marked this conversation as resolved.
RVec can publicly depend on VDT, so here we ensure that the VDT headers are found correctly.
*/

#include <ROOT/RVec.hxx>

#include <iostream>

#define CHECK(ARG) \
if (!(ARG)) { \
success = false; \
std::cerr << #ARG << " failed\n"; \
}

int main()
{
bool success = true;

ROOT::RVec<ROOT::RVecD> rv{{1., 2., 3., 4., 5.}, {1., 2., 3., 4., 5.}};
auto sum = rv[0] + rv[1];
CHECK(sum.size() == rv[0].size())
CHECK(sum[3] == 8.)

#ifdef R__HAS_VDT
ROOT::RVecD rv2{1., 2., 3., 4., 5.};
auto logs = fast_log(rv2);
CHECK(std::fabs(logs[0]) < 1.E-15)
CHECK(std::fabs(logs[1] - std::log(2.)) < 1.E-15);
if (!success)
std::cout << "logs=" << logs << "\n";
#endif

return success ? 0 : 1;
}
Loading