Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++17 prep - namespace qualifiers only #2693

Merged
merged 37 commits into from
Jun 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
6b5d89c
Add namespace qualifier to apply
andrjohns Mar 28, 2022
5805d97
Update includes
andrjohns Mar 28, 2022
2742f3d
Size qualifier
andrjohns Mar 28, 2022
e3c7d27
Size qualifier for opencl
andrjohns Mar 28, 2022
e13f4bc
Missed size
andrjohns Mar 28, 2022
7db39ef
Remove stray test files
andrjohns Mar 28, 2022
8e0cc70
cpplint and includes
andrjohns Mar 28, 2022
92e4df6
Opencl
andrjohns Mar 28, 2022
9c20b0d
Merge commit 'b285b51a494ebf5aeb1434b0e34acbf275cabbd7' into HEAD
yashikno Mar 28, 2022
fd69a70
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Mar 28, 2022
b162659
Test g++ with threading tests
andrjohns Mar 28, 2022
2645b25
Re-enable unit tests
andrjohns Mar 29, 2022
e635eae
Update mix.hpp
andrjohns Mar 29, 2022
8fea43a
Merge branch 'develop' into feature/cpp17-pr-1
andrjohns Apr 2, 2022
e886d82
Use new ci image
andrjohns Apr 2, 2022
4b130cc
Update default clang
andrjohns Apr 2, 2022
8ee14e7
Update default clang
andrjohns Apr 2, 2022
922427a
Update Jenkinsfile
andrjohns Apr 2, 2022
5a0fc01
Trigger CI
andrjohns Apr 4, 2022
ef4fcd1
Force pull image
andrjohns Apr 4, 2022
b0798ed
Update Jenkinsfile
andrjohns Apr 4, 2022
3a1b8b3
Fix force pull
andrjohns Apr 4, 2022
039e8a9
Force pull docker image, removed --pull always
serban-nicusor-toptal Apr 4, 2022
7843804
Updated label for pulling VM1
serban-nicusor-toptal Apr 4, 2022
03fd3af
Update Jenkinsfile
andrjohns Apr 4, 2022
1e8a333
Update clang for unit tests
andrjohns Apr 4, 2022
1d20f2d
Merge branch 'develop' into feature/cpp17-pr-1
rok-cesnovar Apr 6, 2022
a5dc3c4
Trigger CI
andrjohns Apr 6, 2022
fd0aa5a
Update github action for c++17
andrjohns Apr 10, 2022
2015377
Opencl size header
andrjohns Apr 10, 2022
229be79
Merge branch 'develop' into feature/cpp17-pr-1
andrjohns Apr 12, 2022
dabceed
Merge branch 'develop' into feature/cpp17-pr-1
andrjohns Apr 12, 2022
c0dec57
Merge branch 'develop' into feature/cpp17-pr-1
rok-cesnovar May 11, 2022
8b2381f
Merge remote-tracking branch 'origin/develop' into HEAD
SteveBronder Jun 1, 2022
98d26cc
Merge branch 'develop' into feature/cpp17-pr-1
andrjohns Jun 17, 2022
67bb1c1
Revert CI changes
andrjohns Jun 17, 2022
78515b6
Un-revert Jenkinsfile change
andrjohns Jun 17, 2022
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
33 changes: 15 additions & 18 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pipeline {
}
environment {
STAN_NUM_THREADS = 4
CLANG_CXX = 'clang++-6.0'
CLANG_CXX = 'clang++-7'
GCC = 'g++'
MPICXX = 'mpicxx.openmpi'
N_TESTS = 150
Expand Down Expand Up @@ -116,7 +116,7 @@ pipeline {
stage("Clang-format") {
agent {
docker {
image 'stanorg/ci:gpu'
image 'stanorg/ci:gpu-cpp17'
label 'linux'
}
}
Expand Down Expand Up @@ -167,7 +167,7 @@ pipeline {
stage('Linting & Doc checks') {
agent {
docker {
image 'stanorg/ci:gpu'
image 'stanorg/ci:gpu-cpp17'
label 'linux'
}
}
Expand Down Expand Up @@ -202,7 +202,7 @@ pipeline {
stage('Verify changes') {
agent {
docker {
image 'stanorg/ci:gpu'
image 'stanorg/ci:gpu-cpp17'
label 'linux'
}
}
Expand All @@ -224,7 +224,7 @@ pipeline {
stage('Headers check') {
agent {
docker {
image 'stanorg/ci:gpu'
image 'stanorg/ci:gpu-cpp17'
label 'linux'
}
}
Expand Down Expand Up @@ -252,7 +252,7 @@ pipeline {
stage('Rev/Fwd Unit Tests') {
agent {
docker {
image 'stanorg/ci:gpu'
image 'stanorg/ci:gpu-cpp17'
label 'linux'
args '--cap-add SYS_PTRACE'
}
Expand All @@ -275,7 +275,7 @@ pipeline {
stage('Mix Unit Tests') {
agent {
docker {
image 'stanorg/ci:gpu'
image 'stanorg/ci:gpu-cpp17'
label 'linux'
args '--cap-add SYS_PTRACE'
}
Expand All @@ -297,7 +297,7 @@ pipeline {
stage('Prim Unit Tests') {
agent {
docker {
image 'stanorg/ci:gpu'
image 'stanorg/ci:gpu-cpp17'
label 'linux'
args '--cap-add SYS_PTRACE'
}
Expand All @@ -313,7 +313,7 @@ pipeline {
script {
runTests("test/unit/*_test.cpp", false)
runTests("test/unit/math/*_test.cpp", false)
runTests("test/unit/math/prim", false)
runTests("test/unit/math/prim", false)
runTests("test/unit/math/memory", false)
}
}
Expand All @@ -332,7 +332,7 @@ pipeline {
stage('MPI tests') {
agent {
docker {
image 'stanorg/ci:gpu'
image 'stanorg/ci:gpu-cpp17'
label 'linux'
}
}
Expand All @@ -352,7 +352,7 @@ pipeline {
stage('OpenCL GPU tests') {
agent {
docker {
image 'stanorg/ci:gpu'
image 'stanorg/ci:gpu-cpp17'
label 'v100'
args '--gpus 1'
}
Expand All @@ -375,9 +375,8 @@ pipeline {
stage('Distribution tests') {
agent {
docker {
image 'stanorg/ci:gpu'
image 'stanorg/ci:gpu-cpp17'
label 'linux'
args '--pull always'
}
}
steps {
Expand Down Expand Up @@ -409,9 +408,8 @@ pipeline {
stage('Expressions test') {
agent {
docker {
image 'stanorg/ci:gpu'
image 'stanorg/ci:gpu-cpp17'
label 'linux'
args '--pull always'
}
}
steps {
Expand Down Expand Up @@ -445,9 +443,8 @@ pipeline {
stage('Threading tests') {
agent {
docker {
image 'stanorg/ci:gpu'
image 'stanorg/ci:gpu-cpp17'
label 'linux'
args '--pull always'
}
}
steps {
Expand Down Expand Up @@ -495,7 +492,7 @@ pipeline {
stage('Upload doxygen') {
agent {
docker {
image 'stanorg/ci:gpu'
image 'stanorg/ci:gpu-cpp17'
label 'linux'
}
}
Expand Down
14 changes: 7 additions & 7 deletions stan/math/opencl/matrix_cl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ class matrix_cl : public matrix_cl_base {
matrix_cl(const int rows, const int cols,
matrix_cl_view partial_view = matrix_cl_view::Entire)
: rows_(rows), cols_(cols), view_(partial_view) {
if (size() == 0) {
if (this->size() == 0) {
return;
}
cl::Context& ctx = opencl_context.context();
Expand Down Expand Up @@ -321,7 +321,7 @@ class matrix_cl : public matrix_cl_base {
matrix_cl_view partial_view = matrix_cl_view::Entire)
: rows_(A.rows()), cols_(A.cols()), view_(partial_view) {
using Mat_type = std::decay_t<ref_type_for_opencl_t<Mat>>;
if (size() == 0) {
if (this->size() == 0) {
return;
}
initialize_buffer_no_heap_if<
Expand Down Expand Up @@ -457,7 +457,7 @@ class matrix_cl : public matrix_cl_base {
return *this;
}
this->wait_for_read_write_events();
if (size() != a.size()) {
if (this->size() != a.size()) {
buffer_cl_ = cl::Buffer(opencl_context.context(), CL_MEM_READ_WRITE,
sizeof(T) * a.size());
}
Expand Down Expand Up @@ -518,7 +518,7 @@ class matrix_cl : public matrix_cl_base {
template <bool in_order = false>
cl::Event initialize_buffer(const T* A) {
cl::Event transfer_event;
if (size() == 0) {
if (this->size() == 0) {
return transfer_event;
}
cl::Context& ctx = opencl_context.context();
Expand All @@ -538,7 +538,7 @@ class matrix_cl : public matrix_cl_base {
template <bool in_order = false>
cl::Event initialize_buffer(T* A) {
cl::Event transfer_event;
if (size() == 0) {
if (this->size() == 0) {
return transfer_event;
}
cl::Context& ctx = opencl_context.context();
Expand Down Expand Up @@ -577,7 +577,7 @@ class matrix_cl : public matrix_cl_base {
*/
template <bool No_heap, typename U, std::enable_if_t<No_heap>* = nullptr>
void initialize_buffer_no_heap_if(U&& obj) {
if (size() == 0) {
if (this->size() == 0) {
return;
}
initialize_buffer(obj.data());
Expand All @@ -587,7 +587,7 @@ class matrix_cl : public matrix_cl_base {
template <bool No_heap, typename U, std::enable_if_t<!No_heap>* = nullptr>
void initialize_buffer_no_heap_if(U&& obj) {
using U_val = std::decay_t<ref_type_for_opencl_t<U>>;
if (size() == 0) {
if (this->size() == 0) {
return;
}
auto* obj_heap = new U_val(std::move(obj));
Expand Down
2 changes: 1 addition & 1 deletion stan/math/opencl/prim/bernoulli_cdf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ return_type_t<T_prob_cl> bernoulli_cdf(const T_n_cl& n,

check_consistent_sizes(function, "Random variable", n,
"Probability parameter", theta);
const size_t N = is_n_vector ? size(n) : size(theta);
const size_t N = is_n_vector ? math::size(n) : math::size(theta);
if (N == 0) {
return 1.0;
}
Expand Down
2 changes: 1 addition & 1 deletion stan/math/opencl/prim/bernoulli_lccdf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ return_type_t<T_prob_cl> bernoulli_lccdf(const T_n_cl& n,

check_consistent_sizes(function, "Random variable", n,
"Probability parameter", theta);
const size_t N = is_n_vector ? size(n) : size(theta);
const size_t N = is_n_vector ? math::size(n) : math::size(theta);
if (N == 0) {
return 0.0;
}
Expand Down
2 changes: 1 addition & 1 deletion stan/math/opencl/prim/bernoulli_lcdf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ return_type_t<T_prob_cl> bernoulli_lcdf(const T_n_cl& n,

check_consistent_sizes(function, "Random variable", n,
"Probability parameter", theta);
const size_t N = is_n_vector ? size(n) : size(theta);
const size_t N = is_n_vector ? math::size(n) : math::size(theta);
if (N == 0) {
return 0.0;
}
Expand Down
7 changes: 4 additions & 3 deletions stan/math/opencl/prim/bernoulli_logit_glm_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@ return_type_t<T_x_cl, T_alpha_cl, T_beta_cl> bernoulli_logit_glm_lpmf(
const size_t M = x.cols();

if (is_y_vector) {
check_size_match(function, "Rows of ", "x", N, "rows of ", "y", size(y));
check_size_match(function, "Rows of ", "x", N, "rows of ", "y",
math::size(y));
}
check_size_match(function, "Columns of ", "x_cl", M, "size of ", "beta",
size(beta));
math::size(beta));
if (is_alpha_vector) {
check_size_match(function, "Rows of ", "x", N, "size of ", "alpha",
size(alpha));
math::size(alpha));
}

if (N == 0) {
Expand Down
2 changes: 1 addition & 1 deletion stan/math/opencl/prim/bernoulli_logit_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ return_type_t<T_prob_cl> bernoulli_logit_lpmf(const T_n_cl& n,

check_consistent_sizes(function, "Random variable", n,
"Probability parameter", theta);
const size_t N = is_n_vector ? size(n) : size(theta);
const size_t N = is_n_vector ? math::size(n) : math::size(theta);
if (N == 0) {
return 0.0;
}
Expand Down
2 changes: 1 addition & 1 deletion stan/math/opencl/prim/bernoulli_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ return_type_t<T_prob_cl> bernoulli_lpmf(const T_n_cl& n,

check_consistent_sizes(function, "Random variable", n,
"Probability parameter", theta);
const size_t N = is_n_vector ? size(n) : size(theta);
const size_t N = is_n_vector ? math::size(n) : math::size(theta);
if (N == 0) {
return 0.0;
}
Expand Down
4 changes: 2 additions & 2 deletions stan/math/opencl/prim/categorical_logit_glm_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ return_type_t<T_x, T_alpha, T_beta> categorical_logit_glm_lpmf(
static const char* function = "categorical_logit_glm_lpmf";
if (is_y_vector) {
check_size_match(function, "Rows of ", "x", N_instances, "size of ", "y",
size(y));
math::size(y));
}
check_size_match(function, "Columns of ", "beta", N_classes, "size of ",
"alpha", size(alpha));
"alpha", math::size(alpha));
check_size_match(function, "Columns of ", "x", N_attributes, "Rows of",
"beta", beta.rows());

Expand Down
9 changes: 5 additions & 4 deletions stan/math/opencl/prim/neg_binomial_2_log_glm_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,18 @@ neg_binomial_2_log_glm_lpmf(const T_y_cl& y, const T_x_cl& x,
const size_t M = x.cols();

if (is_y_vector) {
check_size_match(function, "Rows of ", "x", N, "rows of ", "y", size(y));
check_size_match(function, "Rows of ", "x", N, "rows of ", "y",
math::size(y));
}
check_size_match(function, "Columns of ", "x", M, "size of ", "beta",
size(beta));
math::size(beta));
if (is_phi_vector) {
check_size_match(function, "Rows of ", "x", N, "size of ", "phi",
size(phi));
math::size(phi));
}
if (is_alpha_vector) {
check_size_match(function, "Rows of ", "x", N, "size of ", "alpha",
size(alpha));
math::size(alpha));
}
if (N == 0) {
return 0;
Expand Down
9 changes: 5 additions & 4 deletions stan/math/opencl/prim/normal_id_glm_lpdf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,18 @@ normal_id_glm_lpdf(const T_y_cl& y, const T_x_cl& x, const T_alpha_cl& alpha,
const size_t M = x.cols();

if (is_y_vector) {
check_size_match(function, "Rows of ", "x", N, "rows of ", "y", size(y));
check_size_match(function, "Rows of ", "x", N, "rows of ", "y",
math::size(y));
}
check_size_match(function, "Columns of ", "x_cl", M, "size of ", "beta",
size(beta));
math::size(beta));
if (is_sigma_vector) {
check_size_match(function, "Rows of ", "x", N, "size of ", "sigma",
size(sigma));
math::size(sigma));
}
if (is_alpha_vector) {
check_size_match(function, "Rows of ", "x", N, "size of ", "alpha",
size(alpha));
math::size(alpha));
}
if (!include_summand<propto, T_y_cl, T_x_cl, T_alpha_cl, T_beta_cl,
T_sigma_cl>::value) {
Expand Down
3 changes: 2 additions & 1 deletion stan/math/opencl/prim/num_elements.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#ifdef STAN_OPENCL

#include <stan/math/prim/meta.hpp>
#include <stan/math/opencl/prim/size.hpp>

namespace stan {
namespace math {
Expand All @@ -16,7 +17,7 @@ namespace math {
template <typename T,
require_nonscalar_prim_or_rev_kernel_expression_t<T>* = nullptr>
size_t num_elements(const T& m) {
return size(m);
return math::size(m);
}

} // namespace math
Expand Down
10 changes: 5 additions & 5 deletions stan/math/opencl/prim/ordered_logistic_glm_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,19 @@ return_type_t<T_x, T_beta, T_cuts> ordered_logistic_glm_lpmf(

const size_t N_instances = x.rows();
const size_t N_attributes = x.cols();
const size_t N_classes = size(cuts) + 1;
const size_t N_classes = math::size(cuts) + 1;

if (is_y_vector) {
check_size_match(function, "Rows of ", "x", N_instances, "rows of ", "y",
size(y));
math::size(y));
}
check_size_match(function, "Columns of ", "x", N_attributes, "Size of",
"beta", size(beta));
"beta", math::size(beta));

const auto& cuts_val = eval(value_of(cuts));
if (N_classes >= 2) {
auto cuts_head = block_zero_based(cuts_val, 0, 0, size(cuts) - 1, 1);
auto cuts_tail = block_zero_based(cuts_val, 1, 0, size(cuts) - 1, 1);
auto cuts_head = block_zero_based(cuts_val, 0, 0, math::size(cuts) - 1, 1);
auto cuts_tail = block_zero_based(cuts_val, 1, 0, math::size(cuts) - 1, 1);
check_cl(function, "Cuts", cuts_head, "ordered and finite")
= cuts_head < cuts_tail && isfinite(cuts_head) && isfinite(cuts_tail);
} else {
Expand Down
4 changes: 2 additions & 2 deletions stan/math/opencl/prim/ordered_logistic_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ inline return_type_t<T_y_cl, T_loc_cl, T_cuts_cl> ordered_logistic_lpmf(
static const char* function = "ordered_logistic_lpmf(OpenCL)";

if (size(y) != 1) {
check_size_match(function, "Size of ", "y", size(y), "Size of", "lambda",
size(lambda));
check_size_match(function, "Size of ", "y", math::size(y), "Size of",
"lambda", math::size(lambda));
}

int N_instances = max_size(y, lambda);
Expand Down
7 changes: 4 additions & 3 deletions stan/math/opencl/prim/poisson_log_glm_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@ return_type_t<T_x_cl, T_alpha_cl, T_beta_cl> poisson_log_glm_lpmf(
const size_t M = x.cols();

if (is_y_vector) {
check_size_match(function, "Rows of ", "x", N, "rows of ", "y", size(y));
check_size_match(function, "Rows of ", "x", N, "rows of ", "y",
math::size(y));
}
check_size_match(function, "Columns of ", "x_cl", M, "size of ", "beta",
size(beta));
math::size(beta));
if (is_alpha_vector) {
check_size_match(function, "Rows of ", "x", N, "size of ", "alpha",
size(alpha));
math::size(alpha));
}
if (N == 0) {
return 0;
Expand Down
Loading