From 3e180193e01bb37bf70c474055aed0174e29ec27 Mon Sep 17 00:00:00 2001 From: Ivan K Date: Thu, 9 Apr 2026 10:35:11 +0300 Subject: [PATCH 1/5] froll.Rraw: skip tests that depend on NA payload RISC-V chips do not propagate NaN payload through arithmetic operations. --- inst/tests/froll.Rraw | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/inst/tests/froll.Rraw b/inst/tests/froll.Rraw index 22fd88423..c1bceba43 100644 --- a/inst/tests/froll.Rraw +++ b/inst/tests/froll.Rraw @@ -1456,8 +1456,12 @@ test(6001.731, between(frollvar(y, 3)[4L], 0, 1e-7)) test(6001.732, between(frollsd(y, 3)[4L], 0, 1e-7)) test(6001.733, frollvar(y, c(3,3,3,3), adaptive=TRUE)[4L], 0) test(6001.734, frollsd(y, c(3,3,3,3), adaptive=TRUE)[4L], 0) -test(6001.740, frollvar(c(1.5,2.5,2,NA), c(3,3)), list(c(NA,NA,0.25,NA), c(NA,NA,0.25,NA)), output="running sequentially, because outer parallelism has been used", options=c(datatable.verbose=TRUE)) # ensure no nested parallelism in rolling functions #7352 -test(6001.741, frollsd(c(1.5,2.5,2,NA), c(3,3)), list(c(NA,NA,0.5,NA), c(NA,NA,0.5,NA)), output="running sequentially, because outer parallelism has been used", options=c(datatable.verbose=TRUE)) +if (identical(Sys.info()[["machine"]], "riscv64")) { # see #7695 + cat("\n**** This is a RISC-V; skipping two tests that depend on NaN payload propagation\n\n") +} else { + test(6001.740, frollvar(c(1.5,2.5,2,NA), c(3,3)), list(c(NA,NA,0.25,NA), c(NA,NA,0.25,NA)), output="running sequentially, because outer parallelism has been used", options=c(datatable.verbose=TRUE)) # ensure no nested parallelism in rolling functions #7352 + test(6001.741, frollsd(c(1.5,2.5,2,NA), c(3,3)), list(c(NA,NA,0.5,NA), c(NA,NA,0.5,NA)), output="running sequentially, because outer parallelism has been used", options=c(datatable.verbose=TRUE)) +} test(6001.742, frollvar(c(1.5,2.5,2,1.5), c(3,3)), list(c(NA,NA,0.25,0.25), c(NA,NA,0.25,0.25)), notOutput="running sequentially, because outer parallelism has been used", options=c(datatable.verbose=TRUE)) # no NA - no fallback to exact test(6001.743, frollsd(c(1.5,2.5,2,1.5), c(3,3)), list(c(NA,NA,0.5,0.5), c(NA,NA,0.5,0.5)), notOutput="running sequentially, because outer parallelism has been used", options=c(datatable.verbose=TRUE)) test(6001.744, frollvar(c(1.5,2.5,2,NA), 3), c(NA,NA,0.25,NA), notOutput="running sequentially, because outer parallelism has been used", options=c(datatable.verbose=TRUE)) # not vectorized - no outer parallelism From 0881d7b11e8d7ab29d279d8540f64146fc42072a Mon Sep 17 00:00:00 2001 From: Ivan K Date: Thu, 9 Apr 2026 21:45:08 +0300 Subject: [PATCH 2/5] Better test for when to skip NA tests Co-Authored-By: Michael Chirico --- inst/tests/froll.Rraw | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/inst/tests/froll.Rraw b/inst/tests/froll.Rraw index c1bceba43..f4513ffca 100644 --- a/inst/tests/froll.Rraw +++ b/inst/tests/froll.Rraw @@ -9,11 +9,9 @@ if (exists("test.data.table", .GlobalEnv, inherits=FALSE)) { froll = data.table:::froll } -exact_NaN = isTRUE(capabilities()["long.double"]) && identical(as.integer(.Machine$longdouble.digits), 64L) +exact_NaN = identical(NA_real_+0, NA_real_) if (!exact_NaN) { - cat("\n**** Skipping 8 NaN/NA algo='exact' tests because .Machine$longdouble.digits==", .Machine$longdouble.digits, " (!=64); e.g. under valgrind\n\n", sep="") - # for Matt when he runs valgrind it is 53, but 64 when running regular R - # froll.c uses long double and appears to require full long double accuracy in the algo='exact' + cat("\n**** Skipping 10 NaN/NA algo='exact' tests because NaN payload doesn't propagate through numeric operations\n\n") } ## rolling features @@ -1456,9 +1454,7 @@ test(6001.731, between(frollvar(y, 3)[4L], 0, 1e-7)) test(6001.732, between(frollsd(y, 3)[4L], 0, 1e-7)) test(6001.733, frollvar(y, c(3,3,3,3), adaptive=TRUE)[4L], 0) test(6001.734, frollsd(y, c(3,3,3,3), adaptive=TRUE)[4L], 0) -if (identical(Sys.info()[["machine"]], "riscv64")) { # see #7695 - cat("\n**** This is a RISC-V; skipping two tests that depend on NaN payload propagation\n\n") -} else { +if (exact_NaN) { test(6001.740, frollvar(c(1.5,2.5,2,NA), c(3,3)), list(c(NA,NA,0.25,NA), c(NA,NA,0.25,NA)), output="running sequentially, because outer parallelism has been used", options=c(datatable.verbose=TRUE)) # ensure no nested parallelism in rolling functions #7352 test(6001.741, frollsd(c(1.5,2.5,2,NA), c(3,3)), list(c(NA,NA,0.5,NA), c(NA,NA,0.5,NA)), output="running sequentially, because outer parallelism has been used", options=c(datatable.verbose=TRUE)) } From f41ae1e499c38afbb2b0930e14096dac94fb400b Mon Sep 17 00:00:00 2001 From: Ivan K Date: Thu, 9 Apr 2026 21:47:05 +0300 Subject: [PATCH 3/5] Drop unused check from frollBatch.Rraw --- inst/tests/frollBatch.Rraw | 8 -------- 1 file changed, 8 deletions(-) diff --git a/inst/tests/frollBatch.Rraw b/inst/tests/frollBatch.Rraw index 0dd7c81bd..eae370f6a 100644 --- a/inst/tests/frollBatch.Rraw +++ b/inst/tests/frollBatch.Rraw @@ -9,14 +9,6 @@ if (exists("test.data.table", .GlobalEnv, inherits=FALSE)) { froll = data.table:::froll } -exact_NaN = isTRUE(capabilities()["long.double"]) && identical(as.integer(.Machine$longdouble.digits), 64L) -if (!exact_NaN) { - cat("\n**** Skipping 7 NaN/NA algo='exact' tests because .Machine$longdouble.digits==", .Machine$longdouble.digits, " (!=64); e.g. under valgrind\n\n", sep="") - # for Matt when he runs valgrind it is 53, but 64 when running regular R - # froll.c uses long double and appears to require full long double accuracy in the algo='exact' -} - - ## batch validation set.seed(108) makeNA = function(x, ratio=0.1, nf=FALSE) { From 6633b8b67085ced710b1fb29b5d4436246503f2c Mon Sep 17 00:00:00 2001 From: Ivan K Date: Thu, 9 Apr 2026 22:09:49 +0300 Subject: [PATCH 4/5] Test R behaviour to stop NA-related test --- inst/tests/tests.Rraw | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index 161d3dcea..443487c6a 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -144,6 +144,11 @@ if (!test_longdouble) { cat("\n**** Full long double accuracy is not available. Tests using this will be skipped.\n\n") # e.g. under valgrind, longdouble.digits==53; causing these to fail: 1262, 1729.04, 1729.08, 1729.09, 1729.11, 1729.13, 1830.7; #4639 } +exact_NA = identical(NA_real_ + 0, NA_real_) +if (!exact_NA) { + cat("\n**** NaN payload does not propagate through arithmetic operations. Tests requiring NA not to decay to NaN will be skipped.\n\n") + # e.g. on riscv64 +} tt = Sys.getenv("TZ", unset=NA) TZnotUTC = !identical(tt,"") && !is_utc(tt) @@ -1957,12 +1962,9 @@ basemean = base::mean # to isolate time of `::` itself ans3 = DT[,list(basemean(x),basemean(y)),by=list(grp1,grp2)] test(646, ans1, ans2) test(647, ans1, ans3) -if (test_longdouble) { +if (exact_NA) { test(648, anyNA(ans1$V1) && !any(is.nan(ans1$V1))) - # used to error with `valgrind` because of the 'long double' usage in gsumm.c (although I wonder if we need long double precision). - # it doesn't seem to error under valgrind anymore so the test_longdouble may be removable - # http://valgrind.org/docs/manual/manual-core.html#manual-core.limits - # http://comments.gmane.org/gmane.comp.debugging.valgrind/10340 + # Valgrind may have had NaN payload propagation problems in the past; RISC-V will in the future } ans1 = DT[,list(mean(x,na.rm=TRUE),mean(y,na.rm=TRUE)),by=list(grp1,grp2)] ans2 = DT[,list(mean.default(x,na.rm=TRUE),mean.default(y,na.rm=TRUE)),by=list(grp1,grp2)] From d4ba469335d0171ed66bd87f312ff121f06a6e33 Mon Sep 17 00:00:00 2001 From: Ivan K Date: Thu, 9 Apr 2026 23:01:48 +0300 Subject: [PATCH 5/5] Fix typo --- inst/tests/froll.Rraw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/tests/froll.Rraw b/inst/tests/froll.Rraw index f4513ffca..99c878d49 100644 --- a/inst/tests/froll.Rraw +++ b/inst/tests/froll.Rraw @@ -11,7 +11,7 @@ if (exists("test.data.table", .GlobalEnv, inherits=FALSE)) { exact_NaN = identical(NA_real_+0, NA_real_) if (!exact_NaN) { - cat("\n**** Skipping 10 NaN/NA algo='exact' tests because NaN payload doesn't propagate through numeric operations\n\n") + cat("\n**** Skipping 10 NaN/NA algo='exact' tests because NaN payload doesn't propagate through arithmetic operations\n\n") } ## rolling features