From afb55c7d8aff1b090a92e19db87f6b290effdd89 Mon Sep 17 00:00:00 2001 From: Daniel Sharp Date: Tue, 13 Feb 2024 17:56:17 -0500 Subject: [PATCH] Fixing sigmoid.h and small LA --- MParT/Sigmoid.h | 8 ++++---- tests/Test_LinearAlgebra.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/MParT/Sigmoid.h b/MParT/Sigmoid.h index bfd817cf..138e551b 100644 --- a/MParT/Sigmoid.h +++ b/MParT/Sigmoid.h @@ -109,7 +109,7 @@ class Sigmoid1d { Kokkos::View widths) : centers_(centers), widths_(widths) { Kokkos::View weights ("Sigmoid weights", centers.extent(0)); - Kokkos::parallel_for(centers.extent(0), KOKKOS_LAMBDA(unsigned int i) { weights(i) = 1.; }); + Kokkos::deep_copy(weights, 1.0); weights_ = weights; Validate(); } @@ -121,7 +121,7 @@ class Sigmoid1d { * @param max_order Maximum order of basis function to evaluate * @param input Point to evaluate function */ - void EvaluateAll(double* output, int max_order, double input) const { + KOKKOS_FUNCTION void EvaluateAll(double* output, int max_order, double input) const { if (order_ < max_order) { std::stringstream ss; ss << "Sigmoid basis evaluation order too large.\n"; @@ -164,7 +164,7 @@ class Sigmoid1d { * @param max_order Number of sigmoids to evaluate * @param input Where to evaluate sigmoids */ - void EvaluateDerivatives(double* output, double* output_diff, int max_order, + KOKKOS_FUNCTION void EvaluateDerivatives(double* output, double* output_diff, int max_order, double input) const { if (order_ < max_order) { std::stringstream ss; @@ -218,7 +218,7 @@ class Sigmoid1d { * @param max_order Maximum order of sigmoid to evaluate * @param input Where to evaluate the sigmoids */ - void EvaluateSecondDerivatives(double* output, double* output_diff, + KOKKOS_FUNCTION void EvaluateSecondDerivatives(double* output, double* output_diff, double* output_diff2, int max_order, double input) const { if (order_ < max_order) { diff --git a/tests/Test_LinearAlgebra.cpp b/tests/Test_LinearAlgebra.cpp index d51ded4f..05b854c5 100644 --- a/tests/Test_LinearAlgebra.cpp +++ b/tests/Test_LinearAlgebra.cpp @@ -150,7 +150,7 @@ TEST_CASE( "Testing LU Factorization", "LinearAlgebra_LU" ) { B(1,0) = 2.; B(1,1) = 5.; B(2,0) = 3.; B(2,1) = 6.; - auto constA = ToConstKokkos(A.data(), 3, 3); + Kokkos::View constA = A; auto eigA = ConstKokkosToMat(constA); auto eigB = KokkosToMat(B); unsigned int nrows = eigA.rows(); @@ -197,7 +197,7 @@ TEST_CASE( "Testing Cholesky Factorization", "LinearAlgebra_Cholesky" ) { B(1,0) = 2.; B(1,1) = 5.; B(2,0) = 3.; B(2,1) = 6.; - auto constA = ToConstKokkos(A.data(), 3, 3); + Kokkos::View constA = A; auto eigA = ConstKokkosToMat(constA); auto eigB = KokkosToMat(B); unsigned int nrows = eigA.rows(); @@ -364,7 +364,7 @@ TEST_CASE( "Testing LU Factorization on Device", "LinearAlgebra_LUDevice" ) { B(1,0) = 2.; B(1,1) = 5.; B(2,0) = 3.; B(2,1) = 6.; - auto constA = ToConstKokkos(A.data(), 3, 3); + Kokkos::View constA = A; auto constA_d = ToDevice(constA); auto B_d = ToDevice(B); auto eigA = ConstKokkosToMat(constA); @@ -415,7 +415,7 @@ TEST_CASE( "Testing Cholesky Factorization", "LinearAlgebra_Cholesky" ) { B_h(1,0) = 2.; B_h(1,1) = 5.; B_h(2,0) = 3.; B_h(2,1) = 6.; - auto constA_h = ToConstKokkos(A.data(), 3, 3); + Kokkos::View constA_h = A; auto constA_d = ToDevice(constA_h); auto B_d = ToDevice(B); auto eigA = ConstKokkosToMat(constA_h);