Skip to content

Commit

Permalink
Modify tests to enable printing the derivative code and only test CHE…
Browse files Browse the repository at this point in the history
…CK-EXEC for the reverse mode.
  • Loading branch information
PetroZarytskyi committed Aug 15, 2023
1 parent b11ccab commit 697624d
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion test/Arrays/ArrayInputsReverseMode.C
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/Gradient/TestTypeConversion.C
Original file line number Diff line number Diff line change
@@ -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:.*}}
Expand Down
2 changes: 1 addition & 1 deletion test/Gradient/constexprTest.C
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion test/Hessian/NestedFunctionCalls.C
Original file line number Diff line number Diff line change
@@ -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:.*}}
Expand Down
6 changes: 3 additions & 3 deletions test/Jacobian/constexprTest.C
Original file line number Diff line number Diff line change
@@ -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:.*}}

Expand Down Expand Up @@ -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}
}
}
3 changes: 1 addition & 2 deletions test/Jacobian/testUtility.C
Original file line number Diff line number Diff line change
@@ -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:.*}}

Expand Down Expand Up @@ -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}

}

12 changes: 6 additions & 6 deletions test/Misc/RunDemos.C
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<float> _d_x, clad::array_ref<unsigned int> _d_n, double &_final_error) {
Expand Down Expand Up @@ -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{{.*}}

Expand Down Expand Up @@ -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{{.*}}

Expand Down Expand Up @@ -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<double> _d_theta_0, clad::array_ref<double> _d_theta_1, clad::array_ref<double> _d_x) {
//CHECK_GRADIENT_DESCENT-NEXT: double _t0;
Expand Down
4 changes: 2 additions & 2 deletions test/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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) )
Expand Down

0 comments on commit 697624d

Please sign in to comment.