From 43a9b70f5802b57e5507f61997584f59fdbeefb6 Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Wed, 6 Nov 2024 18:11:12 +0100 Subject: [PATCH 01/10] rm fov_forward test, feature not supported --- .../boost-test/traceFixedPointScalarTests.cpp | 45 ------------------- 1 file changed, 45 deletions(-) diff --git a/ADOL-C/boost-test/traceFixedPointScalarTests.cpp b/ADOL-C/boost-test/traceFixedPointScalarTests.cpp index 406fd2b3..b6fa593d 100644 --- a/ADOL-C/boost-test/traceFixedPointScalarTests.cpp +++ b/ADOL-C/boost-test/traceFixedPointScalarTests.cpp @@ -128,50 +128,5 @@ BOOST_AUTO_TEST_CASE(NewtonScalarFixedPoint_fos_forward) BOOST_TEST(derivative[0] == exactDerivative, tt::tolerance(tol)); } -BOOST_AUTO_TEST_CASE(NewtonForSquareRootFixedPoint_fov_forward) -{ - // Compute the square root of 2.0 - const double argument[1] = {2.0}; - double out = traceNewtonForSquareRoot(1, // tape number - 2, - argument[0]); - - // Did taping really produce the correct value? - BOOST_TEST(out == std::sqrt(argument[0]), tt::tolerance(tol)); - - // Use fov_forward to compute the first derivative - int m = 1; // Number of dependent variables - int n = 1; // Number of independent variables - int p = 1; // Number of tangents - - double **xd = myalloc2(n, p); - double value[m]; - double **yd = myalloc2(m, p); - - /* Test partial derivative wrt x1 and x2. */ - for (int i = 0; i < n; i++) { - for (int j = 0; j < p; j++) { - xd[i][j] = (i == j) ? 1.0 : 0.0; - } - } - - fov_forward(1, // Tape number - m, // Number of dependent variables - n, // Number of independent variables - p, // Number of tangents - argument, // Where to evaluate the derivative - xd, // The tangents - value, // The compute function value - yd); // The computed derivative - - double exactDerivative = 1.0/(2*sqrt(argument[0])); - - BOOST_TEST(value[0] == out, tt::tolerance(tol)); - BOOST_TEST(yd[0][0] == exactDerivative, tt::tolerance(tol)); - - myfree2(xd); - myfree2(yd); -} - BOOST_AUTO_TEST_SUITE_END() From bfda65710d0d9c8ef55fcc0b8584440b52e70080 Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Thu, 7 Nov 2024 09:04:48 +0100 Subject: [PATCH 02/10] rm prints --- ADOL-C/src/fixpoint.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/ADOL-C/src/fixpoint.cpp b/ADOL-C/src/fixpoint.cpp index 82e2080e..fa8bc84c 100644 --- a/ADOL-C/src/fixpoint.cpp +++ b/ADOL-C/src/fixpoint.cpp @@ -144,7 +144,6 @@ static int fp_hos_reverse ( int dim_x, double *x_fix_bar, int dim_xu, double *xu for (i=0; inorm_deriv)(xi,dim_x); - printf(" fp_fos_reverse: k = %d err = %e\n",k,err); if (errepsilon_deriv) { for (i=0; i Date: Thu, 7 Nov 2024 09:05:51 +0100 Subject: [PATCH 03/10] rm fp_hos_reverse -> just a copy of fp_fos_reverse --- ADOL-C/src/fixpoint.cpp | 39 --------------------------------------- 1 file changed, 39 deletions(-) diff --git a/ADOL-C/src/fixpoint.cpp b/ADOL-C/src/fixpoint.cpp index fa8bc84c..461eb156 100644 --- a/ADOL-C/src/fixpoint.cpp +++ b/ADOL-C/src/fixpoint.cpp @@ -120,45 +120,6 @@ static int fp_fos_forward ( int dim_xu, double *xu, double *xu_dot, return -1; } -static int fp_hos_reverse ( int dim_x, double *x_fix_bar, int dim_xu, double *xu_bar, double* /*unused*/, double* /*unused*/) { - // (d x_fix) / (d x_0) = 0 (!) - int i, k; - double err; - ADOLC_OPENMP_THREAD_NUMBER; - ADOLC_OPENMP_GET_THREAD_NUMBER; - locint edf_index = ADOLC_CURRENT_TAPE_INFOS.ext_diff_fct_index; - - // Find fpi_stack element with index 'edf_index'. - auto current = std::find_if(fpi_stack.begin(), fpi_stack.end(), [&](auto&& v){return v.edf_index == edf_index;}); - - if (current==fpi_stack.end()) { - fprintf(stderr,"ADOL-C Error! No edf found for fixpoint iteration.\n"); - adolc_exit(-1,"",__func__,__FILE__,__LINE__); - } - double *U = new double[dim_xu]; - double *xi = new double[dim_x]; - - for (k=1; kN_max_deriv; k++) { - for (i=0; isub_tape_num, dim_x, dim_xu, xi, U ); - for (i=0; inorm_deriv)(xi,dim_x); - if (errepsilon_deriv) { - for (i=0; i Date: Thu, 7 Nov 2024 09:06:28 +0100 Subject: [PATCH 04/10] rm line, did nothing since hos was same as fos --- ADOL-C/src/fixpoint.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/ADOL-C/src/fixpoint.cpp b/ADOL-C/src/fixpoint.cpp index 461eb156..cc202ea2 100644 --- a/ADOL-C/src/fixpoint.cpp +++ b/ADOL-C/src/fixpoint.cpp @@ -184,7 +184,6 @@ ADOLC_DLL_EXPORT int fp_iteration ( int sub_tape_num, edf_iteration->zos_forward = &fp_zos_forward; edf_iteration->fos_forward = &fp_fos_forward; edf_iteration->fos_reverse = &fp_fos_reverse; - edf_iteration->fos_reverse = &fp_hos_reverse; // add new fp information fpi_data data; From 16cc1ff31f63c95f61e78ee453eddfe1e70bd0ad Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Thu, 7 Nov 2024 09:06:49 +0100 Subject: [PATCH 05/10] rm prints --- ADOL-C/src/fixpoint.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/ADOL-C/src/fixpoint.cpp b/ADOL-C/src/fixpoint.cpp index cc202ea2..989c5c71 100644 --- a/ADOL-C/src/fixpoint.cpp +++ b/ADOL-C/src/fixpoint.cpp @@ -145,7 +145,6 @@ static int fp_fos_reverse ( int dim_x, double *x_fix_bar, int dim_xu, double *xu for (i=0; inorm_deriv)(xi,dim_x); - printf(" fp_fos_reverse: k = %d err = %e\n",k,err); if (errepsilon_deriv) { for (i=0; i Date: Thu, 7 Nov 2024 09:08:19 +0100 Subject: [PATCH 06/10] copy data after first it, this caused the error in test --- ADOL-C/src/fixpoint.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ADOL-C/src/fixpoint.cpp b/ADOL-C/src/fixpoint.cpp index 989c5c71..dbb6b487 100644 --- a/ADOL-C/src/fixpoint.cpp +++ b/ADOL-C/src/fixpoint.cpp @@ -106,8 +106,10 @@ static int fp_fos_forward ( int dim_xu, double *xu, double *xu_dot, adolc_exit(-1,"",__func__,__FILE__,__LINE__); } for (k=1; (kN_max_deriv)|(kN_max); k++) { + if (k > 1){ for (i=0; isub_tape_num, dim_x, dim_xu, 0, xu, xu_dot, x_fix, x_fix_dot); for (i=0; inorm)(xu,dim_x); From 00a5444cd3ad17a242e998e51e5ba31266273496 Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Thu, 7 Nov 2024 09:18:26 +0100 Subject: [PATCH 07/10] mv adouble inits --- ADOL-C/boost-test/traceFixedPointScalarTests.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ADOL-C/boost-test/traceFixedPointScalarTests.cpp b/ADOL-C/boost-test/traceFixedPointScalarTests.cpp index b6fa593d..1702c741 100644 --- a/ADOL-C/boost-test/traceFixedPointScalarTests.cpp +++ b/ADOL-C/boost-test/traceFixedPointScalarTests.cpp @@ -41,13 +41,15 @@ static double norm(double* x, int dim) static double traceNewtonForSquareRoot(int tapeNumber, int subTapeNumber, double argument) { + //ax1 = sqrt(ax1); + adouble x = 2.5; // Initial iterate + adouble y; + double out; trace_on(tapeNumber); adouble u; u <<= argument; - //ax1 = sqrt(ax1); - adouble x = 2.5; // Initial iterate - adouble y; + fp_iteration(subTapeNumber, iteration, @@ -63,8 +65,6 @@ static double traceNewtonForSquareRoot(int tapeNumber, int subTapeNumber, double &y, // [out] Final state of the iteration 1, // Size of the vector x_0 1); // Number of parameters - - double out; y >>= out; trace_off(); From 96c802e89212680135955bca209e53898832cd5e Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Thu, 7 Nov 2024 09:31:17 +0100 Subject: [PATCH 08/10] test if ensurecontiguouslocations fix issue --- ADOL-C/boost-test/traceFixedPointScalarTests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ADOL-C/boost-test/traceFixedPointScalarTests.cpp b/ADOL-C/boost-test/traceFixedPointScalarTests.cpp index 1702c741..d404c9b6 100644 --- a/ADOL-C/boost-test/traceFixedPointScalarTests.cpp +++ b/ADOL-C/boost-test/traceFixedPointScalarTests.cpp @@ -86,7 +86,7 @@ BOOST_AUTO_TEST_CASE(NewtonScalarFixedPoint_zos_forward) BOOST_TEST(out == std::sqrt(argument[0]), tt::tolerance(tol)); double value[1]; - + ensureContiguousLocations(100); zos_forward(1, // Tape number 1, // Number of dependent variables 1, // Number of indepdent variables From 9ff6e6147b14f7be25a25d42db0b79d76f0d0df6 Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Thu, 7 Nov 2024 09:34:24 +0100 Subject: [PATCH 09/10] mv fct --- ADOL-C/boost-test/traceFixedPointScalarTests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ADOL-C/boost-test/traceFixedPointScalarTests.cpp b/ADOL-C/boost-test/traceFixedPointScalarTests.cpp index d404c9b6..d862e7bd 100644 --- a/ADOL-C/boost-test/traceFixedPointScalarTests.cpp +++ b/ADOL-C/boost-test/traceFixedPointScalarTests.cpp @@ -76,6 +76,7 @@ static double traceNewtonForSquareRoot(int tapeNumber, int subTapeNumber, double */ BOOST_AUTO_TEST_CASE(NewtonScalarFixedPoint_zos_forward) { + ensureContiguousLocations(100); // Compute the square root of 2.0 const double argument[1] = {2.0}; double out = traceNewtonForSquareRoot(1, // tape number @@ -86,7 +87,6 @@ BOOST_AUTO_TEST_CASE(NewtonScalarFixedPoint_zos_forward) BOOST_TEST(out == std::sqrt(argument[0]), tt::tolerance(tol)); double value[1]; - ensureContiguousLocations(100); zos_forward(1, // Tape number 1, // Number of dependent variables 1, // Number of indepdent variables From e5dcfebb62a0ed1c83c370a75bf4d34f59288fc9 Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Thu, 7 Nov 2024 09:40:02 +0100 Subject: [PATCH 10/10] reduce the number of contiguous blocks to 5 --- ADOL-C/boost-test/traceFixedPointScalarTests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ADOL-C/boost-test/traceFixedPointScalarTests.cpp b/ADOL-C/boost-test/traceFixedPointScalarTests.cpp index d862e7bd..9b739157 100644 --- a/ADOL-C/boost-test/traceFixedPointScalarTests.cpp +++ b/ADOL-C/boost-test/traceFixedPointScalarTests.cpp @@ -76,7 +76,7 @@ static double traceNewtonForSquareRoot(int tapeNumber, int subTapeNumber, double */ BOOST_AUTO_TEST_CASE(NewtonScalarFixedPoint_zos_forward) { - ensureContiguousLocations(100); + ensureContiguousLocations(5); // Compute the square root of 2.0 const double argument[1] = {2.0}; double out = traceNewtonForSquareRoot(1, // tape number