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
7 changes: 7 additions & 0 deletions math/mathcore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,11 @@ ROOT_STANDARD_LIBRARY_PACKAGE(MathCore

target_link_libraries(MathCore PRIVATE ${CMAKE_THREAD_LIBS_INIT})

# Force remove FMA on RISC-V
if(CMAKE_SYSTEM_PROCESSOR MATCHES "riscv64|riscv")
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(MathCore PRIVATE -ffp-contract=off)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's the right approach to forbid FMA - it will be slower, no? Failing tests are a sign of too tight tolerances...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now we want this package to build. Previous builds just added failed tests to exclude list.

I decided to try different approach. Without FMA we at least have something which builds and works as expected (so it passes tests).

I am open to other solutions.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I maintain that the tests should be fixed. Disabling FMA is a workaround, and if we put it in now nobody will be working to remove it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can "root" get some central way to tell "this architecture has FMA precision" instead of forcing any new architecture to reinvent the wheel?

The whole build takes 14 hours on current RISC-V hardware (SpacemiT K3 - the fastest available CPU). The way how it builds (single thread for most of time) does not help.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will resume my work on root around 20th August.

endif()
endif()

ROOT_ADD_TEST_SUBDIRECTORY(test)
3 changes: 2 additions & 1 deletion math/mathcore/test/stress/testGenVector.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ TYPED_TEST_P(GenVectorTest, TestGenVectors)
scale = this->fDim * 20;
if (this->fDim == 3 && this->V2Name() == "RhoEtaPhiVector") scale *= 12; // for problem with RhoEtaPhi
if (this->fDim == 4 && ( this->V2Name() == "PtEtaPhiMVector" || this->V2Name() == "PxPyPzMVector")) {
#if (defined(__arm__) || defined(__arm64__) || defined(__aarch64__) || defined(__s390x__) || defined(__FMA__))
#if (defined(__arm__) || defined(__arm64__) || defined(__aarch64__) || defined(__s390x__) || defined(__FMA__)) || \
defined(__riscv)
scale *= 1.E7;
#else
scale *= 10;
Expand Down
7 changes: 7 additions & 0 deletions math/matrix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,12 @@ ROOT_STANDARD_LIBRARY_PACKAGE(Matrix
-writeEmptyRootPCM
)

# Force remove FMA on RISC-V
if(CMAKE_SYSTEM_PROCESSOR MATCHES "riscv64|riscv")
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(Matrix PRIVATE -ffp-contract=off)
endif()
endif()

ROOT_ADD_TEST_SUBDIRECTORY(test)

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

ROOT_ADD_GTEST(testMatrixTSparse testMatrixTSparse.cxx LIBRARIES Matrix)
# Disable FMA on RISC-V to avoid 1-ULP differences between sparse and dense paths
if(CMAKE_SYSTEM_PROCESSOR MATCHES "riscv64|riscv")
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(testMatrixTSparse PRIVATE -ffp-contract=off)
endif()
endif()
ROOT_ADD_GTEST(testMatrixTDecomp testMatrixTDecomp.cxx LIBRARIES Matrix)
ROOT_ADD_GTEST(testMatrixT testMatrixT.cxx LIBRARIES Matrix)
3 changes: 2 additions & 1 deletion test/stressMathCore.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,8 @@ int testVector(int ngen, bool testio=false) {
scale = Dim*20;
if (Dim==3 && VecType<V2>::name() == "RhoEtaPhiVector") scale *= 12; // for problem with RhoEtaPhi
if (Dim==4 && ( VecType<V2>::name() == "PtEtaPhiMVector" || VecType<V2>::name() == "PxPyPzMVector")) {
#if (defined(__arm__) || defined(__arm64__) || defined(__aarch64__) || defined(__s390x__) || defined(__FMA__))
#if (defined(__arm__) || defined(__arm64__) || defined(__aarch64__) || defined(__s390x__) || defined(__FMA__)) || \
defined(__riscv)
scale *= 1.E7;
#else
scale *= 10;
Expand Down
Loading