Skip to content

Commit a064d00

Browse files
author
Nicusor Serban
committed
Merge branch 'develop' into release/v4.9.0
2 parents c19cdad + e1fcbe8 commit a064d00

8 files changed

Lines changed: 73 additions & 17 deletions

File tree

Jenkinsfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import org.stan.Utils
55
def runTests(String testPath, boolean jumbo = false) {
66
try {
77
sh "cat make/local"
8+
sh "make print-compiler-flags"
89
if (jumbo && !params.disableJumbo) {
910
sh "python3 runTests.py -j${env.PARALLEL} ${testPath} --jumbo --debug"
1011
} else {
@@ -142,8 +143,8 @@ pipeline {
142143
}
143144
post {
144145
always {
145-
recordIssues(
146-
enabledForFailure: true,
146+
recordIssues(
147+
enabledForFailure: true,
147148
tools: [cppLint(),groovyScript(parserId: 'mathDependencies', pattern: '**/dependencies.log')]
148149
)
149150
deleteDir()
@@ -575,7 +576,7 @@ pipeline {
575576
always {
576577
node("linux") {
577578
recordIssues(
578-
enabledForFailure: false,
579+
enabledForFailure: false,
579580
tool: clang()
580581
)
581582
}

doxygen/contributor_help_pages/developer_doc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ These are the more common make flags that could be set:
184184
These are the rest of the variables that can be set:
185185

186186
- C++ compiler flags
187-
- `CXXFLAGS_LANG`: sets the language. Currently defaults to `-std=c++1y`
187+
- `CXXFLAGS_LANG`: sets the language. Currently defaults to `-std=c++17`
188188
- `CXXFLAGS_WARNINGS`: compiler options to squash compiler warnings
189189
- `CXXFLAGS_BOOST`: Boost-specific compiler flags
190190
- `CXXFLAGS_EIGEN`: Eigen-specific compiler flags

lib/sundials_6.1.1/STAN_CHANGES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This file documents changes done for the stan-math project
2+
3+
- Backported bugfix for hashmap int overflow on Windows (https://github.com/LLNL/sundials/pull/421)

lib/sundials_6.1.1/src/sundials/sundials_hashmap.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#ifndef _SUNDIALS_HASHMAP_H
2121
#define _SUNDIALS_HASHMAP_H
2222

23+
#include <stdint.h>
2324
#include <string.h>
2425
#include <stdlib.h>
2526

@@ -30,10 +31,10 @@
3031
This is a 64-bit implementation of the 'a' modification of the
3132
Fowler–Noll–Vo hash (i.e., FNV1-a).
3233
*/
33-
static unsigned long fnv1a_hash(const char* str)
34+
static uint64_t fnv1a_hash(const char* str)
3435
{
35-
const unsigned long prime = 14695981039346656037U; /* prime */
36-
unsigned long hash = 1099511628211U; /* offset basis */
36+
const uint64_t prime = 14695981039346656037U; /* prime */
37+
uint64_t hash = 1099511628211U; /* offset basis */
3738
char c;
3839
while ((c = *str++))
3940
hash = (hash^c) * prime;

make/compiler_flags

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ CXX_VERSION := $(shell $(CXX) -dumpfullversion -dumpversion 2>&1)
7070
CXX_MAJOR := $(word 1,$(subst ., ,$(CXX_VERSION)))
7171
CXX_MINOR := $(word 2,$(subst ., ,$(CXX_VERSION)))
7272

73-
7473
################################################################################
7574
# Set optional compiler flags for performance
7675
#
@@ -121,10 +120,32 @@ INC_GTEST ?= -I $(GTEST)/include -I $(GTEST)
121120
CPPFLAGS_BOOST ?= -DBOOST_DISABLE_ASSERTS
122121
CPPFLAGS_SUNDIALS ?= -DNO_FPRINTF_OUTPUT $(CPPFLAGS_OPTIM_SUNDIALS) $(CXXFLAGS_FLTO_SUNDIALS)
123122
#CPPFLAGS_GTEST ?=
123+
STAN_HAS_CXX17 ?= false
124+
ifeq ($(CXX_TYPE), gcc)
125+
GCC_GE_73 := $(shell [ $(CXX_MAJOR) -gt 7 -o \( $(CXX_MAJOR) -eq 7 -a $(CXX_MINOR) -ge 1 \) ] && echo true)
126+
ifeq ($(GCC_GE_73),true)
127+
STAN_HAS_CXX17 := true
128+
endif
129+
else ifeq ($(CXX_TYPE), clang)
130+
CLANG_GE_5 := $(shell [ $(CXX_MAJOR) -gt 5 -o \( $(CXX_MAJOR) -eq 5 -a $(CXX_MINOR) -ge 0 \) ] && echo true)
131+
ifeq ($(CLANG_GE_5),true)
132+
STAN_HAS_CXX17 := true
133+
endif
134+
else ifeq ($(CXX_TYPE), mingw32-gcc)
135+
MINGW_GE_50 := $(shell [ $(CXX_MAJOR) -gt 5 -o \( $(CXX_MAJOR) -eq 5 -a $(CXX_MINOR) -ge 0 \) ] && echo true)
136+
ifeq ($(MINGW_GE_50),true)
137+
STAN_HAS_CXX17 := true
138+
endif
139+
endif
124140

125-
126-
## setup compiler flags
127-
CXXFLAGS_LANG ?= -std=c++1y
141+
ifeq ($(STAN_HAS_CXX17), true)
142+
CXXFLAGS_LANG ?= -std=c++17
143+
CXXFLAGS_STANDARD ?= c++17
144+
else
145+
$(warning "Stan cannot detect if your compiler has the C++17 standard. If it does, please set STAN_HAS_CXX17=true in your make/local file. C++17 support is mandatory in the next release of Stan. Defaulting to C++14")
146+
CXXFLAGS_LANG ?= -std=c++1y
147+
CXXFLAGS_STANDARD ?= c++1y
148+
endif
128149
#CXXFLAGS_BOOST ?=
129150
CXXFLAGS_SUNDIALS ?= -pipe $(CXXFLAGS_OPTIM_SUNDIALS) $(CPPFLAGS_FLTO_SUNDIALS)
130151
#CXXFLAGS_GTEST
@@ -225,6 +246,10 @@ endif
225246

226247
## silence warnings occuring due to the TBB and Eigen libraries
227248
CXXFLAGS_WARNINGS += -Wno-ignored-attributes
249+
## https://github.com/oneapi-src/oneTBB/issues/307
250+
ifeq ($(CXX_TYPE), gcc)
251+
CXXFLAGS_WARNINGS += -Wno-class-memaccess
252+
endif
228253

229254
################################################################################
230255
# Setup OpenCL
@@ -284,13 +309,19 @@ CXXFLAGS_TBB ?= -I $(TBB_INC)
284309
else
285310
CXXFLAGS_TBB ?= -I $(TBB)/include
286311
endif
287-
LDFLAGS_TBB ?= -Wl,-L,"$(TBB_LIB)" -Wl,--disable-new-dtags
312+
313+
# MacOS ld does not support --disable-new-dtags
314+
ifneq ($(OS),Darwin)
315+
LDFLAGS_TBB_DTAGS ?= -Wl,--disable-new-dtags
316+
endif
288317

289318
# Windows LLVM/Clang does not support -rpath, but is not needed on Windows anyway
290319
ifneq ($(OS), Windows_NT)
291-
LDFLAGS_TBB += -Wl,-rpath,"$(TBB_LIB)"
320+
LDFLAGS_TBB_RPATH ?= -Wl,-rpath,"$(TBB_LIB)"
292321
endif
293322

323+
LDFLAGS_TBB ?= -Wl,-L,"$(TBB_LIB)" $(LDFLAGS_TBB_DTAGS) $(LDFLAGS_TBB_RPATH)
324+
294325
LDLIBS_TBB ?= -ltbb
295326

296327
else

make/libraries

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,11 @@ endif
176176
$(TBB_BIN)/tbb.def: $(TBB_BIN)/tbb-make-check
177177
@mkdir -p $(TBB_BIN)
178178
touch $(TBB_BIN)/version_$(notdir $(TBB))
179-
tbb_root="$(TBB_RELATIVE_PATH)" WINARM64="$(WINARM64)" CXX="$(CXX)" CC="$(TBB_CC)" LDFLAGS='$(LDFLAGS_TBB)' '$(MAKE)' -C "$(TBB_BIN)" -r -f "$(TBB_ABSOLUTE_PATH)/build/Makefile.tbb" compiler=$(TBB_CXX_TYPE) cfg=release stdver=c++1y CXXFLAGS="$(TBB_CXXFLAGS)"
179+
tbb_root="$(TBB_RELATIVE_PATH)" WINARM64="$(WINARM64)" CXX="$(CXX)" CC="$(TBB_CC)" LDFLAGS='$(LDFLAGS_TBB)' '$(MAKE)' -C "$(TBB_BIN)" -r -f "$(TBB_ABSOLUTE_PATH)/build/Makefile.tbb" compiler=$(TBB_CXX_TYPE) cfg=release stdver=$(CXXFLAGS_STANDARD) CXXFLAGS="$(TBB_CXXFLAGS)"
180180

181181
$(TBB_BIN)/tbbmalloc.def: $(TBB_BIN)/tbb-make-check
182182
@mkdir -p $(TBB_BIN)
183-
tbb_root="$(TBB_RELATIVE_PATH)" WINARM64="$(WINARM64)" CXX="$(CXX)" CC="$(TBB_CC)" LDFLAGS='$(LDFLAGS_TBB)' '$(MAKE)' -C "$(TBB_BIN)" -r -f "$(TBB_ABSOLUTE_PATH)/build/Makefile.tbbmalloc" compiler=$(TBB_CXX_TYPE) cfg=release stdver=c++1y malloc CXXFLAGS="$(TBB_CXXFLAGS)"
183+
tbb_root="$(TBB_RELATIVE_PATH)" WINARM64="$(WINARM64)" CXX="$(CXX)" CC="$(TBB_CC)" LDFLAGS='$(LDFLAGS_TBB)' '$(MAKE)' -C "$(TBB_BIN)" -r -f "$(TBB_ABSOLUTE_PATH)/build/Makefile.tbbmalloc" compiler=$(TBB_CXX_TYPE) cfg=release stdver=$(CXXFLAGS_STANDARD) malloc CXXFLAGS="$(TBB_CXXFLAGS)"
184184

185185
$(TBB_BIN)/libtbb.dylib: $(TBB_BIN)/tbb.def
186186
$(TBB_BIN)/libtbbmalloc.dylib: $(TBB_BIN)/tbbmalloc.def

stan/math/prim/functor/hcubature.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,8 @@ inline auto hcubature(const F& integrand, const ParsTuple& pars, const int dim,
479479
std::tie(result_2, err_2, kdivide_2) = internal::integrate_GenzMalik(
480480
integrand, genz_malik, dim, box.a_, mb, pars);
481481
}
482-
box_t box1(std::move(ma), std::move(box.b_), result_1, kdivide_1);
483-
box_t box2(std::move(box.a_), std::move(mb), result_2, kdivide_2);
482+
box_t box1(std::move(ma), box.b_, result_1, kdivide_1);
483+
box_t box2(box.a_, std::move(mb), result_2, kdivide_2);
484484
result += result_1 + result_2 - box.I_;
485485
err += err_1 + err_2 - err_vec[err_idx];
486486
ms[err_idx].I_ = 0;

test/unit/math/prim/functor/hcubature_test.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <stan/math/prim/functor.hpp>
22
#include <stan/math/prim/fun.hpp>
3+
#include <stan/math/prim/prob/wiener_full_lpdf.hpp>
34

45
#include <gtest/gtest.h>
56
#include <vector>
@@ -163,3 +164,22 @@ TEST(StanMath_hcubature_prim, test1) {
163164
std::make_tuple((1 + sqrt(10.0)) / 9.0), dim, a_4, b_4,
164165
20000, 0.0, reqRelError_3, 0.999998);
165166
}
167+
168+
TEST(StanMath_hcubature_prim, test_issue_3075) {
169+
// test for regressions against issue
170+
// https://github.com/stan-dev/math/issues/3075
171+
using stan::math::internal::GradientCalc;
172+
using stan::math::internal::wiener5_density;
173+
using stan::math::internal::wiener7_integrate;
174+
175+
auto params_st = std::make_tuple(0.553273, 1, -3.5, 0.55, 0.553161, 1.06423,
176+
0.0941929, 0.0, -28.3242);
177+
Eigen::VectorXd xmin = Eigen::VectorXd::Zero(2);
178+
Eigen::VectorXd xmax = Eigen::VectorXd::Ones(2);
179+
180+
auto f = wiener7_integrate<GradientCalc::OFF, GradientCalc::OFF>(
181+
[](auto&&... args) { return wiener5_density<GradientCalc::ON>(args...); },
182+
-18.3029, params_st, 1, xmin, xmax, 6000, 0, 4.5e-05);
183+
184+
ASSERT_FLOAT_EQ(f, 4.97571e-312);
185+
}

0 commit comments

Comments
 (0)