From 697624dd5ac816ed0d098c0eadf82bdcc32850b8 Mon Sep 17 00:00:00 2001 From: "petro.zarytskyi" Date: Tue, 15 Aug 2023 20:54:03 +0300 Subject: [PATCH] Modify tests to enable printing the derivative code and only test CHECK-EXEC for the reverse mode. --- test/Arrays/ArrayInputsReverseMode.C | 2 +- test/Gradient/TestTypeConversion.C | 2 +- test/Gradient/constexprTest.C | 2 +- test/Hessian/NestedFunctionCalls.C | 2 +- test/Jacobian/constexprTest.C | 6 +++--- test/Jacobian/testUtility.C | 3 +-- test/Misc/RunDemos.C | 12 ++++++------ test/lit.cfg | 4 ++-- 8 files changed, 16 insertions(+), 17 deletions(-) diff --git a/test/Arrays/ArrayInputsReverseMode.C b/test/Arrays/ArrayInputsReverseMode.C index 99bbe92d9..4b4a1fd5d 100644 --- a/test/Arrays/ArrayInputsReverseMode.C +++ b/test/Arrays/ArrayInputsReverseMode.C @@ -390,7 +390,7 @@ int main() { auto nested = clad::gradient(func3); nested.execute(a3, b, da3, db2); - printf("Result (b) = {%.2f, %.2f, %.2f}\n", db2[0], db2[1], db2[2]); // CHECK-EXEC: Result (b) = {0.00, 0.00, 0.00} + printf("Result (b) = {%.2f, %.2f, %.2f}\n", db2[0], db2[1], db2[2]); // CHECK-EXEC: Result (b) = {1.00, 1.00, 1.00} auto constArray = clad::gradient(func4); double _dx = 0; diff --git a/test/Gradient/TestTypeConversion.C b/test/Gradient/TestTypeConversion.C index d821e2742..6235d81f3 100644 --- a/test/Gradient/TestTypeConversion.C +++ b/test/Gradient/TestTypeConversion.C @@ -1,4 +1,4 @@ -// RUN: %cladnumdiffclang %s -I%S/../../include -oTestTypeConversion.out 2>&1 | FileCheck %s +// RUN: %cladnumdiffclang %s -I%S/../../include -oTestTypeConversion.out // RUN: ./TestTypeConversion.out | FileCheck -check-prefix=CHECK-EXEC %s //CHECK-NOT: {{.*error|warning|note:.*}} diff --git a/test/Gradient/constexprTest.C b/test/Gradient/constexprTest.C index 72c9a46cb..95586d08f 100644 --- a/test/Gradient/constexprTest.C +++ b/test/Gradient/constexprTest.C @@ -1,4 +1,4 @@ -// RUN: %cladclang %s -I%S/../../include -oconstexprTest.out | FileCheck %s +// RUN: %cladclang %s -I%S/../../include -oconstexprTest.out // RUN: ./constexprTest.out | FileCheck -check-prefix=CHECK-EXEC %s #include "clad/Differentiator/Differentiator.h" diff --git a/test/Hessian/NestedFunctionCalls.C b/test/Hessian/NestedFunctionCalls.C index 7518c0aa1..c74336af8 100644 --- a/test/Hessian/NestedFunctionCalls.C +++ b/test/Hessian/NestedFunctionCalls.C @@ -1,4 +1,4 @@ -// RUN: %cladclang %s -I%S/../../include -oNestedFunctionCalls.out 2>&1 | FileCheck %s +// RUN: %cladclang %s -I%S/../../include -oNestedFunctionCalls.out // RUN: ./NestedFunctionCalls.out | FileCheck -check-prefix=CHECK-EXEC %s // CHECK-NOT: {{.*error|warning|note:.*}} diff --git a/test/Jacobian/constexprTest.C b/test/Jacobian/constexprTest.C index 8fa166511..84e60b5c6 100644 --- a/test/Jacobian/constexprTest.C +++ b/test/Jacobian/constexprTest.C @@ -1,4 +1,4 @@ -// RUN: %cladclang %s -I%S/../../include -std=c++14 -oconstexprTest.out 2>&1 | FileCheck %s +// RUN: %cladclang %s -I%S/../../include -std=c++14 -oconstexprTest.out // RUN: ./constexprTest.out | FileCheck -check-prefix=CHECK-EXEC %s // CHECK-NOT: {{.*error|warning|note:.*}} @@ -134,10 +134,10 @@ constexpr void f_1(double x, double y, double z, double output[]) { //CHECK-NEXT:} int main() { - + INIT_JACOBIAN(fn_mul); INIT_JACOBIAN(f_1); TEST_JACOBIAN(fn_mul, 2, 6, 3, 1, result, jacobianou); // CHECK-EXEC: {6.00, 0.00, 0.00, 2.00, 1.00, 3.00} TEST_JACOBIAN(f_1, 3, 9, 4, 5, 6, result1, jacobianou1); // CHECK-EXEC: {48.00, 0.00, 0.00, 80.00, 32.00, 0.00, 60.00, -6.00, 35.00} -} \ No newline at end of file +} diff --git a/test/Jacobian/testUtility.C b/test/Jacobian/testUtility.C index 9919e7095..eacf96fa2 100644 --- a/test/Jacobian/testUtility.C +++ b/test/Jacobian/testUtility.C @@ -1,4 +1,4 @@ -// RUN: %cladclang %s -I%S/../../include -otestUtility.out 2>&1 | FileCheck %s +// RUN: %cladclang %s -I%S/../../include -otestUtility.out // RUN: ./testUtility.out | FileCheck -check-prefix=CHECK-EXEC %s // CHECK-NOT: {{.*error|warning|note:.*}} @@ -142,4 +142,3 @@ int main(){ TEST_JACOBIAN(f_1, 3, 9, 4, 5, 6, output1, jacobian1); // CHECK-EXEC: {48.00, 0.00, 0.00, 80.00, 32.00, 0.00, 60.00, -6.00, 35.00} } - diff --git a/test/Misc/RunDemos.C b/test/Misc/RunDemos.C index 6e000b119..fc10758ef 100644 --- a/test/Misc/RunDemos.C +++ b/test/Misc/RunDemos.C @@ -9,7 +9,7 @@ // Demo: Gradient.cpp //-----------------------------------------------------------------------------/ -// RUN: %cladclang %S/../../demos/Gradient.cpp -I%S/../../include -oGradient.out 2>&1 | FileCheck -check-prefix CHECK_GRADIENT %s +// RUN: %cladclang %S/../../demos/Gradient.cpp -I%S/../../include -oGradient.out // CHECK_GRADIENT-NOT:{{.*error|warning|note:.*}} // CHECK_GRADIENT:float sphere_implicit_func_darg0(float x, float y, float z, float xc, float yc, float zc, float r) { // CHECK_GRADIENT: float _d_x = 1; @@ -68,7 +68,7 @@ //-----------------------------------------------------------------------------/ // Demo: Rosenbrock Function //-----------------------------------------------------------------------------/ -// RUN: %cladclang %S/../../demos/RosenbrockFunction.cpp -I%S/../../include -oRosenbrockFunction.out 2>&1 | FileCheck -check-prefix CHECK_ROSENBROCK %s +// RUN: %cladclang %S/../../demos/RosenbrockFunction.cpp -I%S/../../include -oRosenbrockFunction.out // CHECK_ROSENBROCK-NOT:{{.*error|warning|note:.*}} // CHECK_ROSENBROCK:double rosenbrock_func_darg0(double x, double y) { // CHECK_ROSENBROCK: double _d_x = 1; @@ -102,7 +102,7 @@ // Demo: Error Estimation Float Sum //-----------------------------------------------------------------------------/ -// RUN: %cladclang %S/../../demos/ErrorEstimation/FloatSum.cpp -I%S/../../include 2>&1 | FileCheck -check-prefix CHECK_FLOAT_SUM %s +// RUN: %cladclang %S/../../demos/ErrorEstimation/FloatSum.cpp -I%S/../../include //CHECK_FLOAT_SUM-NOT: {{.*error|warning|note:.*}} //CHECK_FLOAT_SUM: void vanillaSum_grad(float x, unsigned int n, clad::array_ref _d_x, clad::array_ref _d_n, double &_final_error) { @@ -145,7 +145,7 @@ // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -fcustom-estimation-model \ // RUN: -Xclang -plugin-arg-clad -Xclang %clad_obj_root/demos/ErrorEstimation/CustomModel/libcladCustomModelPlugin%shlibext \ // RUN: %S/../../demos/ErrorEstimation/CustomModel/test.cpp \ -// RUN: -I%S/../../include -oCustomModelTest.out | FileCheck -check-prefix CHECK_CUSTOM_MODEL %s +// RUN: -I%S/../../include -oCustomModelTest.out // CHECK_CUSTOM_MODEL-NOT: Could not load {{.*}}cladCustomModelPlugin{{.*}} @@ -184,7 +184,7 @@ // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -fcustom-estimation-model \ // RUN: -Xclang -plugin-arg-clad -Xclang %clad_obj_root/demos/ErrorEstimation/PrintModel/libcladPrintModelPlugin%shlibext \ // RUN: %S/../../demos/ErrorEstimation/PrintModel/test.cpp \ -// RUN: -I%S/../../include -oPrintModelTest.out | FileCheck -check-prefix CHECK_PRINT_MODEL %s +// RUN: -I%S/../../include -oPrintModelTest.out // CHECK_PRINT_MODEL-NOT: Could not load {{.*}}cladPrintModelPlugin{{.*}} @@ -223,7 +223,7 @@ //-----------------------------------------------------------------------------/ // Demo: Gradient Descent //-----------------------------------------------------------------------------/ -// RUN: %cladclang %S/../../demos/GradientDescent.cpp -I%S/../../include -oGradientDescent.out | FileCheck -check-prefix CHECK_GRADIENT_DESCENT %s +// RUN: %cladclang %S/../../demos/GradientDescent.cpp -I%S/../../include -oGradientDescent.out //CHECK_GRADIENT_DESCENT: void f_pullback(double theta_0, double theta_1, double x, double _d_y, clad::array_ref _d_theta_0, clad::array_ref _d_theta_1, clad::array_ref _d_x) { //CHECK_GRADIENT_DESCENT-NEXT: double _t0; diff --git a/test/lit.cfg b/test/lit.cfg index 2d06ae85e..62ba8de32 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -253,8 +253,8 @@ lit.util.usePlatformSdkOnDarwin(config, lit_config) #\ -plugin-arg-ad -Xclang -fdump-derived-fn -Xclang -load -Xclang../../Debug+Asserts/lib/libclad.so #FIXME: we need to introduce a better way to check compatible version of clang, propagating #-fvalidate-clang-version flag is not enough. -flags = ' -std=c++11 -Xclang -add-plugin -Xclang clad\ - -Xclang \ +flags = ' -std=c++11 -Xclang -add-plugin -Xclang clad -Xclang \ + -plugin-arg-clad -Xclang -fdump-derived-fn -Xclang \ -load -Xclang ' + config.cladlib config.substitutions.append( ('%cladclang_cuda', config.clang + flags) )