From d92866f9ddf8c016e373310b38b868372cb7e36b Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Sat, 31 Aug 2024 08:42:14 +0000 Subject: [PATCH 01/14] [cuda][ci] Run the cuda tests on a self-hosted runner with a gpu. --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8cf88d095..bc4c485ed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -238,11 +238,11 @@ jobs: clang-runtime: '10' cuda: true - - name: selfh-ubu20-clang9-runtime10-cuda - os: self-hosted #ubuntu-20.04 + - name: selfh-ubu22-clang16-runtime18-cuda + os: self-hosted #ubuntu-22.04 runs-on: cuda - compiler: clang-9 - clang-runtime: '10' + compiler: clang-16 + clang-runtime: '18' cuda: true - name: ubu20-clang9-runtime15 From 487fd32840a84359efc14be728b0c7eb768110c6 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Tue, 10 Sep 2024 13:08:21 +0000 Subject: [PATCH 02/14] List skipped and unsupported tests to hint what ran. --- test/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 557134fb9..783cf1959 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -36,9 +36,9 @@ configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py ) -option(CLANG_TEST_USE_VG "Run Clang tests under Valgrind" OFF) -if(CLANG_TEST_USE_VG) - set(CLANG_TEST_EXTRA_ARGS ${CLANG_TEST_EXTRA_ARGS} "--vg") +option(CLAD_TEST_USE_VG "Run Clang tests under Valgrind" OFF) +if(CLAD_TEST_USE_VG) + set(CLAD_TEST_EXTRA_ARGS ${CLAD_TEST_EXTRA_ARGS} "--vg") endif () list(APPEND CLAD_TEST_DEPS clad cladCustomModelPlugin cladPrintModelPlugin) @@ -68,7 +68,7 @@ add_lit_testsuite(check-clad "Running the Clad regression tests" LIT ${LIT_COMMAND} PARAMS ${CLAD_TEST_PARAMS} DEPENDS ${CLAD_TEST_DEPS} - ARGS ${CLAD_TEST_EXTRA_ARGS} --verbose --succinct + ARGS ${CLAD_TEST_EXTRA_ARGS} --show-skipped --show-unsupported ) set_target_properties(check-clad PROPERTIES FOLDER "Clad tests") From 2b363500b859f3a19f64bc2bd6629de6878a8c76 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Tue, 10 Sep 2024 16:12:15 +0000 Subject: [PATCH 03/14] Teach lit to find cuda and add useful substitutions --- test/CMakeLists.txt | 27 +++++++++++++++++++++++++++ test/lit.cfg | 13 +++++-------- test/lit.site.cfg.in | 4 ++++ 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 783cf1959..715af0971 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -24,6 +24,33 @@ if(CLAD_BUILT_STANDALONE) set(LLVM_LIBS_DIR ${LLVM_INSTALL_PREFIX}/lib/) endif() +find_package(CUDAToolkit QUIET) +if(CUDAToolkit_FOUND) + get_filename_component(CUDA_ROOT "${CUDAToolkit_BIN_DIR}" DIRECTORY ABSOLUTE) + get_filename_component(CUDA_LIBDIR "${CUDA_cudart_static_LIBRARY}" DIRECTORY) + + set(LIBOMPTARGET_DEP_CUDA_ARCH "sm_50") + + if(TARGET nvptx-arch) + get_property(LIBOMPTARGET_NVPTX_ARCH TARGET nvptx-arch PROPERTY LOCATION) + endif() + if (NOT EXISTS ${LIBOMPTARGET_NVPTX_ARCH}) + find_program(LIBOMPTARGET_NVPTX_ARCH NAMES nvptx-arch) + endif() + + if(LIBOMPTARGET_NVPTX_ARCH) + execute_process(COMMAND ${LIBOMPTARGET_NVPTX_ARCH} + OUTPUT_VARIABLE LIBOMPTARGET_NVPTX_ARCH_OUTPUT + OUTPUT_STRIP_TRAILING_WHITESPACE) + string(REPLACE "\n" ";" nvptx_arch_list "${LIBOMPTARGET_NVPTX_ARCH_OUTPUT}") + if(nvptx_arch_list) + set(LIBOMPTARGET_FOUND_NVIDIA_GPU TRUE) + set(LIBOMPTARGET_NVPTX_DETECTED_ARCH_LIST "${nvptx_arch_list}") + list(GET nvptx_arch_list 0 LIBOMPTARGET_DEP_CUDA_ARCH) + endif() + endif() +endif(CUDAToolkit_FOUND) + configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg diff --git a/test/lit.cfg b/test/lit.cfg index 59baa61b8..1da159f84 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -323,23 +323,20 @@ if clang_repl_path: #if loadable_module: # config.available_features.add('loadable_module') -libcudart_path = lit.util.which('libcudart.so', config.environment.get('LD_LIBRARY_PATH','')) +libcudart_path = lit.util.which('libcudart.so', config.cuda_libdir) if libcudart_path is not None: config.available_features.add('cuda-runtime') # set the CUDA SDK root path # necessary if CUDA is not installed under /usr/local/ - config.substitutions.append(('%cudapath', libcudart_path[0:-len('/lib64/libcudart.so')])) + config.substitutions.append(('%cudapath', config.cuda_path)) + config.substitutions.append(('%cudaldflags', '-L' + config.cuda_libdir + + ' -lcudart_static -ldl -lrt -pthread -lm -lstdc++')) # limit the number of usable GPUs in a system # https://developer.nvidia.com/blog/cuda-pro-tip-control-gpu-visibility-cuda_visible_devices/ if 'CUDA_VISIBLE_DEVICES' in os.environ: config.environment['CUDA_VISIBLE_DEVICES'] = os.environ['CUDA_VISIBLE_DEVICES'] - # set the CUDA sm level for the tests (e.g. "export CLING_TEST_CUDA_SM_LEVEL=35") - # if no sm level is set, the default of cling will be used - if 'CLING_TEST_CUDA_SM_LEVEL' in os.environ: - config.substitutions.append(('%cudasmlevel', '--cuda-gpu-arch=sm_' + os.environ['CLING_TEST_CUDA_SM_LEVEL'])) - else: - config.substitutions.append(('%cudasmlevel', "")) + config.substitutions.append(('%cudaarch', config.cuda_test_arch)) if(config.have_enzyme): config.available_features.add('Enzyme') diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in index bc3d6f8d1..b1eccea24 100644 --- a/test/lit.site.cfg.in +++ b/test/lit.site.cfg.in @@ -15,6 +15,10 @@ if config.target_triple == "" : config.target_triple = "@TARGET_TRIPLE@" config.shlibext = "@TARGET_SHLIBEXT@" config.have_enzyme = "@CLAD_ENABLE_ENZYME_BACKEND@" +config.cuda_path = "@CUDA_ROOT@" +config.cuda_libdir = "@CUDA_LIBDIR@" +config.cuda_test_arch = "@LIBOMPTARGET_DEP_CUDA_ARCH@" + # Support substitution of the tools and libs dirs with user parameters. This is # used when we can't determine the tool dir at configuration time. try: From 14fb32c4fe80339d600c44574951d0ed5ddca082 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Mon, 9 Sep 2024 17:49:31 +0000 Subject: [PATCH 04/14] Do not install different cuda version in self hosted bots --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bc4c485ed..b00493b37 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -739,7 +739,7 @@ jobs: echo "PATH_TO_LLVM_BUILD=$env:PATH_TO_LLVM_BUILD" echo "PATH_TO_LLVM_BUILD=$env:PATH_TO_LLVM_BUILD" >> $env:GITHUB_ENV - name: Setup CUDA 8 on Linux - if: ${{ matrix.cuda == true }} + if: ${{ matrix.cuda == true && !matrix.os == 'self-hosted'}} run: | wget --no-verbose https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda_8.0.61_375.26_linux-run wget --no-verbose https://developer.nvidia.com/compute/cuda/8.0/Prod2/patches/2/cuda_8.0.61.2_linux-run From 49b9c8bb8421a88731a1abfdfd9921a2c7c35500 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Sat, 14 Sep 2024 08:12:22 +0000 Subject: [PATCH 05/14] [cuda] Enable filecheck on tests --- test/CUDA/ForwardMode.cu | 20 +++++++++++--------- test/CUDA/GradientCuda.cu | 26 ++++++++++++++------------ test/CUDA/GradientKernels.cu | 25 +++++++++++++------------ test/lit.cfg | 2 +- 4 files changed, 39 insertions(+), 34 deletions(-) diff --git a/test/CUDA/ForwardMode.cu b/test/CUDA/ForwardMode.cu index 502beb997..cac79c418 100644 --- a/test/CUDA/ForwardMode.cu +++ b/test/CUDA/ForwardMode.cu @@ -1,12 +1,14 @@ -// RUN: %cladclang_cuda -I%S/../../include %s -xc++ %cudasmlevel \ -// RUN: --cuda-path=%cudapath -L/usr/local/cuda/lib64 -lcudart_static \ -// RUN: -ldl -lrt -pthread -lm -lstdc++ -oForwardMode.out 2>&1 | %filecheck %s - -// RUN: ./ForwardMode.out - +// RUN: %cladclang_cuda -I%S/../../include --cuda-path=%cudapath \ +// RUN: --cuda-gpu-arch=%cudaarch %cudaldflags -oForwardMode.out \ +// RUN: -Xclang -verify %s 2>&1 | %filecheck %s +// +// RUN: ./ForwardMode.out | %filecheck_exec %s +// // REQUIRES: cuda-runtime - +// // expected-no-diagnostics +// +// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" #include "../TestUtils.h" @@ -17,7 +19,7 @@ __global__ void add(double *a, double *b, double *c, int n) { c[idx] = a[idx] + b[idx]; } -// CHECK: void add_pushforward(double *a, double *b, double *c, int n, double *_d_a, double *_d_b, double *_d_c, int _d_n) __attribute__((global)) { +// CHECK: __attribute__((global)) void add_pushforward(double *a, double *b, double *c, int n, double *_d_a, double *_d_b, double *_d_c, int _d_n) { // CHECK-NEXT: int _d_idx = 0; // CHECK-NEXT: int idx = threadIdx.x; // CHECK-NEXT: if (idx < n) { @@ -121,4 +123,4 @@ int main() { INIT_DIFFERENTIATE(fn1, "i"); TEST_DIFFERENTIATE(fn1, 3, 5); // CHECK-EXEC: 8000.00 -} \ No newline at end of file +} diff --git a/test/CUDA/GradientCuda.cu b/test/CUDA/GradientCuda.cu index 1ae46e348..2f165fe22 100644 --- a/test/CUDA/GradientCuda.cu +++ b/test/CUDA/GradientCuda.cu @@ -1,18 +1,20 @@ // The Test checks whether a clad gradient can be successfully be generated on // the device having all the dependencies also as device functions. -// RUN: %cladclang_cuda -I%S/../../include %s -fsyntax-only \ -// RUN: %cudasmlevel --cuda-path=%cudapath -Xclang -verify 2>&1 | %filecheck %s - -// RUN: %cladclang_cuda -I%S/../../include %s -xc++ %cudasmlevel \ -// RUN: --cuda-path=%cudapath -L/usr/local/cuda/lib64 -lcudart_static \ -// RUN: -ldl -lrt -pthread -lm -lstdc++ - +// RUN: %cladclang_cuda -I%S/../../include -fsyntax-only \ +// RUN: --cuda-gpu-arch=%cudaarch --cuda-path=%cudapath -Xclang -verify \ +// RUN: %s 2>&1 | %filecheck %s +// +// RUN: %cladclang_cuda -I%S/../../include --cuda-gpu-arch=%cudaarch \ +// RUN: --cuda-path=%cudapath %cudaldflags -oGradientCuda.out %s +// +// RUN: ./GradientCuda.out | %filecheck_exec %s +// // REQUIRES: cuda-runtime - +// // expected-no-diagnostics - -// XFAIL: clang-15 +// +// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" #include @@ -28,7 +30,7 @@ __device__ __host__ double gauss(double* x, double* p, double sigma, int dim) { } -// CHECK: void gauss_grad_1(double *x, double *p, double sigma, int dim, double *_d_p) __attribute__((device)) __attribute__((host)) { +// CHECK: __attribute__((device)) __attribute__((host)) void gauss_grad_1(double *x, double *p, double sigma, int dim, double *_d_p) { //CHECK-NEXT: double _d_sigma = 0.; //CHECK-NEXT: int _d_dim = 0; //CHECK-NEXT: int _d_i = 0; @@ -116,7 +118,7 @@ int main(void) { cudaDeviceSynchronize(); cudaMemcpy(result.data(), d_result, N * sizeof(double), cudaMemcpyDeviceToHost); - printf("%f,%f,%f\n", result[0], result[1], result[2]); + printf("%f,%f,%f\n", result[0], result[1], result[2]); // CHECK-EXEC: 0.007714,0.007714,0.007714 std::array result_cpu{0}; auto gauss_g = clad::gradient(gauss, "p"); diff --git a/test/CUDA/GradientKernels.cu b/test/CUDA/GradientKernels.cu index 0a5e40d54..2d4f47512 100644 --- a/test/CUDA/GradientKernels.cu +++ b/test/CUDA/GradientKernels.cu @@ -1,16 +1,17 @@ -// RUN: %cladclang_cuda -I%S/../../include %s -fsyntax-only \ -// RUN: %cudasmlevel --cuda-path=%cudapath -Xclang -verify 2>&1 | %filecheck %s - -// RUN: %cladclang_cuda -I%S/../../include %s -xc++ %cudasmlevel \ -// RUN: --cuda-path=%cudapath -L/usr/local/cuda/lib64 -lcudart_static \ -// RUN: -L%cudapath/lib64/stubs \ -// RUN: -ldl -lrt -pthread -lm -lstdc++ -lcuda -lnvrtc - +// RUN: %cladclang_cuda -I%S/../../include -fsyntax-only \ +// RUN: --cuda-gpu-arch=%cudaarch --cuda-path=%cudapath -Xclang -verify \ +// RUN: %s 2>&1 | %filecheck %s +// +// RUN: %cladclang_cuda -I%S/../../include --cuda-path=%cudapath \ +// RUN: --cuda-gpu-arch=%cudaarch %cudaldflags -oGradientKernels.out %s +// +// RUN: ./GradientKernels.out | %filecheck_exec %s +// // REQUIRES: cuda-runtime - +// // expected-no-diagnostics - -// XFAIL: clang-15 +// +// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" @@ -76,4 +77,4 @@ int main(void) { printf("a = %d, a^2 = %d\n", *a, *asquare); // CHECK-EXEC: a = 5, a^2 = 10 return 0; -} \ No newline at end of file +} diff --git a/test/lit.cfg b/test/lit.cfg index 1da159f84..d5ef13f51 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -331,7 +331,7 @@ if libcudart_path is not None: # necessary if CUDA is not installed under /usr/local/ config.substitutions.append(('%cudapath', config.cuda_path)) config.substitutions.append(('%cudaldflags', '-L' + config.cuda_libdir + - ' -lcudart_static -ldl -lrt -pthread -lm -lstdc++')) + ' -lcudart -ldl -lrt -pthread -lm -lstdc++')) # limit the number of usable GPUs in a system # https://developer.nvidia.com/blog/cuda-pro-tip-control-gpu-visibility-cuda_visible_devices/ if 'CUDA_VISIBLE_DEVICES' in os.environ: From 000754a2725038972a6ffd73ef700f386c402f03 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Sat, 14 Sep 2024 08:16:03 +0000 Subject: [PATCH 06/14] Use implicit check-not in FileCheck --- test/Analyses/TBR.cpp | 1 - test/Arrays/ArrayErrorsForwardMode.C | 4 +--- test/Arrays/ArrayInputsForwardMode.C | 2 -- test/Arrays/ArrayInputsReverseMode.C | 4 +--- test/Arrays/ArrayInputsVectorForwardMode.C | 2 -- test/Arrays/Arrays.C | 2 -- test/CUDA/ForwardMode.cu | 2 -- test/CUDA/GradientCuda.cu | 2 -- test/CUDA/GradientKernels.cu | 2 -- test/Enzyme/DifferentCladEnzymeDerivatives.C | 1 - test/Enzyme/ForwardMode.C | 3 +-- test/Enzyme/FunctionPrototypesReverseMode.C | 1 - test/Enzyme/GradientsComparisonWithClad.C | 1 - test/Enzyme/LoopsReverseModeComparisonWithClad.C | 2 -- test/ErrorEstimation/Assignments.C | 1 - test/ErrorEstimation/BasicOps.C | 1 - test/ErrorEstimation/ConditonalStatements.C | 1 - test/ErrorEstimation/LoopsAndArrays.C | 1 - test/ErrorEstimation/LoopsAndArraysExec.C | 2 -- test/ExecOnly/TestExecOnly.C | 1 - test/FirstDerivative/Assignments.C | 1 - test/FirstDerivative/BasicArithmeticAddSub.C | 2 -- test/FirstDerivative/BasicArithmeticAll.C | 2 -- test/FirstDerivative/BasicArithmeticMulDiv.C | 2 -- test/FirstDerivative/BuiltinDerivatives.C | 2 -- test/FirstDerivative/CallArguments.C | 2 -- test/FirstDerivative/ClassMethodCall.C | 1 - test/FirstDerivative/CodeGenSimple.C | 2 -- test/FirstDerivative/CompoundAssignments.C | 1 - test/FirstDerivative/DependencyTracking.C | 1 - test/FirstDerivative/DiffInterface.C | 2 -- test/FirstDerivative/FunctionCalls.C | 2 -- test/FirstDerivative/FunctionCallsWithResults.C | 5 ++++- test/FirstDerivative/FunctionsInNamespaces.C | 3 +-- test/FirstDerivative/FunctionsOneVariable.C | 2 -- test/FirstDerivative/Loops.C | 1 - test/FirstDerivative/Namespaces.C | 1 - test/FirstDerivative/NonContinuous.C | 2 -- test/FirstDerivative/Overloads.C | 1 - test/FirstDerivative/Recursive.C | 2 -- test/FirstDerivative/Simple.C | 1 - test/FirstDerivative/StructGlobalObjects.C | 1 - test/FirstDerivative/StructMethodCall.C | 1 - test/FirstDerivative/Switch.C | 3 +-- test/FirstDerivative/SwitchErrors.C | 3 +-- test/FirstDerivative/SwitchInit.C | 3 +-- test/FirstDerivative/TemplateFunction.C | 1 - test/FirstDerivative/UnsupportedOpsWarn.C | 2 -- test/FirstDerivative/Variables.C | 1 - test/FirstDerivative/VirtualMethodsCall.C | 1 - test/ForwardMode/Casts.C | 3 +-- test/ForwardMode/FunctorErrors.C | 3 +-- test/ForwardMode/Functors.C | 1 - test/ForwardMode/Lambdas.C | 1 - test/ForwardMode/MemberFunctions.C | 3 +-- test/ForwardMode/NonDifferentiable.C | 3 +-- test/ForwardMode/NotEnoughArgError.C | 5 ++--- test/ForwardMode/Pointer.C | 1 - test/ForwardMode/ReferenceArguments.C | 1 - test/ForwardMode/STLCustomDerivatives.C | 4 +--- test/ForwardMode/SourceFnArg.C | 3 +-- test/ForwardMode/TemplateFunctors.C | 1 - test/ForwardMode/UserDefinedTypes.C | 4 +--- test/ForwardMode/VectorMode.C | 2 -- test/ForwardMode/VectorModeInterface.C | 2 -- test/Functors/Simple.C | 2 -- test/Gradient/Assignments.C | 1 - test/Gradient/DiffInterface.C | 2 -- test/Gradient/FunctionCalls.C | 4 +--- test/Gradient/Functors.C | 1 - test/Gradient/Gradients.C | 2 -- test/Gradient/InterfaceCompatibility.c | 3 +-- test/Gradient/Lambdas.C | 3 +-- test/Gradient/Loops.C | 3 +-- test/Gradient/MemberFunctions.C | 1 - test/Gradient/NonDifferentiable.C | 1 - test/Gradient/Pointers.C | 1 - test/Gradient/PointersWithTBR.C | 1 - test/Gradient/STLCustomDerivatives.C | 2 -- test/Gradient/Switch.C | 3 +-- test/Gradient/SwitchInit.C | 3 +-- test/Gradient/TemplateFunctors.C | 1 - test/Gradient/TestAgainstDiff.C | 1 - test/Gradient/TestTypeConversion.C | 2 -- test/Gradient/UserDefinedTypes.C | 3 +-- test/Hessian/ArrayErrors.C | 3 +-- test/Hessian/Arrays.C | 2 -- test/Hessian/BuiltinDerivatives.C | 2 -- test/Hessian/Functors.C | 1 - test/Hessian/Hessians.C | 2 -- test/Hessian/NestedFunctionCalls.C | 2 -- test/Hessian/Pointers.C | 1 - test/Hessian/TemplateFunctors.C | 1 - test/Hessian/constexprTest.C | 1 - test/Hessian/testhessUtility.C | 1 - test/Jacobian/FunctionCalls.C | 2 -- test/Jacobian/Functors.C | 1 - test/Jacobian/Jacobian.C | 4 +--- test/Jacobian/Pointers.C | 1 - test/Jacobian/TemplateFunctors.C | 1 - test/Jacobian/constexprTest.C | 1 - test/Jacobian/testUtility.C | 1 - test/Misc/CladArray.C | 1 - test/Misc/CladMatrix.C | 1 - test/Misc/ClangConsumers.cpp | 1 - test/Misc/TapeMemory.C | 1 - test/Misc/TimingsReport.C | 3 +-- test/MixedDerivatives/Simple.C | 2 -- test/NestedCalls/NestedCalls.C | 2 -- test/NumericalDiff/GradientMultiArg.C | 4 +--- test/NumericalDiff/NoNumDiff.C | 4 +--- test/NumericalDiff/NumDiff.C | 7 +++---- test/NumericalDiff/PrintErrorNumDiff.C | 4 +--- test/NumericalDiff/PureCentralDiffCalls.C | 2 -- test/NumericalDiff/UserDefinedPointers.C | 2 -- test/ROOT/Hessian.C | 4 +--- test/ROOT/Interface.C | 2 -- test/ROOT/TFormula.C | 2 -- test/lit.cfg | 2 +- 119 files changed, 38 insertions(+), 200 deletions(-) diff --git a/test/Analyses/TBR.cpp b/test/Analyses/TBR.cpp index 9b1ac71fc..21f4c5b9f 100644 --- a/test/Analyses/TBR.cpp +++ b/test/Analyses/TBR.cpp @@ -2,7 +2,6 @@ // RUN: ./TBR.out | %filecheck_exec %s // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oTBR.out // RUN: ./TBR.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/Arrays/ArrayErrorsForwardMode.C b/test/Arrays/ArrayErrorsForwardMode.C index 4d363950b..8c8753a33 100644 --- a/test/Arrays/ArrayErrorsForwardMode.C +++ b/test/Arrays/ArrayErrorsForwardMode.C @@ -2,8 +2,6 @@ #include "clad/Differentiator/Differentiator.h" -//CHECK-NOT: {{.*error|warning|note:.*}} - double addArr(double *arr) { return arr[0] + arr[1] + arr[2] + arr[3]; } @@ -22,4 +20,4 @@ int main() { clad::differentiate(addArr, "arr[2:1]"); // expected-error {{Range specified in 'arr[2:1]' is in incorrect format}} clad::differentiate(addDoubleArr, "arr[1]"); -} \ No newline at end of file +} diff --git a/test/Arrays/ArrayInputsForwardMode.C b/test/Arrays/ArrayInputsForwardMode.C index 57559a6be..f3c5a9060 100644 --- a/test/Arrays/ArrayInputsForwardMode.C +++ b/test/Arrays/ArrayInputsForwardMode.C @@ -1,8 +1,6 @@ // RUN: %cladclang %s -I%S/../../include -oArrayInputsForwardMode.out 2>&1 | %filecheck %s // RUN: ./ArrayInputsForwardMode.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" double multiply(const double *arr) { diff --git a/test/Arrays/ArrayInputsReverseMode.C b/test/Arrays/ArrayInputsReverseMode.C index dff6496e0..58d64741a 100644 --- a/test/Arrays/ArrayInputsReverseMode.C +++ b/test/Arrays/ArrayInputsReverseMode.C @@ -3,8 +3,6 @@ // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -Wno-unused-value -oArrayInputsReverseMode.out // RUN: ./ArrayInputsReverseMode.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" double addArr(const double *arr, int n) { @@ -695,4 +693,4 @@ int main() { //CHECK-NEXT: *_d_elem += _r_d0 * elem; //CHECK-NEXT: *_d_elem += elem * _r_d0; //CHECK-NEXT: } -//CHECK-NEXT: } \ No newline at end of file +//CHECK-NEXT: } diff --git a/test/Arrays/ArrayInputsVectorForwardMode.C b/test/Arrays/ArrayInputsVectorForwardMode.C index a0de3bfda..af913241a 100644 --- a/test/Arrays/ArrayInputsVectorForwardMode.C +++ b/test/Arrays/ArrayInputsVectorForwardMode.C @@ -3,8 +3,6 @@ // XFAIL: asserts -// CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" double multiply(const double *arr) { diff --git a/test/Arrays/Arrays.C b/test/Arrays/Arrays.C index b38497834..e52e9932e 100644 --- a/test/Arrays/Arrays.C +++ b/test/Arrays/Arrays.C @@ -3,8 +3,6 @@ // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oArrays.out // RUN: ./Arrays.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" #include diff --git a/test/CUDA/ForwardMode.cu b/test/CUDA/ForwardMode.cu index cac79c418..532bc5950 100644 --- a/test/CUDA/ForwardMode.cu +++ b/test/CUDA/ForwardMode.cu @@ -7,8 +7,6 @@ // REQUIRES: cuda-runtime // // expected-no-diagnostics -// -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" #include "../TestUtils.h" diff --git a/test/CUDA/GradientCuda.cu b/test/CUDA/GradientCuda.cu index 2f165fe22..7c1a23d69 100644 --- a/test/CUDA/GradientCuda.cu +++ b/test/CUDA/GradientCuda.cu @@ -13,8 +13,6 @@ // REQUIRES: cuda-runtime // // expected-no-diagnostics -// -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" #include diff --git a/test/CUDA/GradientKernels.cu b/test/CUDA/GradientKernels.cu index 2d4f47512..e67c74926 100644 --- a/test/CUDA/GradientKernels.cu +++ b/test/CUDA/GradientKernels.cu @@ -10,8 +10,6 @@ // REQUIRES: cuda-runtime // // expected-no-diagnostics -// -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/Enzyme/DifferentCladEnzymeDerivatives.C b/test/Enzyme/DifferentCladEnzymeDerivatives.C index 6ae2eb037..c3b36cda9 100644 --- a/test/Enzyme/DifferentCladEnzymeDerivatives.C +++ b/test/Enzyme/DifferentCladEnzymeDerivatives.C @@ -1,6 +1,5 @@ // RUN: %cladclang %s -I%S/../../include -oDifferentCladEnzymeDerivatives.out | %filecheck %s // RUN: ./DifferentCladEnzymeDerivatives.out -// CHECK-NOT: {{.*error|warning|note:.*}} // REQUIRES: Enzyme #include "clad/Differentiator/Differentiator.h" diff --git a/test/Enzyme/ForwardMode.C b/test/Enzyme/ForwardMode.C index 88a9d9f81..ec2e48000 100644 --- a/test/Enzyme/ForwardMode.C +++ b/test/Enzyme/ForwardMode.C @@ -1,6 +1,5 @@ // RUN: %cladclang %s -I%S/../../include -oEnzyme.out 2>&1 | %filecheck %s // RUN: ./Enzyme.out -// CHECK-NOT: {{.*error|warning|note:.*}} // REQUIRES: Enzyme // XFAIL:* // Forward mode is not implemented yet @@ -14,4 +13,4 @@ double f(double x, double y) { return x * y; } int main(){ auto f_dx = clad::differentiate(f, "x"); -} \ No newline at end of file +} diff --git a/test/Enzyme/FunctionPrototypesReverseMode.C b/test/Enzyme/FunctionPrototypesReverseMode.C index 4e24e4937..cb4de6fe7 100644 --- a/test/Enzyme/FunctionPrototypesReverseMode.C +++ b/test/Enzyme/FunctionPrototypesReverseMode.C @@ -1,6 +1,5 @@ // RUN: %cladclang %s -I%S/../../include -oReverseMode.out | %filecheck %s // RUN: ./ReverseMode.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} // REQUIRES: Enzyme #include "clad/Differentiator/Differentiator.h" diff --git a/test/Enzyme/GradientsComparisonWithClad.C b/test/Enzyme/GradientsComparisonWithClad.C index a38e3856d..f8fa64994 100644 --- a/test/Enzyme/GradientsComparisonWithClad.C +++ b/test/Enzyme/GradientsComparisonWithClad.C @@ -1,7 +1,6 @@ // RUN: %cladclang %s -I%S/../../include -oEnzymeGradients.out 2>&1 | %filecheck %s // RUN: ./EnzymeGradients.out | %filecheck_exec %s // REQUIRES: Enzyme -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" #include diff --git a/test/Enzyme/LoopsReverseModeComparisonWithClad.C b/test/Enzyme/LoopsReverseModeComparisonWithClad.C index 092e9ba21..6434e75c0 100644 --- a/test/Enzyme/LoopsReverseModeComparisonWithClad.C +++ b/test/Enzyme/LoopsReverseModeComparisonWithClad.C @@ -1,8 +1,6 @@ // RUN: %cladclang %s -I%S/../../include -oEnzymeLoops.out 2>&1 | %filecheck %s // RUN: ./EnzymeLoops.out | %filecheck_exec %s // REQUIRES: Enzyme -// CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" #include diff --git a/test/ErrorEstimation/Assignments.C b/test/ErrorEstimation/Assignments.C index 4d310ee0b..eb49e7485 100644 --- a/test/ErrorEstimation/Assignments.C +++ b/test/ErrorEstimation/Assignments.C @@ -1,6 +1,5 @@ // RUN: %cladclang -I%S/../../include -oAssignments.out %s 2>&1 | %filecheck %s // RUN: ./Assignments.out -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/ErrorEstimation/BasicOps.C b/test/ErrorEstimation/BasicOps.C index 89d4d43da..52ef2aa39 100644 --- a/test/ErrorEstimation/BasicOps.C +++ b/test/ErrorEstimation/BasicOps.C @@ -1,5 +1,4 @@ // RUN: %cladclang %s -I%S/../../include -fsyntax-only -Xclang -verify 2>&1 | %filecheck %s -//CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/ErrorEstimation/ConditonalStatements.C b/test/ErrorEstimation/ConditonalStatements.C index be966ad67..452f80c47 100644 --- a/test/ErrorEstimation/ConditonalStatements.C +++ b/test/ErrorEstimation/ConditonalStatements.C @@ -1,5 +1,4 @@ // RUN: %cladclang -I%S/../../include -oCondStmts.out %s 2>&1 | %filecheck %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/ErrorEstimation/LoopsAndArrays.C b/test/ErrorEstimation/LoopsAndArrays.C index 52643993f..a141087c7 100644 --- a/test/ErrorEstimation/LoopsAndArrays.C +++ b/test/ErrorEstimation/LoopsAndArrays.C @@ -1,5 +1,4 @@ // RUN: %cladclang -I%S/../../include -oLoopsAndArrays.out %s 2>&1 | %filecheck %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/ErrorEstimation/LoopsAndArraysExec.C b/test/ErrorEstimation/LoopsAndArraysExec.C index 6ee40641b..a2a8ec2b7 100644 --- a/test/ErrorEstimation/LoopsAndArraysExec.C +++ b/test/ErrorEstimation/LoopsAndArraysExec.C @@ -1,8 +1,6 @@ // RUN: %cladclang %s -I%S/../../include -oLoopsAndArraysExec.out 2>&1 | %filecheck %s // RUN: ./LoopsAndArraysExec.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" #include diff --git a/test/ExecOnly/TestExecOnly.C b/test/ExecOnly/TestExecOnly.C index 41ace7c5f..eea1f2b5d 100644 --- a/test/ExecOnly/TestExecOnly.C +++ b/test/ExecOnly/TestExecOnly.C @@ -1,6 +1,5 @@ // RUN: %cladclang %s -I%S/../../include -oTestExecOnly.out 2>&1 | %filecheck %s // RUN: ./TestExecOnly.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/FirstDerivative/Assignments.C b/test/FirstDerivative/Assignments.C index d17ed16d2..66798b850 100644 --- a/test/FirstDerivative/Assignments.C +++ b/test/FirstDerivative/Assignments.C @@ -1,6 +1,5 @@ // RUN: %cladclang %s -I%S/../../include -oAssignments.out 2>&1 | %filecheck %s // RUN: ./Assignments.out -//CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" #include diff --git a/test/FirstDerivative/BasicArithmeticAddSub.C b/test/FirstDerivative/BasicArithmeticAddSub.C index b40c53b77..808ff046d 100644 --- a/test/FirstDerivative/BasicArithmeticAddSub.C +++ b/test/FirstDerivative/BasicArithmeticAddSub.C @@ -1,8 +1,6 @@ // RUN: %cladclang %s -I%S/../../include -oBasicArithmeticAddSub.out 2>&1 | %filecheck %s // RUN: ./BasicArithmeticAddSub.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" extern "C" int printf(const char* fmt, ...); diff --git a/test/FirstDerivative/BasicArithmeticAll.C b/test/FirstDerivative/BasicArithmeticAll.C index 296cabda3..f2464d8df 100644 --- a/test/FirstDerivative/BasicArithmeticAll.C +++ b/test/FirstDerivative/BasicArithmeticAll.C @@ -1,8 +1,6 @@ // RUN: %cladclang %s -I%S/../../include -oBasicArithmeticAll.out 2>&1 | %filecheck %s // RUN: ./BasicArithmeticAll.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" extern "C" int printf(const char* fmt, ...); diff --git a/test/FirstDerivative/BasicArithmeticMulDiv.C b/test/FirstDerivative/BasicArithmeticMulDiv.C index b7a2b88be..6164fed88 100644 --- a/test/FirstDerivative/BasicArithmeticMulDiv.C +++ b/test/FirstDerivative/BasicArithmeticMulDiv.C @@ -1,8 +1,6 @@ // RUN: %cladclang %s -I%S/../../include -oBasicArithmeticMulDiv.out 2>&1 | FileCheck %s // RUN: ./BasicArithmeticMulDiv.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" extern "C" int printf(const char* fmt, ...); diff --git a/test/FirstDerivative/BuiltinDerivatives.C b/test/FirstDerivative/BuiltinDerivatives.C index 4820c4694..e608473bc 100644 --- a/test/FirstDerivative/BuiltinDerivatives.C +++ b/test/FirstDerivative/BuiltinDerivatives.C @@ -3,8 +3,6 @@ // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -Xclang -verify -oBuiltinDerivatives.out // RUN: ./BuiltinDerivatives.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" #include "../TestUtils.h" extern "C" int printf(const char* fmt, ...); diff --git a/test/FirstDerivative/CallArguments.C b/test/FirstDerivative/CallArguments.C index 5b590417b..b9219a220 100644 --- a/test/FirstDerivative/CallArguments.C +++ b/test/FirstDerivative/CallArguments.C @@ -1,8 +1,6 @@ // RUN: %cladclang %s -I%S/../../include -Xclang -verify -oCallArguments.out 2>&1 | %filecheck %s // RUN: ./CallArguments.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" float f(float y) { diff --git a/test/FirstDerivative/ClassMethodCall.C b/test/FirstDerivative/ClassMethodCall.C index 3459b0644..14c83c5e2 100644 --- a/test/FirstDerivative/ClassMethodCall.C +++ b/test/FirstDerivative/ClassMethodCall.C @@ -1,6 +1,5 @@ // RUN: %cladclang %s -I%S/../../include -oClassMethods.out 2>&1 | %filecheck %s // RUN: ./ClassMethods.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/FirstDerivative/CodeGenSimple.C b/test/FirstDerivative/CodeGenSimple.C index aef969600..4df61d4c4 100644 --- a/test/FirstDerivative/CodeGenSimple.C +++ b/test/FirstDerivative/CodeGenSimple.C @@ -1,8 +1,6 @@ // RUN: %cladclang %s -I%S/../../include -oCodeGenSimple.out 2>&1 | %filecheck %s // RUN: ./CodeGenSimple.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" extern "C" int printf(const char* fmt, ...); diff --git a/test/FirstDerivative/CompoundAssignments.C b/test/FirstDerivative/CompoundAssignments.C index f66426486..86584ac3b 100644 --- a/test/FirstDerivative/CompoundAssignments.C +++ b/test/FirstDerivative/CompoundAssignments.C @@ -1,6 +1,5 @@ // RUN: %cladclang %s -I%S/../../include -oCompoundAssignments.out 2>&1 | %filecheck %s // RUN: ./CompoundAssignments.out -//CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" #include diff --git a/test/FirstDerivative/DependencyTracking.C b/test/FirstDerivative/DependencyTracking.C index 600b96f38..7740286fd 100644 --- a/test/FirstDerivative/DependencyTracking.C +++ b/test/FirstDerivative/DependencyTracking.C @@ -1,6 +1,5 @@ // RUN: %cladclang %s -I%S/../../include 2>&1 -fsyntax-only | %filecheck %s -//CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" // f(x) = | +x*x, x >= 0 diff --git a/test/FirstDerivative/DiffInterface.C b/test/FirstDerivative/DiffInterface.C index 7e538faa7..c1fb73599 100644 --- a/test/FirstDerivative/DiffInterface.C +++ b/test/FirstDerivative/DiffInterface.C @@ -2,8 +2,6 @@ #include "clad/Differentiator/Differentiator.h" -//CHECK-NOT: {{.*error|warning|note:.*}} - extern "C" int printf(const char* fmt, ...); int f_1(float y) { diff --git a/test/FirstDerivative/FunctionCalls.C b/test/FirstDerivative/FunctionCalls.C index 4e831a22e..c460ba94f 100644 --- a/test/FirstDerivative/FunctionCalls.C +++ b/test/FirstDerivative/FunctionCalls.C @@ -1,7 +1,5 @@ // RUN: %cladnumdiffclang %s -I%S/../../include -fsyntax-only -Xclang -verify 2>&1 | %filecheck %s -//CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" #include diff --git a/test/FirstDerivative/FunctionCallsWithResults.C b/test/FirstDerivative/FunctionCallsWithResults.C index 2f26288f6..91d7d95bd 100644 --- a/test/FirstDerivative/FunctionCallsWithResults.C +++ b/test/FirstDerivative/FunctionCallsWithResults.C @@ -1,8 +1,11 @@ -// RUN: %cladclang %s -I%S/../../include -oFunctionCallsWithResults.out 2>&1 | %filecheck %s +// RUN: %cladclang %s -I%S/../../include -oFunctionCallsWithResults.out \ +// RUN: -Xclang -verify 2>&1 | %filecheck %s // RUN: ./FunctionCallsWithResults.out | %filecheck_exec %s #include "clad/Differentiator/Differentiator.h" #include +// expected-warning@* 0-1 {{function 'nextafter' was not differentiated}} +// expected-note@* 0-1 {{considering 'nextafter' as 0}} int printf(const char* fmt, ...); diff --git a/test/FirstDerivative/FunctionsInNamespaces.C b/test/FirstDerivative/FunctionsInNamespaces.C index 7c676be9b..b753a7764 100644 --- a/test/FirstDerivative/FunctionsInNamespaces.C +++ b/test/FirstDerivative/FunctionsInNamespaces.C @@ -1,7 +1,6 @@ // RUN: %cladclang %s -I%S/../../include -oFunctionsInNamespaces.out 2>&1 | %filecheck %s // RUN: ./FunctionsInNamespaces.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" #include "../TestUtils.h" @@ -128,4 +127,4 @@ int main () { // CHECK-NEXT: } return 0; -} \ No newline at end of file +} diff --git a/test/FirstDerivative/FunctionsOneVariable.C b/test/FirstDerivative/FunctionsOneVariable.C index 5c07ea2ee..4b1cdb1ec 100644 --- a/test/FirstDerivative/FunctionsOneVariable.C +++ b/test/FirstDerivative/FunctionsOneVariable.C @@ -2,8 +2,6 @@ #include "clad/Differentiator/Differentiator.h" -//CHECK-NOT: {{.*error|warning|note:.*}} - extern "C" int printf(const char* fmt, ...); float f_simple(float x) { diff --git a/test/FirstDerivative/Loops.C b/test/FirstDerivative/Loops.C index 8605e53f4..bac3c5415 100644 --- a/test/FirstDerivative/Loops.C +++ b/test/FirstDerivative/Loops.C @@ -1,6 +1,5 @@ // RUN: %cladclang %s -std=c++17 -I%S/../../include -oLoops.out 2>&1 | %filecheck %s // RUN: ./Loops.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" #include "clad/Differentiator/STLBuiltins.h" diff --git a/test/FirstDerivative/Namespaces.C b/test/FirstDerivative/Namespaces.C index 2704b15fe..e68997d09 100644 --- a/test/FirstDerivative/Namespaces.C +++ b/test/FirstDerivative/Namespaces.C @@ -1,6 +1,5 @@ // RUN: %cladclang %s -I%S/../../include -oNamespaces.out 2>&1 | %filecheck %s // RUN: ./Namespaces.out -//CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" #include diff --git a/test/FirstDerivative/NonContinuous.C b/test/FirstDerivative/NonContinuous.C index 24cf5b687..5db9d53f8 100644 --- a/test/FirstDerivative/NonContinuous.C +++ b/test/FirstDerivative/NonContinuous.C @@ -1,8 +1,6 @@ // RUN: %cladclang %s -I%S/../../include -oNonContinuous.out 2>&1 | %filecheck %s // RUN: ./NonContinuous.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" // f(x) = | +x*x, x >= 0 diff --git a/test/FirstDerivative/Overloads.C b/test/FirstDerivative/Overloads.C index 3dc549c1b..9406d1757 100644 --- a/test/FirstDerivative/Overloads.C +++ b/test/FirstDerivative/Overloads.C @@ -1,7 +1,6 @@ // RUN: %cladclang %s -I%S/../../include -oOverloads.out 2>&1 | %filecheck %s // RUN: ./Overloads.out | %filecheck_exec %s // XFAIL: asserts -//CHECK-NOT: {{.*error|warning|note:.*}} // XFAIL: target={{i586.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/FirstDerivative/Recursive.C b/test/FirstDerivative/Recursive.C index e6d77d8ea..7c16f5ff7 100644 --- a/test/FirstDerivative/Recursive.C +++ b/test/FirstDerivative/Recursive.C @@ -1,8 +1,6 @@ // RUN: %cladclang %s -I%S/../../include -oRecursive.out 2>&1 | %filecheck %s // RUN: ./Recursive.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" extern "C" int printf(const char* fmt, ...); diff --git a/test/FirstDerivative/Simple.C b/test/FirstDerivative/Simple.C index 1074316e1..8480b9781 100644 --- a/test/FirstDerivative/Simple.C +++ b/test/FirstDerivative/Simple.C @@ -1,6 +1,5 @@ // RUN: %cladclang %s -I%S/../../include -fsyntax-only 2>&1 -//CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" extern "C" int printf(const char* fmt, ...); diff --git a/test/FirstDerivative/StructGlobalObjects.C b/test/FirstDerivative/StructGlobalObjects.C index 784a68188..736aa0c2a 100644 --- a/test/FirstDerivative/StructGlobalObjects.C +++ b/test/FirstDerivative/StructGlobalObjects.C @@ -1,5 +1,4 @@ // RUN: %cladclang %s -I%S/../../include 2>&1 | %filecheck %s -//CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/FirstDerivative/StructMethodCall.C b/test/FirstDerivative/StructMethodCall.C index 99ab6f5b3..291883b04 100644 --- a/test/FirstDerivative/StructMethodCall.C +++ b/test/FirstDerivative/StructMethodCall.C @@ -1,6 +1,5 @@ // RUN: %cladclang %s -I%S/../../include -oStructMethodCall.out 2>&1 | %filecheck %s // RUN: ./StructMethodCall.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/FirstDerivative/Switch.C b/test/FirstDerivative/Switch.C index 77cf19310..2c62db851 100644 --- a/test/FirstDerivative/Switch.C +++ b/test/FirstDerivative/Switch.C @@ -1,6 +1,5 @@ // RUN: %cladclang %s -I%S/../../include -oSwitch.out 2>&1 | %filecheck %s // RUN: ./Switch.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" @@ -318,4 +317,4 @@ int main() { TEST_SWITCH_CASES(fn2, 0, 4); // CHECK-EXEC: 2.00 0.92 2.20 7.00 7.00 TEST_SWITCH_CASES(fn3, 0, 2); // CHECK-EXEC: 27.00 27.00 27.00 TEST_SWITCH_CASES(fn4, 0, 3); // CHECK-EXEC: 7.00 7.20 10.00 10.00 -} \ No newline at end of file +} diff --git a/test/FirstDerivative/SwitchErrors.C b/test/FirstDerivative/SwitchErrors.C index df0827d07..6133e83b5 100644 --- a/test/FirstDerivative/SwitchErrors.C +++ b/test/FirstDerivative/SwitchErrors.C @@ -1,5 +1,4 @@ // RUN: %cladclang %s -I%S/../../include -fsyntax-only -Xclang -verify 2>&1 -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" @@ -30,4 +29,4 @@ auto d_##fn = clad::differentiate(fn, args); int main() { INIT(fn1, "i"); -} \ No newline at end of file +} diff --git a/test/FirstDerivative/SwitchInit.C b/test/FirstDerivative/SwitchInit.C index 44bdf5fd7..f0ffb6e43 100644 --- a/test/FirstDerivative/SwitchInit.C +++ b/test/FirstDerivative/SwitchInit.C @@ -1,6 +1,5 @@ // RUN: %cladclang %s -I%S/../../include -std=c++17 -oSwitchInit.out 2>&1 | %filecheck %s // RUN: ./SwitchInit.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" @@ -65,4 +64,4 @@ printf("\n"); int main() { INIT(fn1, "i"); TEST_SWITCH_CASES(fn1, 0, 3); // CHECK-EXEC: 1.00 6.00 27.00 0.00 -} \ No newline at end of file +} diff --git a/test/FirstDerivative/TemplateFunction.C b/test/FirstDerivative/TemplateFunction.C index b85687c32..28e78120f 100644 --- a/test/FirstDerivative/TemplateFunction.C +++ b/test/FirstDerivative/TemplateFunction.C @@ -1,5 +1,4 @@ // RUN: %cladclang %s -I%S/../../include 2>&1 | %filecheck %s -//CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/FirstDerivative/UnsupportedOpsWarn.C b/test/FirstDerivative/UnsupportedOpsWarn.C index 551391407..2c1babd76 100644 --- a/test/FirstDerivative/UnsupportedOpsWarn.C +++ b/test/FirstDerivative/UnsupportedOpsWarn.C @@ -3,8 +3,6 @@ #include "clad/Differentiator/Differentiator.h" -//CHECK-NOT: {{.*error|warning|note:.*}} - int binOpWarn_0(int x){ return x << 1; // expected-warning {{attempt to differentiate unsupported operator, ignored.}} set to 0}} } diff --git a/test/FirstDerivative/Variables.C b/test/FirstDerivative/Variables.C index 7b4093eeb..040155429 100644 --- a/test/FirstDerivative/Variables.C +++ b/test/FirstDerivative/Variables.C @@ -1,6 +1,5 @@ // RUN: %cladclang %s -I%S/../../include -oVariables.out 2>&1 | %filecheck %s // RUN: ./Variables.out -//CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" #include diff --git a/test/FirstDerivative/VirtualMethodsCall.C b/test/FirstDerivative/VirtualMethodsCall.C index dd1d1950a..ea7c45199 100644 --- a/test/FirstDerivative/VirtualMethodsCall.C +++ b/test/FirstDerivative/VirtualMethodsCall.C @@ -1,7 +1,6 @@ // RUN: %cladclang %s -I%S/../../include -oVirtualMethodsCall.out 2>&1 | %filecheck %s // RUN: ./VirtualMethodsCall.out | %filecheck_exec %s // XFAIL: asserts -//CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/ForwardMode/Casts.C b/test/ForwardMode/Casts.C index 74e536003..0e32f99f9 100644 --- a/test/ForwardMode/Casts.C +++ b/test/ForwardMode/Casts.C @@ -1,6 +1,5 @@ // RUN: %cladclang %s -I%S/../../include -oCasts.out 2>&1 | %filecheck %s // RUN: ./Casts.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" @@ -16,4 +15,4 @@ int main() { INIT_DIFFERENTIATE(fn1, "i"); TEST_DIFFERENTIATE(fn1, 3, 5); // CHECK-EXEC: {12.00} -} \ No newline at end of file +} diff --git a/test/ForwardMode/FunctorErrors.C b/test/ForwardMode/FunctorErrors.C index d0fec67e6..c1f96648c 100644 --- a/test/ForwardMode/FunctorErrors.C +++ b/test/ForwardMode/FunctorErrors.C @@ -1,5 +1,4 @@ // RUN: %cladclang %s -I%S/../../include -fsyntax-only -Xclang -verify 2>&1 -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" @@ -58,4 +57,4 @@ int main() { Widget W(3, 5); auto d_W = clad::differentiate(W, 0); auto d_W_Again = clad::differentiate(W, 10); // expected-error {{Invalid member variable index '10' of '4' member variable(s)}} -} \ No newline at end of file +} diff --git a/test/ForwardMode/Functors.C b/test/ForwardMode/Functors.C index 4285d86aa..aa077682a 100644 --- a/test/ForwardMode/Functors.C +++ b/test/ForwardMode/Functors.C @@ -1,6 +1,5 @@ // RUN: %cladclang %s -I%S/../../include -oFunctors.out 2>&1 | %filecheck %s // RUN: ./Functors.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/ForwardMode/Lambdas.C b/test/ForwardMode/Lambdas.C index f9c203a22..87d0c8016 100644 --- a/test/ForwardMode/Lambdas.C +++ b/test/ForwardMode/Lambdas.C @@ -1,6 +1,5 @@ // RUN: %cladclang %s -I%S/../../include -oLambdas.out 2>&1 | %filecheck %s // RUN: ./Lambdas.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/ForwardMode/MemberFunctions.C b/test/ForwardMode/MemberFunctions.C index 4ba230d8d..96f914500 100644 --- a/test/ForwardMode/MemberFunctions.C +++ b/test/ForwardMode/MemberFunctions.C @@ -4,7 +4,6 @@ // RUN: ./MemberFunctions-cpp14.out | %filecheck_exec %s // RUN: %cladclang -std=c++17 %s -I%S/../../include -oMemberFunctions-cpp17.out 2>&1 | %filecheck %s // RUN: ./MemberFunctions-cpp17.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" @@ -1003,4 +1002,4 @@ int main() { auto d_multiplySimpleFunctionByValue = clad::differentiate(multiplySimpleFunctionByValue, "value"); printf("%.2f %.2f %.2f\n", d_addValueToSimpleFunction.execute(sf, 3), d_subtractValueFromSimpleFunction.execute(sf, 3), d_multiplySimpleFunctionByValue.execute(sf, 3)); // CHECK-EXEC: 1.00 -1.00 2.00 -} \ No newline at end of file +} diff --git a/test/ForwardMode/NonDifferentiable.C b/test/ForwardMode/NonDifferentiable.C index a5b923de1..bdcd04a75 100644 --- a/test/ForwardMode/NonDifferentiable.C +++ b/test/ForwardMode/NonDifferentiable.C @@ -1,6 +1,5 @@ // RUN: %cladclang %s -I%S/../../include -oNonDifferentiable.out 2>&1 | %filecheck %s // RUN: ./NonDifferentiable.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #define non_differentiable __attribute__((annotate("another_attribute"), annotate("non_differentiable"))) @@ -218,4 +217,4 @@ int main() { // CHECK-NEXT: return {SimpleFunctions1(this->x + other.x, this->y + other.y), SimpleFunctions1(_d_this->x + _d_other.x, 0. + 0.)}; // CHECK-NEXT: } -} \ No newline at end of file +} diff --git a/test/ForwardMode/NotEnoughArgError.C b/test/ForwardMode/NotEnoughArgError.C index 3fca2fc06..df49c5b14 100644 --- a/test/ForwardMode/NotEnoughArgError.C +++ b/test/ForwardMode/NotEnoughArgError.C @@ -1,5 +1,4 @@ // RUN: %cladclang %s -I%S/../../include -fsyntax-only -Xclang -verify 2>&1 -// CHECK-NOT: {{.*warning|note:.*}} #include "clad/Differentiator/Differentiator.h" @@ -15,9 +14,9 @@ int main () { // expected-note@clad/Differentiator/Differentiator.h:* {{in instantiation of function template specialization 'clad::execute_with_default_args' requested here}} #if __clang_major__ < 16 // expected-note@clad/Differentiator/Differentiator.h:* {{in instantiation of function template specialization 'clad::CladFunction::execute_helper' requested here}} - // expected-note@NotEnoughArgError.C:13 {{in instantiation of function template specialization 'clad::CladFunction::execute' requested here}} + // expected-note@NotEnoughArgError.C:12 {{in instantiation of function template specialization 'clad::CladFunction::execute' requested here}} #else // expected-note@clad/Differentiator/Differentiator.h:* {{in instantiation of function template specialization 'clad::CladFunction::execute_helper' requested here}} - // expected-note@NotEnoughArgError.C:13 {{in instantiation of function template specialization 'clad::CladFunction::execute' requested here}} + // expected-note@NotEnoughArgError.C:12 {{in instantiation of function template specialization 'clad::CladFunction::execute' requested here}} #endif } diff --git a/test/ForwardMode/Pointer.C b/test/ForwardMode/Pointer.C index 9f724fbb2..909035078 100644 --- a/test/ForwardMode/Pointer.C +++ b/test/ForwardMode/Pointer.C @@ -1,6 +1,5 @@ // RUN: %cladclang %s -I%S/../../include -oPointer.out 2>&1 | %filecheck %s // RUN: ./Pointer.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/ForwardMode/ReferenceArguments.C b/test/ForwardMode/ReferenceArguments.C index 0800bdacb..aaa653d34 100644 --- a/test/ForwardMode/ReferenceArguments.C +++ b/test/ForwardMode/ReferenceArguments.C @@ -1,6 +1,5 @@ // RUN: %cladclang %s -I%S/../../include -oReferenceArguments.out 2>&1 | %filecheck %s // RUN: ./ReferenceArguments.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/ForwardMode/STLCustomDerivatives.C b/test/ForwardMode/STLCustomDerivatives.C index a9bb77ee4..cfb1f7813 100644 --- a/test/ForwardMode/STLCustomDerivatives.C +++ b/test/ForwardMode/STLCustomDerivatives.C @@ -1,8 +1,6 @@ // RUN: %cladclang %s -std=c++14 -I%S/../../include -oSTLCustomDerivatives.out | %filecheck %s // RUN: ./STLCustomDerivatives.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" #include "clad/Differentiator/STLBuiltins.h" @@ -197,4 +195,4 @@ int main() { TEST_DIFFERENTIATE(fnVec4, 3, 5); // CHECK-EXEC: {30.00} TEST_DIFFERENTIATE(fnArr1, 3); // CHECK-EXEC: {3.00} TEST_DIFFERENTIATE(fnArr2, 3); // CHECK-EXEC: {108.00} -} \ No newline at end of file +} diff --git a/test/ForwardMode/SourceFnArg.C b/test/ForwardMode/SourceFnArg.C index 9b0db5171..23df6b3e1 100644 --- a/test/ForwardMode/SourceFnArg.C +++ b/test/ForwardMode/SourceFnArg.C @@ -1,6 +1,5 @@ // RUN: %cladclang %s -I%S/../../include -oSourceFnArg.out 2>&1 | %filecheck %s // RUN: ./SourceFnArg.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" @@ -159,4 +158,4 @@ int main() { NON_MEM_FN_TEST(d_nonMemFnReinterpretCast); // CHECK-EXEC: 5.00 NON_MEM_FN_TEST(d_nonMemFnCStyleCast); // CHECK-EXEC: 5.00 -} \ No newline at end of file +} diff --git a/test/ForwardMode/TemplateFunctors.C b/test/ForwardMode/TemplateFunctors.C index 2d3961cd9..f2ff09840 100644 --- a/test/ForwardMode/TemplateFunctors.C +++ b/test/ForwardMode/TemplateFunctors.C @@ -1,6 +1,5 @@ // RUN: %cladclang %s -I%S/../../include -oTemplateFunctors.out 2>&1 | %filecheck %s // RUN: ./TemplateFunctors.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/ForwardMode/UserDefinedTypes.C b/test/ForwardMode/UserDefinedTypes.C index 82ef5f54f..e0fca6587 100644 --- a/test/ForwardMode/UserDefinedTypes.C +++ b/test/ForwardMode/UserDefinedTypes.C @@ -3,8 +3,6 @@ // XFAIL: asserts -// CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" #include "clad/Differentiator/STLBuiltins.h" @@ -1358,4 +1356,4 @@ int main() { // CHECK: clad::ValueAndPushforward operator_amp_equal_pushforward(Tensor &lhs, const Tensor &rhs, Tensor &_d_lhs, const Tensor &_d_rhs) { // CHECK-NEXT: return {(bool)1, (bool)0}; // CHECK-NEXT: } -} \ No newline at end of file +} diff --git a/test/ForwardMode/VectorMode.C b/test/ForwardMode/VectorMode.C index 1c8896692..544b98fad 100644 --- a/test/ForwardMode/VectorMode.C +++ b/test/ForwardMode/VectorMode.C @@ -3,8 +3,6 @@ // XFAIL: asserts -//CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" double f1(double x, double y) { diff --git a/test/ForwardMode/VectorModeInterface.C b/test/ForwardMode/VectorModeInterface.C index b39506ae9..923756db7 100644 --- a/test/ForwardMode/VectorModeInterface.C +++ b/test/ForwardMode/VectorModeInterface.C @@ -2,8 +2,6 @@ // XFAIL: asserts -//CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" double f1(double x, double y) { diff --git a/test/Functors/Simple.C b/test/Functors/Simple.C index d24dd7d17..cbd2bb804 100644 --- a/test/Functors/Simple.C +++ b/test/Functors/Simple.C @@ -1,8 +1,6 @@ // RUN: %cladclang %s -I%S/../../include -oSimpleFunctor.out 2>&1 | %filecheck %s // RUN: ./SimpleFunctor.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" class AFunctor { diff --git a/test/Gradient/Assignments.C b/test/Gradient/Assignments.C index 5716c0b02..b5f7ceead 100644 --- a/test/Gradient/Assignments.C +++ b/test/Gradient/Assignments.C @@ -2,7 +2,6 @@ // RUN: ./ReverseAssignments.out | %filecheck_exec %s // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oReverseAssignments.out // RUN: ./ReverseAssignments.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" #include diff --git a/test/Gradient/DiffInterface.C b/test/Gradient/DiffInterface.C index 1ea3804b1..9e22f2e61 100644 --- a/test/Gradient/DiffInterface.C +++ b/test/Gradient/DiffInterface.C @@ -5,8 +5,6 @@ #include "clad/Differentiator/Differentiator.h" -//CHECK-NOT: {{.*error|warning|note:.*}} - extern "C" int printf(const char* fmt, ...); double f_1(double x, double y, double z) { diff --git a/test/Gradient/FunctionCalls.C b/test/Gradient/FunctionCalls.C index 05a571648..e7df7695b 100644 --- a/test/Gradient/FunctionCalls.C +++ b/test/Gradient/FunctionCalls.C @@ -3,8 +3,6 @@ // RUN: %cladnumdiffclang -Xclang -plugin-arg-clad -Xclang -enable-tbr -std=c++17 -Wno-writable-strings %s -I%S/../../include -oFunctionCalls.out // RUN: ./FunctionCalls.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" namespace A { @@ -1071,4 +1069,4 @@ double sq_defined_later(double x) { // CHECK: inline void identity_with_bool_pullback(double x, bool b, double _d_y, double *_d_x, bool *_d_b) { // CHECK-NEXT: *_d_x += _d_y; -// CHECK-NEXT: } \ No newline at end of file +// CHECK-NEXT: } diff --git a/test/Gradient/Functors.C b/test/Gradient/Functors.C index 5a1d1e6d7..07bac5513 100644 --- a/test/Gradient/Functors.C +++ b/test/Gradient/Functors.C @@ -2,7 +2,6 @@ // RUN: ./Functors.out | %filecheck_exec %s // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oFunctors.out // RUN: ./Functors.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/Gradient/Gradients.C b/test/Gradient/Gradients.C index 891aa2ecf..a23fe2e8b 100644 --- a/test/Gradient/Gradients.C +++ b/test/Gradient/Gradients.C @@ -3,8 +3,6 @@ // RUN: %cladnumdiffclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oGradients.out // RUN: ./Gradients.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" #include diff --git a/test/Gradient/InterfaceCompatibility.c b/test/Gradient/InterfaceCompatibility.c index 77ea7f039..a130df42a 100644 --- a/test/Gradient/InterfaceCompatibility.c +++ b/test/Gradient/InterfaceCompatibility.c @@ -3,7 +3,6 @@ // RUN: %cladnumdiffclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oInterfaceCompatibility.out // RUN: ./InterfaceCompatibility.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" #include @@ -30,4 +29,4 @@ int main() { auto df2 = clad::gradient(f2); df2.execute(x, y, dx_ref, dy2_ref); printf("{%.2f, %.2f, %.2f}\n", dx_ref[0], dx_ref[1], (double)*dy2_ref); // CHECK-EXEC: {9.00, 0.00, 2.00} -} \ No newline at end of file +} diff --git a/test/Gradient/Lambdas.C b/test/Gradient/Lambdas.C index b39e6dc4a..f9b06aeeb 100644 --- a/test/Gradient/Lambdas.C +++ b/test/Gradient/Lambdas.C @@ -2,7 +2,6 @@ // RUN: ./Lambdas.out | %filecheck_exec %s // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oLambdas.out // RUN: ./Lambdas.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" @@ -76,4 +75,4 @@ int main() { // CHECK-NEXT: *_d_t += _d_y; // CHECK-NEXT: *_d_k += _d_y; // CHECK-NEXT: } -// CHECK-NEXT: } \ No newline at end of file +// CHECK-NEXT: } diff --git a/test/Gradient/Loops.C b/test/Gradient/Loops.C index 0c7bd00b3..8586aac60 100644 --- a/test/Gradient/Loops.C +++ b/test/Gradient/Loops.C @@ -2,7 +2,6 @@ // RUN: ./ReverseLoops.out | %filecheck_exec %s // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oReverseLoops.out // RUN: ./ReverseLoops.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" #include @@ -3231,4 +3230,4 @@ int main() { //CHECK-NEXT: *_d_x += _d_y * x; //CHECK-NEXT: *_d_x += x * _d_y; //CHECK-NEXT: } -//CHECK-NEXT: } \ No newline at end of file +//CHECK-NEXT: } diff --git a/test/Gradient/MemberFunctions.C b/test/Gradient/MemberFunctions.C index a79c0dd8b..78d58ba5b 100644 --- a/test/Gradient/MemberFunctions.C +++ b/test/Gradient/MemberFunctions.C @@ -13,7 +13,6 @@ // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr -std=c++17 %s -fno-exceptions -I%S/../../include -oMemberFunctions-cpp17.out // RUN: ./MemberFunctions-cpp17.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" class SimpleFunctions { diff --git a/test/Gradient/NonDifferentiable.C b/test/Gradient/NonDifferentiable.C index ae0006da2..3c8162bea 100644 --- a/test/Gradient/NonDifferentiable.C +++ b/test/Gradient/NonDifferentiable.C @@ -1,6 +1,5 @@ // RUN: %cladclang %s -I%S/../../include -oNonDifferentiable.out 2>&1 | %filecheck %s // RUN: ./NonDifferentiable.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #define non_differentiable __attribute__((annotate("another_attribute"), annotate("non_differentiable"))) diff --git a/test/Gradient/Pointers.C b/test/Gradient/Pointers.C index e4884e0df..21d98ecaf 100644 --- a/test/Gradient/Pointers.C +++ b/test/Gradient/Pointers.C @@ -1,6 +1,5 @@ // RUN: %cladclang %s -I%S/../../include -oPointers.out 2>&1 | %filecheck %s // RUN: ./Pointers.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} // FIXME: This test does not work with enable-tbr flag, because the // current implementation of TBR analysis doesn't support pointers. diff --git a/test/Gradient/PointersWithTBR.C b/test/Gradient/PointersWithTBR.C index 80cb20c4a..c3a496a5b 100644 --- a/test/Gradient/PointersWithTBR.C +++ b/test/Gradient/PointersWithTBR.C @@ -1,7 +1,6 @@ // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oPointersWithTBR.out // RUN: ./PointersWithTBR.out | %filecheck_exec %s // XFAIL: * -// CHECK-NOT: {{.*error|warning|note:.*}} // FIXME: This is currently marked XFAIL because of lack of pointer support in // TBR analysis. Once TBR supports pointers, this test should be enabled diff --git a/test/Gradient/STLCustomDerivatives.C b/test/Gradient/STLCustomDerivatives.C index 082111eea..ba89aa34d 100644 --- a/test/Gradient/STLCustomDerivatives.C +++ b/test/Gradient/STLCustomDerivatives.C @@ -3,7 +3,6 @@ // RUN: ./STLCustomDerivatives.out | %filecheck_exec %s // RUN: %cladclang -std=c++14 -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oSTLCustomDerivativesWithTBR.out // RUN: ./STLCustomDerivativesWithTBR.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" #include "clad/Differentiator/STLBuiltins.h" @@ -660,4 +659,3 @@ int main() { // CHECK-NEXT: {{.*}}operator_subscript_pullback(&_t0, 1, 0., &_d_a, &_r0); // CHECK-NEXT: } // CHECK-NEXT: } - diff --git a/test/Gradient/Switch.C b/test/Gradient/Switch.C index 438800c43..6e18bc04d 100644 --- a/test/Gradient/Switch.C +++ b/test/Gradient/Switch.C @@ -1,6 +1,5 @@ -// RUN: %cladclang %s -I%S/../../include -oSwitch.out 2>&1 -lstdc++ -lm | %filecheck %s +// RUN: %cladclang %s -I%S/../../include -oSwitch.out 2>&1 -lm | %filecheck %s // RUN: ./Switch.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" #include "../TestUtils.h" diff --git a/test/Gradient/SwitchInit.C b/test/Gradient/SwitchInit.C index 03a832b8e..3b2a6016b 100644 --- a/test/Gradient/SwitchInit.C +++ b/test/Gradient/SwitchInit.C @@ -1,6 +1,5 @@ -// RUN: %cladclang %s -I%S/../../include -std=c++17 -oSwitchInit.out 2>&1 -lstdc++ -lm | %filecheck %s +// RUN: %cladclang %s -I%S/../../include -std=c++17 -oSwitchInit.out 2>&1 | %filecheck %s // RUN: ./SwitchInit.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/Gradient/TemplateFunctors.C b/test/Gradient/TemplateFunctors.C index 4468b0ef0..982a49460 100644 --- a/test/Gradient/TemplateFunctors.C +++ b/test/Gradient/TemplateFunctors.C @@ -2,7 +2,6 @@ // RUN: ./TemplateFunctors.out | %filecheck_exec %s // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oTemplateFunctors.out // RUN: ./TemplateFunctors.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/Gradient/TestAgainstDiff.C b/test/Gradient/TestAgainstDiff.C index 9378e3c54..d428a736b 100644 --- a/test/Gradient/TestAgainstDiff.C +++ b/test/Gradient/TestAgainstDiff.C @@ -3,7 +3,6 @@ // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oTestAgainstDiff.out // RUN: ./TestAgainstDiff.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/Gradient/TestTypeConversion.C b/test/Gradient/TestTypeConversion.C index 9fa99c175..4f58bdb9e 100644 --- a/test/Gradient/TestTypeConversion.C +++ b/test/Gradient/TestTypeConversion.C @@ -3,8 +3,6 @@ // RUN: %cladnumdiffclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oTestTypeConversion.out // RUN: ./TestTypeConversion.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" #include diff --git a/test/Gradient/UserDefinedTypes.C b/test/Gradient/UserDefinedTypes.C index bf5fee8c1..9b6d01258 100644 --- a/test/Gradient/UserDefinedTypes.C +++ b/test/Gradient/UserDefinedTypes.C @@ -2,7 +2,6 @@ // RUN: ./UserDefinedTypes.out | %filecheck_exec %s // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oUserDefinedTypes.out // RUN: ./UserDefinedTypes.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" @@ -512,4 +511,4 @@ int main() { // CHECK-NEXT: (*_d_this).data[i] = 0.; // CHECK-NEXT: *_d_d += _r_d0; // CHECK-NEXT: } -// CHECK-NEXT: } \ No newline at end of file +// CHECK-NEXT: } diff --git a/test/Hessian/ArrayErrors.C b/test/Hessian/ArrayErrors.C index 66d75e382..925372a71 100644 --- a/test/Hessian/ArrayErrors.C +++ b/test/Hessian/ArrayErrors.C @@ -2,7 +2,6 @@ #include "clad/Differentiator/Differentiator.h" -//CHECK-NOT: {{.*error|warning|note:.*}} //XFAIL:* double f(int a, double *b) { return b[0] * a + b[1] * a + b[2] * a; @@ -13,4 +12,4 @@ int main() { clad::hessian(f, "a"); clad::hessian(f, "a, b"); // expected-error {{Hessian mode differentiation w.r.t. array or pointer parameters needs explicit declaration of the indices of the array using the args parameter; did you mean 'clad::hessian(f, "a, b[0:]")'}} clad::hessian(f, "a, b[0:2]"); -}; \ No newline at end of file +}; diff --git a/test/Hessian/Arrays.C b/test/Hessian/Arrays.C index 39b368fca..49cf70ac2 100644 --- a/test/Hessian/Arrays.C +++ b/test/Hessian/Arrays.C @@ -3,8 +3,6 @@ // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oArrays.out // RUN: ./Arrays.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" double f(double i, double j[2]) { return i * j[0] * j[1]; } diff --git a/test/Hessian/BuiltinDerivatives.C b/test/Hessian/BuiltinDerivatives.C index 30628e4e4..942175b4f 100644 --- a/test/Hessian/BuiltinDerivatives.C +++ b/test/Hessian/BuiltinDerivatives.C @@ -4,8 +4,6 @@ // RUN: ./HessianBuiltinDerivatives.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" #include diff --git a/test/Hessian/Functors.C b/test/Hessian/Functors.C index ec9ef1740..b462b0b9b 100644 --- a/test/Hessian/Functors.C +++ b/test/Hessian/Functors.C @@ -2,7 +2,6 @@ // RUN: ./Functors.out | %filecheck_exec %s // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oFunctors.out // RUN: ./Functors.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/Hessian/Hessians.C b/test/Hessian/Hessians.C index 8d9f48717..236f03fbf 100644 --- a/test/Hessian/Hessians.C +++ b/test/Hessian/Hessians.C @@ -3,8 +3,6 @@ // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oHessians.out // RUN: ./Hessians.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" __attribute__((always_inline)) double f_cubed_add1(double a, double b) { diff --git a/test/Hessian/NestedFunctionCalls.C b/test/Hessian/NestedFunctionCalls.C index 618324c13..0aff70f2a 100644 --- a/test/Hessian/NestedFunctionCalls.C +++ b/test/Hessian/NestedFunctionCalls.C @@ -3,8 +3,6 @@ // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oNestedFunctionCalls.out // RUN: ./NestedFunctionCalls.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" diff --git a/test/Hessian/Pointers.C b/test/Hessian/Pointers.C index c18a846ef..7adeb1c38 100644 --- a/test/Hessian/Pointers.C +++ b/test/Hessian/Pointers.C @@ -2,7 +2,6 @@ // RUN: ./Pointers.out | %filecheck_exec %s // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oPointers.out // RUN: ./Pointers.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/Hessian/TemplateFunctors.C b/test/Hessian/TemplateFunctors.C index af140abd2..4a7254501 100644 --- a/test/Hessian/TemplateFunctors.C +++ b/test/Hessian/TemplateFunctors.C @@ -2,7 +2,6 @@ // RUN: ./TemplateFunctors.out | %filecheck_exec %s // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oTemplateFunctors.out // RUN: ./TemplateFunctors.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/Hessian/constexprTest.C b/test/Hessian/constexprTest.C index 32bc87438..2f8d16d09 100644 --- a/test/Hessian/constexprTest.C +++ b/test/Hessian/constexprTest.C @@ -2,7 +2,6 @@ // RUN: ./constexprTest.out | %filecheck_exec %s // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -std=c++14 -oconstexprTest.out // RUN: ./constexprTest.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" #include diff --git a/test/Hessian/testhessUtility.C b/test/Hessian/testhessUtility.C index ceb5f4648..d0fed1c9f 100644 --- a/test/Hessian/testhessUtility.C +++ b/test/Hessian/testhessUtility.C @@ -2,7 +2,6 @@ // RUN: ./testhessUtility.out | %filecheck_exec %s // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -otesthessUtility.out // RUN: ./testhessUtility.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/Jacobian/FunctionCalls.C b/test/Jacobian/FunctionCalls.C index d1ec5e26b..aa97a9ff3 100644 --- a/test/Jacobian/FunctionCalls.C +++ b/test/Jacobian/FunctionCalls.C @@ -3,8 +3,6 @@ // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oFunctionCalls.out // RUN: ./FunctionCalls.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} - #include #include "clad/Differentiator/Differentiator.h" diff --git a/test/Jacobian/Functors.C b/test/Jacobian/Functors.C index 26b3973a0..51cdf2cb7 100644 --- a/test/Jacobian/Functors.C +++ b/test/Jacobian/Functors.C @@ -2,7 +2,6 @@ // RUN: ./Functors.out | %filecheck_exec %s // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oFunctors.out // RUN: ./Functors.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/Jacobian/Jacobian.C b/test/Jacobian/Jacobian.C index 9fcbd1558..32575b377 100644 --- a/test/Jacobian/Jacobian.C +++ b/test/Jacobian/Jacobian.C @@ -3,8 +3,6 @@ // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oJacobian.out // RUN: ./Jacobian.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" #include @@ -201,4 +199,4 @@ int main() { //CHECK-NEXT: *_d_x += _d_y0 * y; //CHECK-NEXT: *_d_y += x * _d_y0; //CHECK-NEXT: } -//CHECK-NEXT:} \ No newline at end of file +//CHECK-NEXT:} diff --git a/test/Jacobian/Pointers.C b/test/Jacobian/Pointers.C index 3b0168745..d4bc2e495 100644 --- a/test/Jacobian/Pointers.C +++ b/test/Jacobian/Pointers.C @@ -2,7 +2,6 @@ // RUN: ./Pointers.out | %filecheck_exec %s // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oPointers.out // RUN: ./Pointers.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/Jacobian/TemplateFunctors.C b/test/Jacobian/TemplateFunctors.C index 95c8c9d4c..0a0a67f52 100644 --- a/test/Jacobian/TemplateFunctors.C +++ b/test/Jacobian/TemplateFunctors.C @@ -2,7 +2,6 @@ // RUN: ./TemplateFunctors.out | %filecheck_exec %s // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oTemplateFunctors.out // RUN: ./TemplateFunctors.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/Jacobian/constexprTest.C b/test/Jacobian/constexprTest.C index 7bf14dc7c..fb3f10c9f 100644 --- a/test/Jacobian/constexprTest.C +++ b/test/Jacobian/constexprTest.C @@ -2,7 +2,6 @@ // RUN: ./constexprTest.out | %filecheck_exec %s // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -std=c++14 -oconstexprTest.out // RUN: ./constexprTest.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/Jacobian/testUtility.C b/test/Jacobian/testUtility.C index 34fcbe4f2..e9f2ed4d6 100644 --- a/test/Jacobian/testUtility.C +++ b/test/Jacobian/testUtility.C @@ -2,7 +2,6 @@ // RUN: ./testUtility.out | %filecheck_exec %s // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -otestUtility.out // RUN: ./testUtility.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/Misc/CladArray.C b/test/Misc/CladArray.C index 53734137e..7cb9f39c8 100644 --- a/test/Misc/CladArray.C +++ b/test/Misc/CladArray.C @@ -1,6 +1,5 @@ // RUN: %cladclang %s -I%S/../../include -oCladArray.out 2>&1 // RUN: ./CladArray.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/Misc/CladMatrix.C b/test/Misc/CladMatrix.C index 1d7d0d205..e6016bd48 100644 --- a/test/Misc/CladMatrix.C +++ b/test/Misc/CladMatrix.C @@ -1,6 +1,5 @@ // RUN: %cladclang %s -I%S/../../include -oCladMatrix.out 2>&1 // RUN: ./CladMatrix.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/Misc/ClangConsumers.cpp b/test/Misc/ClangConsumers.cpp index f445ec39b..d203ce703 100644 --- a/test/Misc/ClangConsumers.cpp +++ b/test/Misc/ClangConsumers.cpp @@ -1,7 +1,6 @@ // RUN: %cladclang %s -I%S/../../include -oClangConsumers.out \ // RUN: -fms-compatibility -DMS_COMPAT -std=c++14 -fmodules \ // RUN: -Xclang -print-stats 2>&1 | %filecheck %s -// CHECK-NOT: {{.*error|warning|note:.*}} // // RUN: clang -xc -Xclang -add-plugin -Xclang clad -Xclang -load \ // RUN: -Xclang %cladlib %s -I%S/../../include -oClangConsumers.out \ diff --git a/test/Misc/TapeMemory.C b/test/Misc/TapeMemory.C index 394b62789..0f908ef9d 100644 --- a/test/Misc/TapeMemory.C +++ b/test/Misc/TapeMemory.C @@ -1,6 +1,5 @@ // RUN: %cladclang %s -I%S/../../include -oTapeMemory.out 2>&1 // RUN: ./TapeMemory.out -// CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/Misc/TimingsReport.C b/test/Misc/TimingsReport.C index ae915217d..6b8dc9282 100644 --- a/test/Misc/TimingsReport.C +++ b/test/Misc/TimingsReport.C @@ -1,7 +1,6 @@ // RUN: %cladclang %s -I%S/../../include -oTimingsReport.out -ftime-report 2>&1 | %filecheck %s #include "clad/Differentiator/Differentiator.h" -// CHECK-NOT: {{.*error|warning|note:.*}} // CHECK: Timers for Clad Funcs double nested1(double c){ @@ -28,4 +27,4 @@ int main() { printf("Result is = %f\n", d_fn_1.execute(3,4)); printf("Result is = %f %f\n", dp, dq); return 0; -} \ No newline at end of file +} diff --git a/test/MixedDerivatives/Simple.C b/test/MixedDerivatives/Simple.C index d02fee82a..e04cd47cd 100644 --- a/test/MixedDerivatives/Simple.C +++ b/test/MixedDerivatives/Simple.C @@ -1,8 +1,6 @@ // RUN: %cladclang %s -I%S/../../include -oSimple.out -Xclang -verify 2>&1 | %filecheck %s // RUN: ./Simple.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" extern "C" int printf(const char* fmt, ...); diff --git a/test/NestedCalls/NestedCalls.C b/test/NestedCalls/NestedCalls.C index d6eb4da19..9c9eb56be 100644 --- a/test/NestedCalls/NestedCalls.C +++ b/test/NestedCalls/NestedCalls.C @@ -3,8 +3,6 @@ // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oNestedCalls.out // RUN: ./NestedCalls.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" #include diff --git a/test/NumericalDiff/GradientMultiArg.C b/test/NumericalDiff/GradientMultiArg.C index 5e9a07dff..9983e42e0 100644 --- a/test/NumericalDiff/GradientMultiArg.C +++ b/test/NumericalDiff/GradientMultiArg.C @@ -3,8 +3,6 @@ // RUN: %cladnumdiffclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oGradientMultiArg.out -Xclang -verify // RUN: ./GradientMultiArg.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" #include @@ -12,7 +10,7 @@ double test_1(double x, double y){ return std::hypot(x, y); // expected-warning {{function 'hypot' was not differentiated}} - // expected-note@14 {{falling back to numerical differentiation}} + // expected-note@12 {{falling back to numerical differentiation}} } // CHECK: void test_1_grad(double x, double y, double *_d_x, double *_d_y) { // CHECK-NEXT: { diff --git a/test/NumericalDiff/NoNumDiff.C b/test/NumericalDiff/NoNumDiff.C index 7f514926a..50156df29 100644 --- a/test/NumericalDiff/NoNumDiff.C +++ b/test/NumericalDiff/NoNumDiff.C @@ -1,13 +1,11 @@ // RUN: %cladclang %s -I%S/../../include -oNoNumDiff.out -Xclang -verify 2>&1 | FileCheck -check-prefix=CHECK %s -//CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" #include double func(double x) { return std::tanh(x); } // expected-warning 2{{function 'tanh' was not differentiated because clad failed to differentiate it and no suitable overload was found in namespace 'custom_derivatives'}} -// expected-note@9 2{{fallback to numerical differentiation is disabled by the 'CLAD_NO_NUM_DIFF' macro}} +// expected-note@7 2{{fallback to numerical differentiation is disabled by the 'CLAD_NO_NUM_DIFF' macro}} //CHECK: double func_darg0(double x) { //CHECK-NEXT: double _d_x = 1; diff --git a/test/NumericalDiff/NumDiff.C b/test/NumericalDiff/NumDiff.C index d5cd62dc2..dacafe641 100644 --- a/test/NumericalDiff/NumDiff.C +++ b/test/NumericalDiff/NumDiff.C @@ -2,12 +2,11 @@ // RUN: ./NumDiff.out | %filecheck_exec %s // RUN: %cladnumdiffclang -Xclang -plugin-arg-clad -Xclang -enable-tbr -Xclang -verify %s -I%S/../../include -oNumDiff.out // RUN: ./NumDiff.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" double test_1(double x){ return tanh(x); // expected-warning {{function 'tanh' was not differentiated because clad failed to differentiate it and no suitable overload was found in namespace 'custom_derivatives'}} - // expected-note@9 {{falling back to numerical differentiation for 'tanh'}} + // expected-note@8 {{falling back to numerical differentiation for 'tanh'}} } //CHECK: void test_1_grad(double x, double *_d_x) { @@ -21,7 +20,7 @@ double test_1(double x){ double test_2(double x){ return std::log10(x);// expected-warning {{function 'log10' was not differentiated because clad failed to differentiate it and no suitable overload was found in namespace 'custom_derivatives'}} - // expected-note@23 {{falling back to numerical differentiation for 'log10'}} + // expected-note@22 {{falling back to numerical differentiation for 'log10'}} } //CHECK: double test_2_darg0(double x) { //CHECK-NEXT: double _d_x = 1; @@ -33,7 +32,7 @@ double test_3(double x) { if (x > 0) { double constant = 11.; return std::hypot(x, constant); // expected-warning {{function 'hypot' was not differentiated because clad failed to differentiate it and no suitable overload was found in namespace 'custom_derivatives'}} - // expected-note@35 {{falling back to numerical differentiation for 'hypot'}} + // expected-note@34 {{falling back to numerical differentiation for 'hypot'}} } return 0; } diff --git a/test/NumericalDiff/PrintErrorNumDiff.C b/test/NumericalDiff/PrintErrorNumDiff.C index 35957d7e1..21945f893 100644 --- a/test/NumericalDiff/PrintErrorNumDiff.C +++ b/test/NumericalDiff/PrintErrorNumDiff.C @@ -3,8 +3,6 @@ // RUN: %cladnumdiffclang -Xclang -plugin-arg-clad -Xclang -fprint-num-diff-errors -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oPrintErrorNumDiff.out -Xclang -verify // RUN: ./PrintErrorNumDiff.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" #include @@ -13,7 +11,7 @@ extern "C" int printf(const char* fmt, ...); double test_1(double x){ return tanh(x); // expected-warning {{function 'tanh' was not differentiated because}} - // expected-note@15 {{falling back to numerical differentiation for 'tanh}} + // expected-note@13 {{falling back to numerical differentiation for 'tanh}} } //CHECK: void test_1_grad(double x, double *_d_x) { diff --git a/test/NumericalDiff/PureCentralDiffCalls.C b/test/NumericalDiff/PureCentralDiffCalls.C index b96b13515..399e7f784 100644 --- a/test/NumericalDiff/PureCentralDiffCalls.C +++ b/test/NumericalDiff/PureCentralDiffCalls.C @@ -1,8 +1,6 @@ // RUN: %cladnumdiffclang %s -I%S/../../include -oPureCentralDiffCalls.out // -Xclang -verify 2>&1 RUN: ./PureCentralDiffCalls.out | %filecheck_exec %s -// CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" #include diff --git a/test/NumericalDiff/UserDefinedPointers.C b/test/NumericalDiff/UserDefinedPointers.C index 13c14e47a..679c8daf3 100644 --- a/test/NumericalDiff/UserDefinedPointers.C +++ b/test/NumericalDiff/UserDefinedPointers.C @@ -1,8 +1,6 @@ // RUN: %cladnumdiffclang %s -I%S/../../include -oUserDefinedPointers.out -Xclang -verify 2>&1 // RUN: ./UserDefinedPointers.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" struct myStruct diff --git a/test/ROOT/Hessian.C b/test/ROOT/Hessian.C index dbea92c9d..6dc47655c 100644 --- a/test/ROOT/Hessian.C +++ b/test/ROOT/Hessian.C @@ -3,8 +3,6 @@ // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oHessian.out // RUN: ./Hessian.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" #include @@ -33,4 +31,4 @@ int main() { matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5], matrix[6], matrix[7], matrix[8]); // CHECK-EXEC: Result is = {2.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00} -} \ No newline at end of file +} diff --git a/test/ROOT/Interface.C b/test/ROOT/Interface.C index 71cef5488..caeeaebf2 100644 --- a/test/ROOT/Interface.C +++ b/test/ROOT/Interface.C @@ -3,8 +3,6 @@ // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oInterface.out // RUN: ./Interface.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" using Double_t = double; diff --git a/test/ROOT/TFormula.C b/test/ROOT/TFormula.C index d8222cab3..2c2bdad3c 100644 --- a/test/ROOT/TFormula.C +++ b/test/ROOT/TFormula.C @@ -3,8 +3,6 @@ // RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oTFormula.out // RUN: ./TFormula.out | %filecheck_exec %s -//CHECK-NOT: {{.*error|warning|note:.*}} - #include "clad/Differentiator/Differentiator.h" #include diff --git a/test/lit.cfg b/test/lit.cfg index d5ef13f51..484a84e48 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -201,7 +201,7 @@ for pattern in [r"\bbugpoint\b(?!-)", r"(? Date: Sat, 14 Sep 2024 10:55:02 +0000 Subject: [PATCH 07/14] [cuda] Add a return statement to suppress diagnostics. --- include/clad/Differentiator/Differentiator.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/clad/Differentiator/Differentiator.h b/include/clad/Differentiator/Differentiator.h index db9b699f2..3a8f35faf 100644 --- a/include/clad/Differentiator/Differentiator.h +++ b/include/clad/Differentiator/Differentiator.h @@ -145,9 +145,9 @@ CUDA_HOST_DEVICE T push(tape& to, ArgsT... val) { if (CUDAkernel) { void* argPtrs[] = {(void*)&args...}; cudaLaunchKernel((void*)f, grid, block, argPtrs, shared_mem, stream); - } else { - return f(static_cast(args)...); + return return_type_t(); } + return f(static_cast(args)...); #else return f(static_cast(args)...); #endif From b414202a81dc48057c3bdde4055557722fcd080b Mon Sep 17 00:00:00 2001 From: ovdiiuv <104850830+ovdiiuv@users.noreply.github.com> Date: Sun, 15 Sep 2024 17:56:38 +0200 Subject: [PATCH 08/14] Store and restore outputaArray elements for jacobians (#1093) Before this PR, outputArray's elements weren't stored if they were changed. It would also fix an issue with enabling activity analysis. --- lib/Differentiator/ReverseModeVisitor.cpp | 4 +- test/Jacobian/FunctionCalls.C | 29 ++- test/Jacobian/Functors.C | 219 +++++++++++------ test/Jacobian/Jacobian.C | 275 +++++++++++++--------- test/Jacobian/Pointers.C | 14 +- test/Jacobian/TemplateFunctors.C | 37 ++- test/Jacobian/constexprTest.C | 108 +++++---- test/Jacobian/testUtility.C | 109 +++++---- 8 files changed, 504 insertions(+), 291 deletions(-) diff --git a/lib/Differentiator/ReverseModeVisitor.cpp b/lib/Differentiator/ReverseModeVisitor.cpp index c1e5442f2..0bc96501a 100644 --- a/lib/Differentiator/ReverseModeVisitor.cpp +++ b/lib/Differentiator/ReverseModeVisitor.cpp @@ -2518,8 +2518,6 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context, // For x, ResultRef is _d_x, for x[i] its _d_x[i], for reference exprs // like (x = y) it propagates recursively, so _d_x is also returned. ResultRef = Ldiff.getExpr_dx(); - if (!ResultRef) - return Clone(BinOp); // If assigned expr is dependent, first update its derivative; if (dfdx() && !Lblock.empty()) { addToCurrentBlock(*Lblock.begin(), direction::reverse); @@ -2534,6 +2532,8 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context, addToCurrentBlock(pushPop.getStmt_dx(), direction::reverse); } + if (!ResultRef) + return Clone(BinOp); // We need to store values of derivative pointer variables in forward pass // and restore them in reverse pass. if (isPointerOp) { diff --git a/test/Jacobian/FunctionCalls.C b/test/Jacobian/FunctionCalls.C index aa97a9ff3..da7d5420c 100644 --- a/test/Jacobian/FunctionCalls.C +++ b/test/Jacobian/FunctionCalls.C @@ -14,21 +14,29 @@ void fn1(double i, double j, double* output) { } // CHECK: void fn1_jac(double i, double j, double *output, double *jacobianMatrix) { +// CHECK-NEXT: double _t0 = output[0]; // CHECK-NEXT: output[0] = std::pow(i, j); +// CHECK-NEXT: double _t1 = output[1]; // CHECK-NEXT: output[1] = std::pow(j, i); // CHECK-NEXT: { -// CHECK-NEXT: double _r2 = 0.; -// CHECK-NEXT: double _r3 = 0.; -// CHECK-NEXT: clad::custom_derivatives::pow_pullback(j, i, 1, &_r2, &_r3); -// CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += _r2; -// CHECK-NEXT: jacobianMatrix[{{2U|2UL|2ULL}}] += _r3; +// CHECK-NEXT: { +// CHECK-NEXT: double _r2 = 0.; +// CHECK-NEXT: double _r3 = 0.; +// CHECK-NEXT: clad::custom_derivatives::pow_pullback(j, i, 1, &_r2, &_r3); +// CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += _r2; +// CHECK-NEXT: jacobianMatrix[{{2U|2UL|2ULL}}] += _r3; +// CHECK-NEXT: } +// CHECK-NEXT: output[1] = _t1; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: double _r0 = 0.; -// CHECK-NEXT: double _r1 = 0.; -// CHECK-NEXT: clad::custom_derivatives::pow_pullback(i, j, 1, &_r0, &_r1); -// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += _r0; -// CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += _r1; +// CHECK-NEXT: { +// CHECK-NEXT: double _r0 = 0.; +// CHECK-NEXT: double _r1 = 0.; +// CHECK-NEXT: clad::custom_derivatives::pow_pullback(i, j, 1, &_r0, &_r1); +// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += _r0; +// CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += _r1; +// CHECK-NEXT: } +// CHECK-NEXT: output[0] = _t0; // CHECK-NEXT: } // CHECK-NEXT: } @@ -59,3 +67,4 @@ int main() { test<2>(DERIVED_FN(fn1), 3, 5); // CHECK-EXEC: {405.00, 266.96, 201.18, 75.00} } + diff --git a/test/Jacobian/Functors.C b/test/Jacobian/Functors.C index 51cdf2cb7..cf04e1291 100644 --- a/test/Jacobian/Functors.C +++ b/test/Jacobian/Functors.C @@ -17,19 +17,28 @@ struct Experiment { } // CHECK: void operator_call_jac(double i, double j, double *output, double *jacobianMatrix) { + // CHECK-NEXT: double _t0 = output[0]; // CHECK-NEXT: output[0] = this->x * i * i * j; + // CHECK-NEXT: double _t1 = output[1]; // CHECK-NEXT: output[1] = this->y * i * j * j; // CHECK-NEXT: { - // CHECK-NEXT: jacobianMatrix[{{2U|2UL|2ULL}}] += this->y * 1 * j * j; - // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += this->y * i * 1 * j; - // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += this->y * i * j * 1; + // CHECK-NEXT: { + // CHECK-NEXT: jacobianMatrix[{{2U|2UL|2ULL}}] += this->y * 1 * j * j; + // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += this->y * i * 1 * j; + // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += this->y * i * j * 1; + // CHECK-NEXT: } + // CHECK-NEXT: output[1] = _t1; // CHECK-NEXT: } // CHECK-NEXT: { - // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += this->x * 1 * j * i; - // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += this->x * i * 1 * j; - // CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += this->x * i * i * 1; + // CHECK-NEXT: { + // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += this->x * 1 * j * i; + // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += this->x * i * 1 * j; + // CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += this->x * i * i * 1; + // CHECK-NEXT: } + // CHECK-NEXT: output[0] = _t0; // CHECK-NEXT: } // CHECK-NEXT: } + }; struct ExperimentConst { @@ -44,19 +53,28 @@ struct ExperimentConst { } // CHECK: void operator_call_jac(double i, double j, double *output, double *jacobianMatrix) const { + // CHECK-NEXT: double _t0 = output[0]; // CHECK-NEXT: output[0] = this->x * i * i * j; + // CHECK-NEXT: double _t1 = output[1]; // CHECK-NEXT: output[1] = this->y * i * j * j; // CHECK-NEXT: { - // CHECK-NEXT: jacobianMatrix[{{2U|2UL|2ULL}}] += this->y * 1 * j * j; - // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += this->y * i * 1 * j; - // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += this->y * i * j * 1; + // CHECK-NEXT: { + // CHECK-NEXT: jacobianMatrix[{{2U|2UL|2ULL}}] += this->y * 1 * j * j; + // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += this->y * i * 1 * j; + // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += this->y * i * j * 1; + // CHECK-NEXT: } + // CHECK-NEXT: output[1] = _t1; // CHECK-NEXT: } // CHECK-NEXT: { - // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += this->x * 1 * j * i; - // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += this->x * i * 1 * j; - // CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += this->x * i * i * 1; + // CHECK-NEXT: { + // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += this->x * 1 * j * i; + // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += this->x * i * 1 * j; + // CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += this->x * i * i * 1; + // CHECK-NEXT: } + // CHECK-NEXT: output[0] = _t0; // CHECK-NEXT: } // CHECK-NEXT: } + }; struct ExperimentVolatile { @@ -72,20 +90,29 @@ struct ExperimentVolatile { // CHECK: void operator_call_jac(double i, double j, double *output, double *jacobianMatrix) volatile { // CHECK-NEXT: double _t0 = this->x * i; + // CHECK-NEXT: double _t1 = output[0]; // CHECK-NEXT: output[0] = this->x * i * i * j; - // CHECK-NEXT: double _t1 = this->y * i; + // CHECK-NEXT: double _t2 = this->y * i; + // CHECK-NEXT: double _t3 = output[1]; // CHECK-NEXT: output[1] = this->y * i * j * j; // CHECK-NEXT: { - // CHECK-NEXT: jacobianMatrix[{{2U|2UL|2ULL}}] += this->y * 1 * j * j; - // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += _t1 * 1 * j; - // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += _t1 * j * 1; + // CHECK-NEXT: { + // CHECK-NEXT: jacobianMatrix[{{2U|2UL|2ULL}}] += this->y * 1 * j * j; + // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += _t2 * 1 * j; + // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += _t2 * j * 1; + // CHECK-NEXT: } + // CHECK-NEXT: output[1] = _t3; // CHECK-NEXT: } // CHECK-NEXT: { - // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += this->x * 1 * j * i; - // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += _t0 * 1 * j; - // CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += _t0 * i * 1; + // CHECK-NEXT: { + // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += this->x * 1 * j * i; + // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += _t0 * 1 * j; + // CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += _t0 * i * 1; + // CHECK-NEXT: } + // CHECK-NEXT: output[0] = _t1; // CHECK-NEXT: } // CHECK-NEXT: } + }; struct ExperimentConstVolatile { @@ -101,20 +128,29 @@ struct ExperimentConstVolatile { // CHECK: void operator_call_jac(double i, double j, double *output, double *jacobianMatrix) const volatile { // CHECK-NEXT: double _t0 = this->x * i; + // CHECK-NEXT: double _t1 = output[0]; // CHECK-NEXT: output[0] = this->x * i * i * j; - // CHECK-NEXT: double _t1 = this->y * i; + // CHECK-NEXT: double _t2 = this->y * i; + // CHECK-NEXT: double _t3 = output[1]; // CHECK-NEXT: output[1] = this->y * i * j * j; // CHECK-NEXT: { - // CHECK-NEXT: jacobianMatrix[{{2U|2UL|2ULL}}] += this->y * 1 * j * j; - // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += _t1 * 1 * j; - // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += _t1 * j * 1; + // CHECK-NEXT: { + // CHECK-NEXT: jacobianMatrix[{{2U|2UL|2ULL}}] += this->y * 1 * j * j; + // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += _t2 * 1 * j; + // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += _t2 * j * 1; + // CHECK-NEXT: } + // CHECK-NEXT: output[1] = _t3; // CHECK-NEXT: } // CHECK-NEXT: { - // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += this->x * 1 * j * i; - // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += _t0 * 1 * j; - // CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += _t0 * i * 1; + // CHECK-NEXT: { + // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += this->x * 1 * j * i; + // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += _t0 * 1 * j; + // CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += _t0 * i * 1; + // CHECK-NEXT: } + // CHECK-NEXT: output[0] = _t1; // CHECK-NEXT: } // CHECK-NEXT: } + }; namespace outer { @@ -130,20 +166,29 @@ namespace outer { x = val; } - // CHECK: void operator_call_jac(double i, double j, double *output, double *jacobianMatrix) { - // CHECK-NEXT: output[0] = this->x * i * i * j; - // CHECK-NEXT: output[1] = this->y * i * j * j; - // CHECK-NEXT: { - // CHECK-NEXT: jacobianMatrix[{{2U|2UL|2ULL}}] += this->y * 1 * j * j; - // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += this->y * i * 1 * j; - // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += this->y * i * j * 1; - // CHECK-NEXT: } - // CHECK-NEXT: { - // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += this->x * 1 * j * i; - // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += this->x * i * 1 * j; - // CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += this->x * i * i * 1; - // CHECK-NEXT: } - // CHECK-NEXT: } + // CHECK: void operator_call_jac(double i, double j, double *output, double *jacobianMatrix) { + // CHECK-NEXT: double _t0 = output[0]; + // CHECK-NEXT: output[0] = this->x * i * i * j; + // CHECK-NEXT: double _t1 = output[1]; + // CHECK-NEXT: output[1] = this->y * i * j * j; + // CHECK-NEXT: { + // CHECK-NEXT: { + // CHECK-NEXT: jacobianMatrix[{{2U|2UL|2ULL}}] += this->y * 1 * j * j; + // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += this->y * i * 1 * j; + // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += this->y * i * j * 1; + // CHECK-NEXT: } + // CHECK-NEXT: output[1] = _t1; + // CHECK-NEXT: } + // CHECK-NEXT: { + // CHECK-NEXT: { + // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += this->x * 1 * j * i; + // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += this->x * i * 1 * j; + // CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += this->x * i * i * 1; + // CHECK-NEXT: } + // CHECK-NEXT: output[0] = _t0; + // CHECK-NEXT: } + // CHECK-NEXT: } + }; auto lambdaNNS = [](double i, double j, double *output) { @@ -151,20 +196,29 @@ namespace outer { output[1] = i*j*j; }; - // CHECK: inline void operator_call_jac(double i, double j, double *output, double *jacobianMatrix) const { - // CHECK-NEXT: output[0] = i * i * j; - // CHECK-NEXT: output[1] = i * j * j; - // CHECK-NEXT: { - // CHECK-NEXT: jacobianMatrix[{{2U|2UL|2ULL}}] += 1 * j * j; - // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += i * 1 * j; - // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += i * j * 1; - // CHECK-NEXT: } - // CHECK-NEXT: { - // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += 1 * j * i; - // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += i * 1 * j; - // CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += i * i * 1; - // CHECK-NEXT: } - // CHECK-NEXT: } + // CHECK: inline void operator_call_jac(double i, double j, double *output, double *jacobianMatrix) const { + // CHECK-NEXT: double _t0 = output[0]; + // CHECK-NEXT: output[0] = i * i * j; + // CHECK-NEXT: double _t1 = output[1]; + // CHECK-NEXT: output[1] = i * j * j; + // CHECK-NEXT: { + // CHECK-NEXT: { + // CHECK-NEXT: jacobianMatrix[{{2U|2UL|2ULL}}] += 1 * j * j; + // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += i * 1 * j; + // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += i * j * 1; + // CHECK-NEXT: } + // CHECK-NEXT: output[1] = _t1; + // CHECK-NEXT: } + // CHECK-NEXT: { + // CHECK-NEXT: { + // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += 1 * j * i; + // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += i * 1 * j; + // CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += i * i * 1; + // CHECK-NEXT: } + // CHECK-NEXT: output[0] = _t0; + // CHECK-NEXT: } + // CHECK-NEXT: } + } } @@ -201,17 +255,25 @@ int main() { }; // CHECK: inline void operator_call_jac(double i, double j, double *output, double *jacobianMatrix) const { + // CHECK-NEXT: double _t0 = output[0]; // CHECK-NEXT: output[0] = i * i * j; + // CHECK-NEXT: double _t1 = output[1]; // CHECK-NEXT: output[1] = i * j * j; // CHECK-NEXT: { - // CHECK-NEXT: jacobianMatrix[{{2U|2UL|2ULL}}] += 1 * j * j; - // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += i * 1 * j; - // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += i * j * 1; + // CHECK-NEXT: { + // CHECK-NEXT: jacobianMatrix[{{2U|2UL|2ULL}}] += 1 * j * j; + // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += i * 1 * j; + // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += i * j * 1; + // CHECK-NEXT: } + // CHECK-NEXT: output[1] = _t1; // CHECK-NEXT: } // CHECK-NEXT: { - // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += 1 * j * i; - // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += i * 1 * j; - // CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += i * i * 1; + // CHECK-NEXT: { + // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += 1 * j * i; + // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += i * 1 * j; + // CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += i * i * 1; + // CHECK-NEXT: } + // CHECK-NEXT: output[0] = _t0; // CHECK-NEXT: } // CHECK-NEXT: } @@ -220,20 +282,28 @@ int main() { output[1] = y*i*jj*jj; }; - // CHECK: inline void operator_call_jac(double i, double jj, double *output, double *jacobianMatrix) const { - // CHECK-NEXT: output[0] = x * i * i * jj; - // CHECK-NEXT: output[1] = y * i * jj * jj; - // CHECK-NEXT: { - // CHECK-NEXT: jacobianMatrix[{{2U|2UL|2ULL}}] += y * 1 * jj * jj; - // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += y * i * 1 * jj; - // CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += y * i * jj * 1; - // CHECK-NEXT: } - // CHECK-NEXT: { - // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += x * 1 * jj * i; - // CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += x * i * 1 * jj; - // CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += x * i * i * 1; - // CHECK-NEXT: } - // CHECK-NEXT: } +// CHECK: inline void operator_call_jac(double i, double jj, double *output, double *jacobianMatrix) const { +// CHECK-NEXT: double _t0 = output[0]; +// CHECK-NEXT: output[0] = x * i * i * jj; +// CHECK-NEXT: double _t1 = output[1]; +// CHECK-NEXT: output[1] = y * i * jj * jj; +// CHECK-NEXT: { +// CHECK-NEXT: { +// CHECK-NEXT: jacobianMatrix[{{2U|2UL|2ULL}}] += y * 1 * jj * jj; +// CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += y * i * 1 * jj; +// CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += y * i * jj * 1; +// CHECK-NEXT: } +// CHECK-NEXT: output[1] = _t1; +// CHECK-NEXT: } +// CHECK-NEXT: { +// CHECK-NEXT: { +// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += x * 1 * jj * i; +// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += x * i * 1 * jj; +// CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += x * i * i * 1; +// CHECK-NEXT: } +// CHECK-NEXT: output[0] = _t0; +// CHECK-NEXT: } +// CHECK-NEXT: } auto lambdaNNS = outer::inner::lambdaNNS; @@ -277,3 +347,4 @@ int main() { TEST(E_NNS_Again); // CHECK-EXEC: {756.00, 294.00, 405.00, 630.00}, {756.00, 294.00, 405.00, 630.00} TEST(lambdaWithCapture); // CHECK-EXEC: {756.00, 294.00, 405.00, 630.00}, {756.00, 294.00, 405.00, 630.00} } + diff --git a/test/Jacobian/Jacobian.C b/test/Jacobian/Jacobian.C index 32575b377..4d9537022 100644 --- a/test/Jacobian/Jacobian.C +++ b/test/Jacobian/Jacobian.C @@ -13,31 +13,43 @@ void f_1(double a, double b, double c, double output[]) { } void f_1_jac(double a, double b, double c, double output[], double *_result); -//CHECK:void f_1_jac(double a, double b, double c, double output[], double *jacobianMatrix) { -//CHECK-NEXT: output[0] = a * a * a; -//CHECK-NEXT: output[1] = a * a * a + b * b * b; -//CHECK-NEXT: output[2] = c * c * 10 - a * a; -//CHECK-NEXT: { -//CHECK-NEXT: jacobianMatrix[{{8U|8UL|8ULL}}] += 1 * 10 * c; -//CHECK-NEXT: jacobianMatrix[{{8U|8UL|8ULL}}] += c * 1 * 10; -//CHECK-NEXT: jacobianMatrix[{{6U|6UL|6ULL}}] += -1 * a; -//CHECK-NEXT: jacobianMatrix[{{6U|6UL|6ULL}}] += a * -1; -//CHECK-NEXT: } -//CHECK-NEXT: { -//CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += 1 * a * a; -//CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += a * 1 * a; -//CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += a * a * 1; -//CHECK-NEXT: jacobianMatrix[{{4U|4UL|4ULL}}] += 1 * b * b; -//CHECK-NEXT: jacobianMatrix[{{4U|4UL|4ULL}}] += b * 1 * b; -//CHECK-NEXT: jacobianMatrix[{{4U|4UL|4ULL}}] += b * b * 1; -//CHECK-NEXT: } -//CHECK-NEXT: { -//CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += 1 * a * a; -//CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += a * 1 * a; -//CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += a * a * 1; -//CHECK-NEXT: } -//CHECK-NEXT:} +// CHECK: void f_1_jac(double a, double b, double c, double output[], double *jacobianMatrix) { +// CHECK-NEXT: double _t0 = output[0]; +// CHECK-NEXT: output[0] = a * a * a; +// CHECK-NEXT: double _t1 = output[1]; +// CHECK-NEXT: output[1] = a * a * a + b * b * b; +// CHECK-NEXT: double _t2 = output[2]; +// CHECK-NEXT: output[2] = c * c * 10 - a * a; +// CHECK-NEXT: { +// CHECK-NEXT: { +// CHECK-NEXT: jacobianMatrix[{{8U|8UL|8ULL}}] += 1 * 10 * c; +// CHECK-NEXT: jacobianMatrix[{{8U|8UL|8ULL}}] += c * 1 * 10; +// CHECK-NEXT: jacobianMatrix[{{6U|6UL|6ULL}}] += -1 * a; +// CHECK-NEXT: jacobianMatrix[{{6U|6UL|6ULL}}] += a * -1; +// CHECK-NEXT: } +// CHECK-NEXT: output[2] = _t2; +// CHECK-NEXT: } +// CHECK-NEXT: { +// CHECK-NEXT: { +// CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += 1 * a * a; +// CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += a * 1 * a; +// CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += a * a * 1; +// CHECK-NEXT: jacobianMatrix[{{4U|4UL|4ULL}}] += 1 * b * b; +// CHECK-NEXT: jacobianMatrix[{{4U|4UL|4ULL}}] += b * 1 * b; +// CHECK-NEXT: jacobianMatrix[{{4U|4UL|4ULL}}] += b * b * 1; +// CHECK-NEXT: } +// CHECK-NEXT: output[1] = _t1; +// CHECK-NEXT: } +// CHECK-NEXT: { +// CHECK-NEXT: { +// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += 1 * a * a; +// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += a * 1 * a; +// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += a * a * 1; +// CHECK-NEXT: } +// CHECK-NEXT: output[0] = _t0; +// CHECK-NEXT: } +// CHECK-NEXT: } void f_3(double x, double y, double z, double *_result) { double constant = 42; @@ -48,32 +60,44 @@ void f_3(double x, double y, double z, double *_result) { } void f_3_jac(double x, double y, double z, double *_result, double *jacobianMatrix); -//CHECK: void f_3_jac(double x, double y, double z, double *_result, double *jacobianMatrix) { -//CHECK-NEXT: double _d_constant = 0.; -//CHECK-NEXT: double constant = 42; -//CHECK-NEXT: double _t0 = sin(x); -//CHECK-NEXT: _result[0] = sin(x) * constant; -//CHECK-NEXT: double _t1 = sin(y); -//CHECK-NEXT: _result[1] = sin(y) * constant; -//CHECK-NEXT: double _t2 = sin(z); -//CHECK-NEXT: _result[2] = sin(z) * constant; -//CHECK-NEXT: { -//CHECK-NEXT: double _r2 = 0.; -//CHECK-NEXT: _r2 += 1 * constant * clad::custom_derivatives::sin_pushforward(z, 1.).pushforward; -//CHECK-NEXT: jacobianMatrix[{{8U|8UL|8ULL}}] += _r2; -//CHECK-NEXT: } -//CHECK-NEXT: { -//CHECK-NEXT: double _r1 = 0.; -//CHECK-NEXT: _r1 += 1 * constant * clad::custom_derivatives::sin_pushforward(y, 1.).pushforward; -//CHECK-NEXT: jacobianMatrix[{{4U|4UL|4ULL}}] += _r1; -//CHECK-NEXT: } -//CHECK-NEXT: { -//CHECK-NEXT: double _r0 = 0.; -//CHECK-NEXT: _r0 += 1 * constant * clad::custom_derivatives::sin_pushforward(x, 1.).pushforward; -//CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += _r0; -//CHECK-NEXT: } -//CHECK-NEXT:} +// CHECK: void f_3_jac(double x, double y, double z, double *_result, double *jacobianMatrix) { +// CHECK-NEXT: double _d_constant = 0.; +// CHECK-NEXT: double constant = 42; +// CHECK-NEXT: double _t0 = sin(x); +// CHECK-NEXT: double _t1 = _result[0]; +// CHECK-NEXT: _result[0] = sin(x) * constant; +// CHECK-NEXT: double _t2 = sin(y); +// CHECK-NEXT: double _t3 = _result[1]; +// CHECK-NEXT: _result[1] = sin(y) * constant; +// CHECK-NEXT: double _t4 = sin(z); +// CHECK-NEXT: double _t5 = _result[2]; +// CHECK-NEXT: _result[2] = sin(z) * constant; +// CHECK-NEXT: { +// CHECK-NEXT: { +// CHECK-NEXT: double _r2 = 0.; +// CHECK-NEXT: _r2 += 1 * constant * clad::custom_derivatives::sin_pushforward(z, 1.).pushforward; +// CHECK-NEXT: jacobianMatrix[{{8U|8UL|8ULL}}] += _r2; +// CHECK-NEXT: } +// CHECK-NEXT: _result[2] = _t5; +// CHECK-NEXT: } +// CHECK-NEXT: { +// CHECK-NEXT: { +// CHECK-NEXT: double _r1 = 0.; +// CHECK-NEXT: _r1 += 1 * constant * clad::custom_derivatives::sin_pushforward(y, 1.).pushforward; +// CHECK-NEXT: jacobianMatrix[{{4U|4UL|4ULL}}] += _r1; +// CHECK-NEXT: } +// CHECK-NEXT: _result[1] = _t3; +// CHECK-NEXT: } +// CHECK-NEXT: { +// CHECK-NEXT: { +// CHECK-NEXT: double _r0 = 0.; +// CHECK-NEXT: _r0 += 1 * constant * clad::custom_derivatives::sin_pushforward(x, 1.).pushforward; +// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += _r0; +// CHECK-NEXT: } +// CHECK-NEXT: _result[0] = _t1; +// CHECK-NEXT: } +// CHECK-NEXT: } double multiply(double x, double y) { return x * y; } //CHECK: void multiply_pullback(double x, double y, double _d_y0, double *_d_x, double *_d_y); @@ -86,75 +110,108 @@ void f_4(double x, double y, double z, double *_result) { } void f_4_jac(double x, double y, double z, double *_result, double *jacobianMatrix); -//CHECK: void f_4_jac(double x, double y, double z, double *_result, double *jacobianMatrix) { -//CHECK-NEXT: double _d_constant = 0.; -//CHECK-NEXT: double constant = 42; -//CHECK-NEXT: double _t0 = multiply(x, y); -//CHECK-NEXT: _result[0] = multiply(x, y) * constant; -//CHECK-NEXT: double _t1 = multiply(y, z); -//CHECK-NEXT: _result[1] = multiply(y, z) * constant; -//CHECK-NEXT: double _t2 = multiply(z, x); -//CHECK-NEXT: _result[2] = multiply(z, x) * constant; -//CHECK-NEXT: { -//CHECK-NEXT: double _r4 = 0.; -//CHECK-NEXT: double _r5 = 0.; -//CHECK-NEXT: multiply_pullback(z, x, 1 * constant, &_r4, &_r5); -//CHECK-NEXT: jacobianMatrix[{{8U|8UL|8ULL}}] += _r4; -//CHECK-NEXT: jacobianMatrix[{{6U|6UL|6ULL}}] += _r5; -//CHECK-NEXT: } -//CHECK-NEXT: { -//CHECK-NEXT: double _r2 = 0.; -//CHECK-NEXT: double _r3 = 0.; -//CHECK-NEXT: multiply_pullback(y, z, 1 * constant, &_r2, &_r3); -//CHECK-NEXT: jacobianMatrix[{{4U|4UL|4ULL}}] += _r2; -//CHECK-NEXT: jacobianMatrix[{{5U|5UL|5ULL}}] += _r3; -//CHECK-NEXT: } -//CHECK-NEXT: { -//CHECK-NEXT: double _r0 = 0.; -//CHECK-NEXT: double _r1 = 0.; -//CHECK-NEXT: multiply_pullback(x, y, 1 * constant, &_r0, &_r1); -//CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += _r0; -//CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += _r1; -//CHECK-NEXT: } -//CHECK-NEXT:} +// CHECK: void f_4_jac(double x, double y, double z, double *_result, double *jacobianMatrix) { +// CHECK-NEXT: double _d_constant = 0.; +// CHECK-NEXT: double constant = 42; +// CHECK-NEXT: double _t0 = multiply(x, y); +// CHECK-NEXT: double _t1 = _result[0]; +// CHECK-NEXT: _result[0] = multiply(x, y) * constant; +// CHECK-NEXT: double _t2 = multiply(y, z); +// CHECK-NEXT: double _t3 = _result[1]; +// CHECK-NEXT: _result[1] = multiply(y, z) * constant; +// CHECK-NEXT: double _t4 = multiply(z, x); +// CHECK-NEXT: double _t5 = _result[2]; +// CHECK-NEXT: _result[2] = multiply(z, x) * constant; +// CHECK-NEXT: { +// CHECK-NEXT: { +// CHECK-NEXT: double _r4 = 0.; +// CHECK-NEXT: double _r5 = 0.; +// CHECK-NEXT: multiply_pullback(z, x, 1 * constant, &_r4, &_r5); +// CHECK-NEXT: jacobianMatrix[{{8U|8UL|8ULL}}] += _r4; +// CHECK-NEXT: jacobianMatrix[{{6U|6UL|6ULL}}] += _r5; +// CHECK-NEXT: } +// CHECK-NEXT: _result[2] = _t5; +// CHECK-NEXT: } +// CHECK-NEXT: { +// CHECK-NEXT: { +// CHECK-NEXT: double _r2 = 0.; +// CHECK-NEXT: double _r3 = 0.; +// CHECK-NEXT: multiply_pullback(y, z, 1 * constant, &_r2, &_r3); +// CHECK-NEXT: jacobianMatrix[{{4U|4UL|4ULL}}] += _r2; +// CHECK-NEXT: jacobianMatrix[{{5U|5UL|5ULL}}] += _r3; +// CHECK-NEXT: } +// CHECK-NEXT: _result[1] = _t3; +// CHECK-NEXT: } +// CHECK-NEXT: { +// CHECK-NEXT: { +// CHECK-NEXT: double _r0 = 0.; +// CHECK-NEXT: double _r1 = 0.; +// CHECK-NEXT: multiply_pullback(x, y, 1 * constant, &_r0, &_r1); +// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += _r0; +// CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += _r1; +// CHECK-NEXT: } +// CHECK-NEXT: _result[0] = _t1; +// CHECK-NEXT: } +// CHECK-NEXT: } void f_1_jac_0(double a, double b, double c, double output[], double *jacobianMatrix); // CHECK: void f_1_jac_0(double a, double b, double c, double output[], double *jacobianMatrix) { -// CHECK-NEXT: double _d_b = 0.; -// CHECK-NEXT: double _d_c = 0.; -// CHECK-NEXT: output[0] = a * a * a; -// CHECK-NEXT: output[1] = a * a * a + b * b * b; -// CHECK-NEXT: output[2] = c * c * 10 - a * a; -// CHECK-NEXT: { -// CHECK-NEXT: jacobianMatrix[{{2U|2UL|2ULL}}] += -1 * a; -// CHECK-NEXT: jacobianMatrix[{{2U|2UL|2ULL}}] += a * -1; -// CHECK-NEXT: } -// CHECK-NEXT: { -// CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += 1 * a * a; -// CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += a * 1 * a; -// CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += a * a * 1; -// CHECK-NEXT: } -// CHECK-NEXT: { -// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += 1 * a * a; -// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += a * 1 * a; -// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += a * a * 1; -// CHECK-NEXT: } -// CHECK-NEXT:} +// CHECK-NEXT: double _d_b = 0.; +// CHECK-NEXT: double _d_c = 0.; +// CHECK-NEXT: double _t0 = output[0]; +// CHECK-NEXT: output[0] = a * a * a; +// CHECK-NEXT: double _t1 = output[1]; +// CHECK-NEXT: output[1] = a * a * a + b * b * b; +// CHECK-NEXT: double _t2 = output[2]; +// CHECK-NEXT: output[2] = c * c * 10 - a * a; +// CHECK-NEXT: { +// CHECK-NEXT: { +// CHECK-NEXT: jacobianMatrix[{{2U|2UL|2ULL}}] += -1 * a; +// CHECK-NEXT: jacobianMatrix[{{2U|2UL|2ULL}}] += a * -1; +// CHECK-NEXT: } +// CHECK-NEXT: output[2] = _t2; +// CHECK-NEXT: } +// CHECK-NEXT: { +// CHECK-NEXT: { +// CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += 1 * a * a; +// CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += a * 1 * a; +// CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += a * a * 1; +// CHECK-NEXT: } +// CHECK-NEXT: output[1] = _t1; +// CHECK-NEXT: } +// CHECK-NEXT: { +// CHECK-NEXT: { +// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += 1 * a * a; +// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += a * 1 * a; +// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += a * a * 1; +// CHECK-NEXT: } +// CHECK-NEXT: output[0] = _t0; +// CHECK-NEXT: } +// CHECK-NEXT: } void f_5(float a, double output[]){ output[1]=a; output[0]=a*a; } -//CHECK: void f_5_jac(float a, double output[], double *jacobianMatrix) { -//CHECK-NEXT: output[1] = a; -//CHECK-NEXT: output[0] = a * a; -//CHECK-NEXT: { -//CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += 1 * a; -//CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += a * 1; -//CHECK-NEXT: } -//CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += 1; -//CHECK-NEXT:} +// CHECK: void f_5_jac(float a, double output[], double *jacobianMatrix) { +// CHECK-NEXT: double _t0 = output[1]; +// CHECK-NEXT: output[1] = a; +// CHECK-NEXT: double _t1 = output[0]; +// CHECK-NEXT: output[0] = a * a; +// CHECK-NEXT: { +// CHECK-NEXT: { +// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += 1 * a; +// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += a * 1; +// CHECK-NEXT: } +// CHECK-NEXT: output[0] = _t1; +// CHECK-NEXT: } +// CHECK-NEXT: { +// CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += 1; +// CHECK-NEXT: output[1] = _t0; +// CHECK-NEXT: } +// CHECK-NEXT: } + #define TEST(F, x, y, z) { \ result[0] = 0; result[1] = 0; result[2] = 0;\ diff --git a/test/Jacobian/Pointers.C b/test/Jacobian/Pointers.C index d4bc2e495..01bdcecc4 100644 --- a/test/Jacobian/Pointers.C +++ b/test/Jacobian/Pointers.C @@ -11,13 +11,20 @@ void nonMemFn(double i, double j, double* out) { } // CHECK: void nonMemFn_jac(double i, double j, double *out, double *jacobianMatrix) { +// CHECK-NEXT: double _t0 = out[0]; // CHECK-NEXT: out[0] = i; +// CHECK-NEXT: double _t1 = out[1]; // CHECK-NEXT: out[1] = j; -// CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += 1; -// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += 1; +// CHECK-NEXT: { +// CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += 1; +// CHECK-NEXT: out[1] = _t1; +// CHECK-NEXT: } +// CHECK-NEXT: { +// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += 1; +// CHECK-NEXT: out[0] = _t0; +// CHECK-NEXT: } // CHECK-NEXT: } - #define NON_MEM_FN_TEST(var)\ res[0]=res[1]=res[2]=res[3]=0;\ var.execute(5, 7, out, res);\ @@ -45,3 +52,4 @@ int main() { NON_MEM_FN_TEST(d_nonMemFnPtrToPtrPar); // CHECK-EXEC: {1.00 0.00 0.00 1.00} } + diff --git a/test/Jacobian/TemplateFunctors.C b/test/Jacobian/TemplateFunctors.C index 0a0a67f52..9762d355e 100644 --- a/test/Jacobian/TemplateFunctors.C +++ b/test/Jacobian/TemplateFunctors.C @@ -16,15 +16,23 @@ template struct Experiment { }; // CHECK: void operator_call_jac(double i, double j, double *output, double *jacobianMatrix) { +// CHECK-NEXT: double _t0 = output[0]; // CHECK-NEXT: output[0] = this->x * this->y * i * j; +// CHECK-NEXT: double _t1 = output[1]; // CHECK-NEXT: output[1] = 2 * this->x * this->y * i * j; // CHECK-NEXT: { -// CHECK-NEXT: jacobianMatrix[{{2U|2UL|2ULL}}] += 2 * this->x * this->y * 1 * j; -// CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += 2 * this->x * this->y * i * 1; +// CHECK-NEXT: { +// CHECK-NEXT: jacobianMatrix[{{2U|2UL|2ULL}}] += 2 * this->x * this->y * 1 * j; +// CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += 2 * this->x * this->y * i * 1; +// CHECK-NEXT: } +// CHECK-NEXT: output[1] = _t1; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += this->x * this->y * 1 * j; -// CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += this->x * this->y * i * 1; +// CHECK-NEXT: { +// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += this->x * this->y * 1 * j; +// CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += this->x * this->y * i * 1; +// CHECK-NEXT: } +// CHECK-NEXT: output[0] = _t0; // CHECK-NEXT: } // CHECK-NEXT: } @@ -39,17 +47,25 @@ template <> struct Experiment { }; // CHECK: void operator_call_jac(long double i, long double j, long double *output, long double *jacobianMatrix) { +// CHECK-NEXT: long double _t0 = output[0]; // CHECK-NEXT: output[0] = this->x * this->y * i * i * j; +// CHECK-NEXT: long double _t1 = output[1]; // CHECK-NEXT: output[1] = 2 * this->x * this->y * i * i * j; // CHECK-NEXT: { -// CHECK-NEXT: jacobianMatrix[{{2U|2UL|2ULL}}] += 2 * this->x * this->y * 1 * j * i; -// CHECK-NEXT: jacobianMatrix[{{2U|2UL|2ULL}}] += 2 * this->x * this->y * i * 1 * j; -// CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += 2 * this->x * this->y * i * i * 1; +// CHECK-NEXT: { +// CHECK-NEXT: jacobianMatrix[{{2U|2UL|2ULL}}] += 2 * this->x * this->y * 1 * j * i; +// CHECK-NEXT: jacobianMatrix[{{2U|2UL|2ULL}}] += 2 * this->x * this->y * i * 1 * j; +// CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += 2 * this->x * this->y * i * i * 1; +// CHECK-NEXT: } +// CHECK-NEXT: output[1] = _t1; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += this->x * this->y * 1 * j * i; -// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += this->x * this->y * i * 1 * j; -// CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += this->x * this->y * i * i * 1; +// CHECK-NEXT: { +// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += this->x * this->y * 1 * j * i; +// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += this->x * this->y * i * 1 * j; +// CHECK-NEXT: jacobianMatrix[{{1U|1UL|1ULL}}] += this->x * this->y * i * i * 1; +// CHECK-NEXT: } +// CHECK-NEXT: output[0] = _t0; // CHECK-NEXT: } // CHECK-NEXT: } @@ -99,3 +115,4 @@ int main() { TEST_DOUBLE(E, 7, 9); // CHECK-EXEC: {225.00, 175.00, 450.00, 350.00} {225.00, 175.00, 450.00, 350.00} TEST_LONG_DOUBLE(E_ld, 7, 9); // CHECK-EXEC: {3150.00, 1225.00, 6300.00, 2450.00} {3150.00, 1225.00, 6300.00, 2450.00} } + diff --git a/test/Jacobian/constexprTest.C b/test/Jacobian/constexprTest.C index fb3f10c9f..1d34cd196 100644 --- a/test/Jacobian/constexprTest.C +++ b/test/Jacobian/constexprTest.C @@ -18,23 +18,36 @@ constexpr void fn_mul(double i, double j, double *res) { res[2] = i*j; } -//CHECK: constexpr void fn_mul_jac(double i, double j, double *res, double *jacobianMatrix) { -//CHECK-NEXT: res[0] = i * i; -//CHECK-NEXT: res[1] = j * j; -//CHECK-NEXT: res[2] = i * j; -//CHECK-NEXT: { -//CHECK-NEXT: jacobianMatrix[{{4U|4UL|4ULL}}] += 1 * j; -//CHECK-NEXT: jacobianMatrix[{{5U|5UL|5ULL}}] += i * 1; -//CHECK-NEXT: } -//CHECK-NEXT: { -//CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += 1 * j; -//CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += j * 1; -//CHECK-NEXT: } -//CHECK-NEXT: { -//CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += 1 * i; -//CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += i * 1; -//CHECK-NEXT: } -//CHECK-NEXT:} +// CHECK: void fn_mul_jac(double i, double j, double *res, double *jacobianMatrix) { +// CHECK-NEXT: double _t0 = res[0]; +// CHECK-NEXT: res[0] = i * i; +// CHECK-NEXT: double _t1 = res[1]; +// CHECK-NEXT: res[1] = j * j; +// CHECK-NEXT: double _t2 = res[2]; +// CHECK-NEXT: res[2] = i * j; +// CHECK-NEXT: { +// CHECK-NEXT: { +// CHECK-NEXT: jacobianMatrix[{{4U|4UL|4ULL}}] += 1 * j; +// CHECK-NEXT: jacobianMatrix[{{5U|5UL|5ULL}}] += i * 1; +// CHECK-NEXT: } +// CHECK-NEXT: res[2] = _t2; +// CHECK-NEXT: } +// CHECK-NEXT: { +// CHECK-NEXT: { +// CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += 1 * j; +// CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += j * 1; +// CHECK-NEXT: } +// CHECK-NEXT: res[1] = _t1; +// CHECK-NEXT: } +// CHECK-NEXT: { +// CHECK-NEXT: { +// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += 1 * i; +// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += i * 1; +// CHECK-NEXT: } +// CHECK-NEXT: res[0] = _t0; +// CHECK-NEXT: } +// CHECK-NEXT: } + constexpr void f_1(double x, double y, double z, double output[]) { output[0] = x * x * x; @@ -42,30 +55,42 @@ constexpr void f_1(double x, double y, double z, double output[]) { output[2] = z * x * 10 - y * z; } -//CHECK: constexpr void f_1_jac(double x, double y, double z, double output[], double *jacobianMatrix) { -//CHECK-NEXT: output[0] = x * x * x; -//CHECK-NEXT: output[1] = x * y * x + y * x * x; -//CHECK-NEXT: output[2] = z * x * 10 - y * z; -//CHECK-NEXT: { -//CHECK-NEXT: jacobianMatrix[{{8U|8UL|8ULL}}] += 1 * 10 * x; -//CHECK-NEXT: jacobianMatrix[{{6U|6UL|6ULL}}] += z * 1 * 10; -//CHECK-NEXT: jacobianMatrix[{{7U|7UL|7ULL}}] += -1 * z; -//CHECK-NEXT: jacobianMatrix[{{8U|8UL|8ULL}}] += y * -1; -//CHECK-NEXT: } -//CHECK-NEXT: { -//CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += 1 * x * y; -//CHECK-NEXT: jacobianMatrix[{{4U|4UL|4ULL}}] += x * 1 * x; -//CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += x * y * 1; -//CHECK-NEXT: jacobianMatrix[{{4U|4UL|4ULL}}] += 1 * x * x; -//CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += y * 1 * x; -//CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += y * x * 1; -//CHECK-NEXT: } -//CHECK-NEXT: { -//CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += 1 * x * x; -//CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += x * 1 * x; -//CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += x * x * 1; -//CHECK-NEXT: } -//CHECK-NEXT:} +// CHECK: constexpr void f_1_jac(double x, double y, double z, double output[], double *jacobianMatrix) { +// CHECK-NEXT: double _t0 = output[0]; +// CHECK-NEXT: output[0] = x * x * x; +// CHECK-NEXT: double _t1 = output[1]; +// CHECK-NEXT: output[1] = x * y * x + y * x * x; +// CHECK-NEXT: double _t2 = output[2]; +// CHECK-NEXT: output[2] = z * x * 10 - y * z; +// CHECK-NEXT: { +// CHECK-NEXT: { +// CHECK-NEXT: jacobianMatrix[{{8U|8UL|8ULL}}] += 1 * 10 * x; +// CHECK-NEXT: jacobianMatrix[{{6U|6UL|6ULL}}] += z * 1 * 10; +// CHECK-NEXT: jacobianMatrix[{{7U|7UL|7ULL}}] += -1 * z; +// CHECK-NEXT: jacobianMatrix[{{8U|8UL|8ULL}}] += y * -1; +// CHECK-NEXT: } +// CHECK-NEXT: output[2] = _t2; +// CHECK-NEXT: } +// CHECK-NEXT: { +// CHECK-NEXT: { +// CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += 1 * x * y; +// CHECK-NEXT: jacobianMatrix[{{4U|4UL|4ULL}}] += x * 1 * x; +// CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += x * y * 1; +// CHECK-NEXT: jacobianMatrix[{{4U|4UL|4ULL}}] += 1 * x * x; +// CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += y * 1 * x; +// CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += y * x * 1; +// CHECK-NEXT: } +// CHECK-NEXT: output[1] = _t1; +// CHECK-NEXT: } +// CHECK-NEXT: { +// CHECK-NEXT: { +// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += 1 * x * x; +// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += x * 1 * x; +// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += x * x * 1; +// CHECK-NEXT: } +// CHECK-NEXT: output[0] = _t0; +// CHECK-NEXT: } +// CHECK-NEXT: } int main() { @@ -75,3 +100,4 @@ int main() { 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} } + diff --git a/test/Jacobian/testUtility.C b/test/Jacobian/testUtility.C index e9f2ed4d6..7b38eb7ec 100644 --- a/test/Jacobian/testUtility.C +++ b/test/Jacobian/testUtility.C @@ -18,23 +18,36 @@ void fn_mul(double i, double j, double *res) { res[2] = i*j; } -//CHECK: void fn_mul_jac(double i, double j, double *res, double *jacobianMatrix) { -//CHECK-NEXT: res[0] = i * i; -//CHECK-NEXT: res[1] = j * j; -//CHECK-NEXT: res[2] = i * j; -//CHECK-NEXT: { -//CHECK-NEXT: jacobianMatrix[{{4U|4UL|4ULL}}] += 1 * j; -//CHECK-NEXT: jacobianMatrix[{{5U|5UL|5ULL}}] += i * 1; -//CHECK-NEXT: } -//CHECK-NEXT: { -//CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += 1 * j; -//CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += j * 1; -//CHECK-NEXT: } -//CHECK-NEXT: { -//CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += 1 * i; -//CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += i * 1; -//CHECK-NEXT: } -//CHECK-NEXT:} +// CHECK: void fn_mul_jac(double i, double j, double *res, double *jacobianMatrix) { +// CHECK-NEXT: double _t0 = res[0]; +// CHECK-NEXT: res[0] = i * i; +// CHECK-NEXT: double _t1 = res[1]; +// CHECK-NEXT: res[1] = j * j; +// CHECK-NEXT: double _t2 = res[2]; +// CHECK-NEXT: res[2] = i * j; +// CHECK-NEXT: { +// CHECK-NEXT: { +// CHECK-NEXT: jacobianMatrix[{{4U|4UL|4ULL}}] += 1 * j; +// CHECK-NEXT: jacobianMatrix[{{5U|5UL|5ULL}}] += i * 1; +// CHECK-NEXT: } +// CHECK-NEXT: res[2] = _t2; +// CHECK-NEXT: } +// CHECK-NEXT: { +// CHECK-NEXT: { +// CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += 1 * j; +// CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += j * 1; +// CHECK-NEXT: } +// CHECK-NEXT: res[1] = _t1; +// CHECK-NEXT: } +// CHECK-NEXT: { +// CHECK-NEXT: { +// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += 1 * i; +// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += i * 1; +// CHECK-NEXT: } +// CHECK-NEXT: res[0] = _t0; +// CHECK-NEXT: } +// CHECK-NEXT: } + void f_1(double x, double y, double z, double output[]) { @@ -43,30 +56,43 @@ void f_1(double x, double y, double z, double output[]) { output[2] = z * x * 10 - y * z; } -//CHECK: void f_1_jac(double x, double y, double z, double output[], double *jacobianMatrix) { -//CHECK-NEXT: output[0] = x * x * x; -//CHECK-NEXT: output[1] = x * y * x + y * x * x; -//CHECK-NEXT: output[2] = z * x * 10 - y * z; -//CHECK-NEXT: { -//CHECK-NEXT: jacobianMatrix[{{8U|8UL|8ULL}}] += 1 * 10 * x; -//CHECK-NEXT: jacobianMatrix[{{6U|6UL|6ULL}}] += z * 1 * 10; -//CHECK-NEXT: jacobianMatrix[{{7U|7UL|7ULL}}] += -1 * z; -//CHECK-NEXT: jacobianMatrix[{{8U|8UL|8ULL}}] += y * -1; -//CHECK-NEXT: } -//CHECK-NEXT: { -//CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += 1 * x * y; -//CHECK-NEXT: jacobianMatrix[{{4U|4UL|4ULL}}] += x * 1 * x; -//CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += x * y * 1; -//CHECK-NEXT: jacobianMatrix[{{4U|4UL|4ULL}}] += 1 * x * x; -//CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += y * 1 * x; -//CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += y * x * 1; -//CHECK-NEXT: } -//CHECK-NEXT: { -//CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += 1 * x * x; -//CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += x * 1 * x; -//CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += x * x * 1; -//CHECK-NEXT: } -//CHECK-NEXT:} +// CHECK: void f_1_jac(double x, double y, double z, double output[], double *jacobianMatrix) { +// CHECK-NEXT: double _t0 = output[0]; +// CHECK-NEXT: output[0] = x * x * x; +// CHECK-NEXT: double _t1 = output[1]; +// CHECK-NEXT: output[1] = x * y * x + y * x * x; +// CHECK-NEXT: double _t2 = output[2]; +// CHECK-NEXT: output[2] = z * x * 10 - y * z; +// CHECK-NEXT: { +// CHECK-NEXT: { +// CHECK-NEXT: jacobianMatrix[{{8U|8UL|8ULL}}] += 1 * 10 * x; +// CHECK-NEXT: jacobianMatrix[{{6U|6UL|6ULL}}] += z * 1 * 10; +// CHECK-NEXT: jacobianMatrix[{{7U|7UL|7ULL}}] += -1 * z; +// CHECK-NEXT: jacobianMatrix[{{8U|8UL|8ULL}}] += y * -1; +// CHECK-NEXT: } +// CHECK-NEXT: output[2] = _t2; +// CHECK-NEXT: } +// CHECK-NEXT: { +// CHECK-NEXT: { +// CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += 1 * x * y; +// CHECK-NEXT: jacobianMatrix[{{4U|4UL|4ULL}}] += x * 1 * x; +// CHECK-NEXT: jacobianMatrix[{{3U|3UL|3ULL}}] += x * y * 1; +// CHECK-NEXT: jacobianMatrix[{{4U|4UL|4ULL}}] += 1 * x * x; +// CHECK-NEXT: jacobianMatrix[{{3U|3UL|3OLL}}] += y * 1 * x; +// CHECK-NEXT: jacobianMatrix[{{3U|3UL|3OLL}}] += y * x * 1; +// CHECK-NEXT: } +// CHECK-NEXT: output[1] = _t1; +// CHECK-NEXT: } +// CHECK-NEXT: { +// CHECK-NEXT: { +// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += 1 * x * x; +// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += x * 1 * x; +// CHECK-NEXT: jacobianMatrix[{{0U|0UL|0ULL}}] += x * x * 1; +// CHECK-NEXT: } +// CHECK-NEXT: output[0] = _t0; +// CHECK-NEXT: } +// CHECK-NEXT: } + int main(){ INIT_JACOBIAN(fn_mul); @@ -76,4 +102,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} } - From c0c782c3c84acf9d0903075bbb42f1b82b876d06 Mon Sep 17 00:00:00 2001 From: Atell Krasnopolski Date: Sun, 15 Sep 2024 20:34:52 +0200 Subject: [PATCH 09/14] Add basic support for `std::tie` and tuples in the fwd mode --- .../clad/Differentiator/BuiltinDerivatives.h | 5 ++ include/clad/Differentiator/STLBuiltins.h | 81 +++++++++++++++++++ test/ForwardMode/STLCustomDerivatives.C | 32 +++++++- test/ForwardMode/UserDefinedTypes.C | 2 +- 4 files changed, 118 insertions(+), 2 deletions(-) diff --git a/include/clad/Differentiator/BuiltinDerivatives.h b/include/clad/Differentiator/BuiltinDerivatives.h index a31b239bb..3f9dcae67 100644 --- a/include/clad/Differentiator/BuiltinDerivatives.h +++ b/include/clad/Differentiator/BuiltinDerivatives.h @@ -30,6 +30,11 @@ template struct ValueAndPushforward { } }; +template +ValueAndPushforward make_value_and_pushforward(T value, U pushforward) { + return {value, pushforward}; +} + template struct ValueAndAdjoint { T value; U adjoint; diff --git a/include/clad/Differentiator/STLBuiltins.h b/include/clad/Differentiator/STLBuiltins.h index 9f3cb42c0..11192b16d 100644 --- a/include/clad/Differentiator/STLBuiltins.h +++ b/include/clad/Differentiator/STLBuiltins.h @@ -1,8 +1,11 @@ #ifndef CLAD_STL_BUILTINS_H #define CLAD_STL_BUILTINS_H +#include #include +#include #include +#include #include namespace clad { @@ -338,7 +341,85 @@ void constructor_pullback(::std::array* a, const ::std::array& arr, (*d_arr)[i] += (*d_a)[i]; } +template +clad::ValueAndPushforward<::std::tuple, ::std::tuple> +operator_equal_pushforward(::std::tuple* tu, + ::std::tuple&& in, + ::std::tuple* d_tu, + ::std::tuple&& d_in) noexcept { + ::std::tuple t1 = (*tu = in); + ::std::tuple t2 = (*d_tu = d_in); + return {t1, t2}; +} + } // namespace class_functions + +namespace std { + +// Helper functions for selecting subtuples +template <::std::size_t shift_amount, ::std::size_t... Is> +constexpr auto shift_sequence(IndexSequence) { + return IndexSequence{}; +} + +template +auto select_tuple_elements(const Tuple& tpl, IndexSequence) { + return ::std::make_tuple(::std::get(tpl)...); +} + +template auto first_half_tuple(const Tuple& tpl) { + // static_assert(::std::tuple_size::value % 2 == 0); + constexpr ::std::size_t half = ::std::tuple_size::value / 2; + + constexpr MakeIndexSequence first_half; + return select_tuple_elements(tpl, first_half); +} + +template auto second_half_tuple(const Tuple& tpl) { + // static_assert(::std::tuple_size::value % 2 == 0); + constexpr ::std::size_t half = ::std::tuple_size::value / 2; + + constexpr MakeIndexSequence first_half; + constexpr auto second_half = shift_sequence(first_half); + return select_tuple_elements(tpl, second_half); +} + +template +auto select_tuple_elements_tie(const Tuple& tpl, IndexSequence) { + return ::std::tie(::std::get(tpl)...); +} + +template auto first_half_tuple_tie(const Tuple& tpl) { + // static_assert(::std::tuple_size::value % 2 == 0); + constexpr ::std::size_t half = ::std::tuple_size::value / 2; + + constexpr MakeIndexSequence first_half; + return select_tuple_elements_tie(tpl, first_half); +} + +template auto second_half_tuple_tie(const Tuple& tpl) { + // static_assert(::std::tuple_size::value % 2 == 0); + constexpr ::std::size_t half = ::std::tuple_size::value / 2; + + constexpr MakeIndexSequence first_half; + constexpr auto second_half = shift_sequence(first_half); + return select_tuple_elements_tie(tpl, second_half); +} + +template auto tie_pushforward(Args&&... args) noexcept { + ::std::tuple t = ::std::tie(args...); + return clad::make_value_and_pushforward(first_half_tuple_tie(t), + second_half_tuple_tie(t)); +} + +template auto make_tuple_pushforward(Args... args) noexcept { + ::std::tuple t = ::std::make_tuple(args...); + return clad::make_value_and_pushforward(first_half_tuple(t), + second_half_tuple(t)); +} + +} // namespace std + } // namespace custom_derivatives } // namespace clad diff --git a/test/ForwardMode/STLCustomDerivatives.C b/test/ForwardMode/STLCustomDerivatives.C index cfb1f7813..7d441fa0f 100644 --- a/test/ForwardMode/STLCustomDerivatives.C +++ b/test/ForwardMode/STLCustomDerivatives.C @@ -1,4 +1,4 @@ -// RUN: %cladclang %s -std=c++14 -I%S/../../include -oSTLCustomDerivatives.out | %filecheck %s +// RUN: %cladclang -std=c++14 %s -I%S/../../include -oSTLCustomDerivatives.out | %filecheck %s // RUN: ./STLCustomDerivatives.out | %filecheck_exec %s #include "clad/Differentiator/Differentiator.h" @@ -7,6 +7,7 @@ #include #include #include +#include #include "../TestUtils.h" #include "../PrintOverloads.h" @@ -181,6 +182,33 @@ double fnArr2(double x) { //CHECK-NEXT: return (_t0.pushforward * _t3 + _t2 * _t1.pushforward) * _t6 + _t5 * _t4.pushforward; //CHECK-NEXT: } +auto pack(double x) { + return std::make_tuple(x, 2*x, 3*x); +} + +double fnTuple1(double x, double y) { + double u, v = 288*x, w; + + std::tie(u, v, w) = pack(x+y); + + return v; +} // = 2x + 2y + +//CHECK: double fnTuple1_darg0(double x, double y) { +//CHECK-NEXT: double _d_x = 1; +//CHECK-NEXT: double _d_y = 0; +//CHECK-NEXT: double _d_u, _d_v = 0 * x + 288 * _d_x, _d_w; +//CHECK-NEXT: double u, v = 288 * x, w; +//CHECK-NEXT: clad::ValueAndPushforward, tuple > _t0 = clad::custom_derivatives::std::tie_pushforward(u, v, w, _d_u, _d_v, _d_w); +//CHECK-NEXT: clad::ValueAndPushforward<{{.*}}> _t1 = pack_pushforward(x + y, _d_x + _d_y); +//CHECK-NEXT: clad::ValueAndPushforward<{{.*}}> _t2 = clad::custom_derivatives::class_functions::operator_equal_pushforward(&_t0.value, static_cast &&>(_t1.value), &_t0.pushforward, static_cast &&>(_t1.pushforward)); +//CHECK-NEXT: return _d_v; +//CHECK-NEXT: } +//CHECK: clad::ValueAndPushforward<{{.*}}> pack_pushforward({{.*}}) { +//CHECK-NEXT: clad::ValueAndPushforward, tuple > _t0 = clad::custom_derivatives::std::make_tuple_pushforward(x, 2 * x, 3 * x, _d_x, 0 * x + 2 * _d_x, 0 * x + 3 * _d_x); +//CHECK-NEXT: return {_t0.value, _t0.pushforward}; +//CHECK-NEXT: } + int main() { INIT_DIFFERENTIATE(fnVec1, "u"); INIT_DIFFERENTIATE(fnVec2, "u"); @@ -188,6 +216,7 @@ int main() { INIT_DIFFERENTIATE(fnVec4, "u"); INIT_DIFFERENTIATE(fnArr1, "x"); INIT_DIFFERENTIATE(fnArr2, "x"); + INIT_DIFFERENTIATE(fnTuple1, "x"); TEST_DIFFERENTIATE(fnVec1, 3, 5); // CHECK-EXEC: {10.00} TEST_DIFFERENTIATE(fnVec2, 3, 5); // CHECK-EXEC: {5.00} @@ -195,4 +224,5 @@ int main() { TEST_DIFFERENTIATE(fnVec4, 3, 5); // CHECK-EXEC: {30.00} TEST_DIFFERENTIATE(fnArr1, 3); // CHECK-EXEC: {3.00} TEST_DIFFERENTIATE(fnArr2, 3); // CHECK-EXEC: {108.00} + TEST_DIFFERENTIATE(fnTuple1, 3, 4); // CHECK-EXEC: {2.00} } diff --git a/test/ForwardMode/UserDefinedTypes.C b/test/ForwardMode/UserDefinedTypes.C index e0fca6587..922270c96 100644 --- a/test/ForwardMode/UserDefinedTypes.C +++ b/test/ForwardMode/UserDefinedTypes.C @@ -1,4 +1,4 @@ -// RUN: %cladclang %s -I%S/../../include -oUserDefinedTypes.out | %filecheck %s +// RUN: %cladclang -std=c++14 %s -I%S/../../include -oUserDefinedTypes.out | %filecheck %s // RUN: ./UserDefinedTypes.out | %filecheck_exec %s // XFAIL: asserts From 514d43440825ad5c7a8afc1bdddec3ed5ea18a63 Mon Sep 17 00:00:00 2001 From: Atell Krasnopolski Date: Tue, 17 Sep 2024 19:21:25 +0200 Subject: [PATCH 10/14] Enhance the support of `std::vector` and `std::array` in the fwd mode --- include/clad/Differentiator/STLBuiltins.h | 199 ++++++++++++++++++++- test/ForwardMode/STLCustomDerivatives.C | 201 ++++++++++++++++++++++ test/ForwardMode/UserDefinedTypes.C | 2 - 3 files changed, 397 insertions(+), 5 deletions(-) diff --git a/include/clad/Differentiator/STLBuiltins.h b/include/clad/Differentiator/STLBuiltins.h index 11192b16d..fc240d11e 100644 --- a/include/clad/Differentiator/STLBuiltins.h +++ b/include/clad/Differentiator/STLBuiltins.h @@ -12,6 +12,8 @@ namespace clad { namespace custom_derivatives { namespace class_functions { +// vector forward mode + template void clear_pushforward(::std::vector* v, ::std::vector* d_v) { d_v->clear(); @@ -131,6 +133,181 @@ operator_subscript_pushforward(const ::std::vector* v, unsigned idx, return {(*v)[idx], (*d_v)[idx]}; } +template +ValueAndPushforward at_pushforward(::std::vector* v, unsigned idx, + ::std::vector* d_v, + unsigned d_idx) { + return {(*v)[idx], (*d_v)[idx]}; +} + +template +ValueAndPushforward +at_pushforward(const ::std::vector* v, unsigned idx, + const ::std::vector* d_v, unsigned d_idx) { + return {(*v)[idx], (*d_v)[idx]}; +} + +template +clad::ValueAndPushforward<::std::vector&, ::std::vector&> +operator_equal_pushforward(::std::vector* a, const ::std::vector& param, + ::std::vector* d_a, + const ::std::vector& d_param) noexcept { + (*a) = param; + (*d_a) = d_param; + return {*a, *d_a}; +} + +template +inline clad::ValueAndPushforward +front_pushforward(const ::std::vector* a, + const ::std::vector* d_a) noexcept { + return {a->front(), d_a->front()}; +} + +template +inline clad::ValueAndPushforward +front_pushforward(::std::vector* a, ::std::vector* d_a) noexcept { + return {a->front(), d_a->front()}; +} + +template +inline clad::ValueAndPushforward +back_pushforward(const ::std::vector* a, + const ::std::vector* d_a) noexcept { + return {a->back(), d_a->back()}; +} + +template +inline clad::ValueAndPushforward +back_pushforward(::std::vector* a, ::std::vector* d_a) noexcept { + return {a->back(), d_a->back()}; +} + +template +ValueAndPushforward::iterator, + typename ::std::vector::iterator> +begin_pushforward(::std::vector* v, ::std::vector* d_v) { + return {v->begin(), d_v->begin()}; +} + +template +ValueAndPushforward::iterator, + typename ::std::vector::iterator> +end_pushforward(::std::vector* v, ::std::vector* d_v) { + return {v->end(), d_v->end()}; +} + +template +ValueAndPushforward::iterator, + typename ::std::vector::iterator> +erase_pushforward(::std::vector* v, + typename ::std::vector::const_iterator pos, + ::std::vector* d_v, + typename ::std::vector::const_iterator d_pos) { + return {v->erase(pos), d_v->erase(d_pos)}; +} + +template +ValueAndPushforward::iterator, + typename ::std::vector::iterator> +insert_pushforward(::std::vector* v, + typename ::std::vector::const_iterator pos, U u, + ::std::vector* d_v, + typename ::std::vector::const_iterator d_pos, U d_u) { + return {v->insert(pos, u), d_v->insert(d_pos, d_u)}; +} + +template +ValueAndPushforward::iterator, + typename ::std::vector::iterator> +insert_pushforward(::std::vector* v, + typename ::std::vector::const_iterator pos, + ::std::initializer_list list, ::std::vector* d_v, + typename ::std::vector::const_iterator d_pos, + ::std::initializer_list d_list) { + return {v->insert(pos, list), d_v->insert(d_pos, d_list)}; +} + +template +ValueAndPushforward::iterator, + typename ::std::vector::iterator> +insert_pushforward(::std::vector* v, + typename ::std::vector::const_iterator pos, U first, + U last, ::std::vector* d_v, + typename ::std::vector::const_iterator d_pos, U d_first, + U d_last) { + return {v->insert(pos, first, last), d_v->insert(d_pos, d_first, d_last)}; +} + +template +void assign_pushforward(::std::vector* v, + typename ::std::vector::size_type n, const U& val, + ::std::vector* d_v, + typename ::std::vector::size_type /*d_n*/, + const U& d_val) { + v->assign(n, val); + d_v->assign(n, d_val); +} + +template +void assign_pushforward(::std::vector* v, U first, U last, + ::std::vector* d_v, U d_first, U d_last) { + v->assign(first, last); + d_v->assign(d_first, d_last); +} + +template +void assign_pushforward(::std::vector* v, ::std::initializer_list list, + ::std::vector* d_v, + ::std::initializer_list d_list) { + v->assign(list); + d_v->assign(d_list); +} + +template +void reserve_pushforward(::std::vector* v, + typename ::std::vector::size_type n, + ::std::vector* d_v, + typename ::std::vector::size_type /*d_n*/) { + v->reserve(n); + d_v->reserve(n); +} + +template +void shrink_to_fit_pushforward(::std::vector* v, ::std::vector* d_v) { + v->shrink_to_fit(); + d_v->shrink_to_fit(); +} + +template +void push_back_pushforward(::std::vector* v, U val, ::std::vector* d_v, + U d_val) { + v->push_back(val); + d_v->push_back(d_val); +} + +template +void pop_back_pushforward(::std::vector* v, ::std::vector* d_v) noexcept { + v->pop_back(); + d_v->pop_back(); +} + +template +clad::ValueAndPushforward<::std::size_t, ::std::size_t> +size_pushforward(const ::std::vector* v, + const ::std::vector* d_v) noexcept { + return {v->size(), 0}; +} + +template +clad::ValueAndPushforward<::std::size_t, ::std::size_t> +capacity_pushforward(const ::std::vector* v, + const ::std::vector* d_v) noexcept { + return {v->capacity(), 0}; +} + +// array forward mode + template constexpr clad::ValueAndPushforward operator_subscript_pushforward(::std::array* a, ::std::size_t i, @@ -198,13 +375,23 @@ back_pushforward(::std::array* a, ::std::array* d_a) noexcept { return {a->back(), d_a->back()}; } -template -void fill_pushforward(::std::array* a, const T& u, - ::std::array* d_a, const T& d_u) { +template +void fill_pushforward(::std::array* a, const U& u, + ::std::array* d_a, const U& d_u) { a->fill(u); d_a->fill(d_u); } +template +clad::ValueAndPushforward<::std::size_t, ::std::size_t> +size_pushforward(const ::std::array* a, + const ::std::array* d_a) noexcept { + return {a->size(), 0}; +} + +// vector reverse mode +// more can be found in tests: test/Gradient/STLCustomDerivatives.C + template void push_back_reverse_forw(::std::vector* v, U val, ::std::vector* d_v, U d_val) { @@ -256,6 +443,8 @@ void constructor_pullback(::std::vector* v, S count, U val, d_v->clear(); } +// array reverse mode + template clad::ValueAndAdjoint operator_subscript_reverse_forw( ::std::array* arr, typename ::std::array::size_type idx, @@ -341,6 +530,8 @@ void constructor_pullback(::std::array* a, const ::std::array& arr, (*d_arr)[i] += (*d_a)[i]; } +// tuple forward mode + template clad::ValueAndPushforward<::std::tuple, ::std::tuple> operator_equal_pushforward(::std::tuple* tu, @@ -356,6 +547,8 @@ operator_equal_pushforward(::std::tuple* tu, namespace std { +// tie and maketuple forward mode + // Helper functions for selecting subtuples template <::std::size_t shift_amount, ::std::size_t... Is> constexpr auto shift_sequence(IndexSequence) { diff --git a/test/ForwardMode/STLCustomDerivatives.C b/test/ForwardMode/STLCustomDerivatives.C index 7d441fa0f..7ee45affa 100644 --- a/test/ForwardMode/STLCustomDerivatives.C +++ b/test/ForwardMode/STLCustomDerivatives.C @@ -116,6 +116,201 @@ double fnVec4(double u, double v) { // CHECK-NEXT: return _t1.pushforward * _t4 + _t3 * _t2.pushforward; // CHECK-NEXT: } +double fnVec5(double x, double y) { + std::vector v; + + v.reserve(10); + + double res = x*v.capacity(); + + v.push_back(x); + v.shrink_to_fit(); + res += x*v.capacity(); + + return res; // 11x +} + +// CHECK: double fnVec5_darg0(double x, double y) { +// CHECK-NEXT: double _d_x = 1; +// CHECK-NEXT: double _d_y = 0; +// CHECK-NEXT: std::vector _d_v; +// CHECK-NEXT: std::vector v; +// CHECK-NEXT: {{.*}}reserve_pushforward(&v, 10, &_d_v, 0); +// CHECK-NEXT: {{.*}}ValueAndPushforward< ::std::size_t, ::std::size_t> _t0 = {{.*}}capacity_pushforward(&v, &_d_v); +// CHECK-NEXT: {{.*}} &_t1 = _t0.value; +// CHECK-NEXT: double _d_res = _d_x * _t1 + x * _t0.pushforward; +// CHECK-NEXT: double res = x * _t1; +// CHECK-NEXT: {{.*}}push_back_pushforward(&v, x, &_d_v, _d_x); +// CHECK-NEXT: {{.*}}shrink_to_fit_pushforward(&v, &_d_v); +// CHECK-NEXT: {{.*}}ValueAndPushforward< ::std::size_t, ::std::size_t> _t2 = {{.*}}capacity_pushforward(&v, &_d_v); +// CHECK-NEXT: {{.*}} &_t3 = _t2.value; +// CHECK-NEXT: _d_res += _d_x * _t3 + x * _t2.pushforward; +// CHECK-NEXT: res += x * _t3; +// CHECK-NEXT: return _d_res; +// CHECK-NEXT: } + +double fnVec6(double x, double y) { + std::vector v(3, y); + + v.pop_back(); + double res = v.size()*x; // res = 2x + + v.erase(v.begin()); + res += v.size()*x; // res = 3x + + std::vector w; + w = v; + w.clear(); + res += w.size()*x + v.size()*x; // res = 4x + + w.insert(w.end(), 5); + res += w.size()*x; // res = 5x + + w.insert(w.end(), {y, x, y}); + w.insert(w.end(), v.begin(), v.end()); + if (w[0] == 5 && w[1] == y && w[2] == x && w[3] == y && v.back() == w.back()) { // should always be true + res += w[2]; // res = 6x + } + + w.assign(2, y); + res += (w[0] == y && w[1] == y)*x; // res = 7x + + v[0] = x; + w.assign(v.begin(), v.end()); + res += w[0]; // res = 8x; + + w.assign({3*x, 2*x, 4*x}); + res += w[1]; // res = 10x; + + return res; // 10x +} + +// CHECK: double fnVec6_darg0(double x, double y) { +// CHECK-NEXT: double _d_x = 1; +// CHECK-NEXT: double _d_y = 0; +// CHECK-NEXT: {{.*}}ValueAndPushforward< ::std::vector, ::std::vector > _t0 = {{.*}}constructor_pushforward(clad::ConstructorPushforwardTag >(), 3, y{{.*}}, 0, _d_y{{.*}}); +// CHECK-NEXT: std::vector _d_v(_t0.pushforward); +// CHECK-NEXT: std::vector v(_t0.value); +// CHECK-NEXT: {{.*}}pop_back_pushforward(&v, &_d_v); +// CHECK-NEXT: {{.*}}ValueAndPushforward< ::std::size_t, ::std::size_t> _t1 = {{.*}}size_pushforward(&v, &_d_v); +// CHECK-NEXT: {{.*}} &_t2 = _t1.value; +// CHECK-NEXT: double _d_res = _t1.pushforward * x + _t2 * _d_x; +// CHECK-NEXT: double res = _t2 * x; +// CHECK-NEXT: {{.*}}ValueAndPushforward<{{.*}}> _t3 = {{.*}}begin_pushforward(&v, &_d_v); +// CHECK-NEXT: {{.*}}ValueAndPushforward<{{.*}}> _t4 = {{.*}}erase_pushforward(&v, {{.*}}_t3.value{{.*}}, &_d_v, {{.*}}_t3.pushforward{{.*}}); +// CHECK-NEXT: {{.*}}ValueAndPushforward< ::std::size_t, ::std::size_t> _t5 = {{.*}}size_pushforward(&v, &_d_v); +// CHECK-NEXT: {{.*}} &_t6 = _t5.value; +// CHECK-NEXT: _d_res += _t5.pushforward * x + _t6 * _d_x; +// CHECK-NEXT: res += _t6 * x; +// CHECK-NEXT: std::vector _d_w; +// CHECK-NEXT: std::vector w; +// CHECK-NEXT: {{.*}}ValueAndPushforward< ::std::vector &, ::std::vector &> _t7 = {{.*}}operator_equal_pushforward(&w, v, &_d_w, _d_v); +// CHECK-NEXT: {{.*}}clear_pushforward(&w, &_d_w); +// CHECK-NEXT: {{.*}}ValueAndPushforward< ::std::size_t, ::std::size_t> _t8 = {{.*}}size_pushforward(&w, &_d_w); +// CHECK-NEXT: {{.*}} &_t9 = _t8.value; +// CHECK-NEXT: {{.*}}ValueAndPushforward< ::std::size_t, ::std::size_t> _t10 = {{.*}}size_pushforward(&v, &_d_v); +// CHECK-NEXT: {{.*}} &_t11 = _t10.value; +// CHECK-NEXT: _d_res += _t8.pushforward * x + _t9 * _d_x + _t10.pushforward * x + _t11 * _d_x; +// CHECK-NEXT: res += _t9 * x + _t11 * x; +// CHECK-NEXT: {{.*}}ValueAndPushforward<{{.*}}> _t12 = {{.*}}end_pushforward(&w, &_d_w); +// CHECK-NEXT: {{.*}}ValueAndPushforward<{{.*}}> _t13 = {{.*}}insert_pushforward(&w, {{.*}}_t12.value{{.*}}, 5, &_d_w, {{.*}}_t12.pushforward{{.*}}, 0); +// CHECK-NEXT: {{.*}}ValueAndPushforward< ::std::size_t, ::std::size_t> _t14 = {{.*}}size_pushforward(&w, &_d_w); +// CHECK-NEXT: {{.*}} &_t15 = _t14.value; +// CHECK-NEXT: _d_res += _t14.pushforward * x + _t15 * _d_x; +// CHECK-NEXT: res += _t15 * x; +// CHECK-NEXT: {{.*}}ValueAndPushforward<{{.*}}> _t16 = {{.*}}end_pushforward(&w, &_d_w); +// CHECK-NEXT: {{.*}}ValueAndPushforward<{{.*}}> _t17 = {{.*}}insert_pushforward(&w, {{.*}}_t16.value{{.*}}, {y, x, y}, &_d_w, {{.*}}_t16.pushforward{{.*}}, {_d_y, _d_x, _d_y}); +// CHECK-NEXT: {{.*}}ValueAndPushforward<{{.*}}> _t18 = {{.*}}end_pushforward(&w, &_d_w); +// CHECK-NEXT: {{.*}}ValueAndPushforward<{{.*}}> _t19 = {{.*}}begin_pushforward(&v, &_d_v); +// CHECK-NEXT: {{.*}}ValueAndPushforward<{{.*}}> _t20 = {{.*}}end_pushforward(&v, &_d_v); +// CHECK-NEXT: {{.*}}ValueAndPushforward<{{.*}}> _t21 = {{.*}}insert_pushforward(&w, {{.*}}_t18.value{{.*}}, {{.*}}_t19.value{{.*}}, {{.*}}_t20.value{{.*}}, &_d_w, {{.*}}_t18.pushforward{{.*}}, {{.*}}_t19.pushforward{{.*}}, {{.*}}_t20.pushforward{{.*}}); +// CHECK-NEXT: if (w[0] == 5 && w[1] == y && w[2] == x && w[3] == y && v.back() == w.back()) { +// CHECK-NEXT: {{.*}}ValueAndPushforward<{{.*}}> _t22 = {{.*}}operator_subscript_pushforward(&w, 2, &_d_w, 0); +// CHECK-NEXT: _d_res += _t22.pushforward; +// CHECK-NEXT: res += _t22.value; +// CHECK-NEXT: } +// CHECK-NEXT: {{.*}}assign_pushforward(&w, 2, y, &_d_w, 0, _d_y); +// CHECK-NEXT: {{.*}}ValueAndPushforward<{{.*}}> _t23 = {{.*}}operator_subscript_pushforward(&w, 0, &_d_w, 0); +// CHECK-NEXT: {{.*}}ValueAndPushforward<{{.*}}> _t24 = {{.*}}operator_subscript_pushforward(&w, 1, &_d_w, 0); +// CHECK-NEXT: bool _t25 = ((_t23.value == y) && (_t24.value == y)); +// CHECK-NEXT: _d_res += false * x + _t25 * _d_x; +// CHECK-NEXT: res += _t25 * x; +// CHECK-NEXT: {{.*}}ValueAndPushforward<{{.*}}> _t26 = {{.*}}operator_subscript_pushforward(&v, 0, &_d_v, 0); +// CHECK-NEXT: _t26.pushforward = _d_x; +// CHECK-NEXT: _t26.value = x; +// CHECK-NEXT: {{.*}}ValueAndPushforward<{{.*}}> _t27 = {{.*}}begin_pushforward(&v, &_d_v); +// CHECK-NEXT: {{.*}}ValueAndPushforward<{{.*}}> _t28 = {{.*}}end_pushforward(&v, &_d_v); +// CHECK-NEXT: {{.*}}assign_pushforward(&w, {{.*}}_t27.value{{.*}}, {{.*}}_t28.value{{.*}}, &_d_w, {{.*}}_t27.pushforward{{.*}}, {{.*}}_t28.pushforward{{.*}}); +// CHECK-NEXT: {{.*}}ValueAndPushforward<{{.*}}> _t29 = {{.*}}operator_subscript_pushforward(&w, 0, &_d_w, 0); +// CHECK-NEXT: _d_res += _t29.pushforward; +// CHECK-NEXT: res += _t29.value; +// CHECK-NEXT: {{.*}}assign_pushforward(&w, {3 * x, 2 * x, 4 * x}, &_d_w, {0 * x + 3 * _d_x, 0 * x + 2 * _d_x, 0 * x + 4 * _d_x}); +// CHECK-NEXT: {{.*}}ValueAndPushforward<{{.*}}> _t30 = {{.*}}operator_subscript_pushforward(&w, 1, &_d_w, 0); +// CHECK-NEXT: _d_res += _t30.pushforward; +// CHECK-NEXT: res += _t30.value; +// CHECK-NEXT: return _d_res; +// CHECK-NEXT: } + +double fnVec7(double x, double y) { + std::vector v; + for (size_t i = 0; i < 3; ++i) { + float fx = x; + v.push_back(fx); + } + double res = 0; + for (size_t i = 0; i < v.size(); ++i) { + v[i] = i * v.at(i); + res += v.at(i); + } + + const std::vector v2 = v; + + // result is the same as res, that is: 3x + return res + v.front() + v.back() - v[v.size()-1] + v2.at(0) + v2.front() + v2.back() - v2[v2.size()-1]; +} + +// CHECK: double fnVec7_darg0(double x, double y) { +// CHECK-NEXT: double _d_x = 1; +// CHECK-NEXT: double _d_y = 0; +// CHECK-NEXT: std::vector _d_v; +// CHECK-NEXT: std::vector v; +// CHECK-NEXT: { +// CHECK-NEXT: size_t _d_i = 0; +// CHECK-NEXT: for (size_t i = 0; i < 3; ++i) { +// CHECK-NEXT: float _d_fx = _d_x; +// CHECK-NEXT: float fx = x; +// CHECK-NEXT: {{.*}}push_back_pushforward(&v, static_cast(fx), &_d_v, static_cast(_d_fx)); +// CHECK-NEXT: } +// CHECK-NEXT: } +// CHECK-NEXT: double _d_res = 0; +// CHECK-NEXT: double res = 0; +// CHECK-NEXT: { +// CHECK-NEXT: size_t _d_i = 0; +// CHECK-NEXT: for (size_t i = 0; i < v.size(); ++i) { +// CHECK-NEXT: {{.*}}ValueAndPushforward<{{.*}}> _t0 = {{.*}}operator_subscript_pushforward(&v, i, &_d_v, _d_i); +// CHECK-NEXT: {{.*}}ValueAndPushforward<{{.*}}> _t1 = {{.*}}at_pushforward(&v, i, &_d_v, _d_i); +// CHECK-NEXT: double &_t2 = _t1.value; +// CHECK-NEXT: _t0.pushforward = _d_i * _t2 + i * _t1.pushforward; +// CHECK-NEXT: _t0.value = i * _t2; +// CHECK-NEXT: {{.*}}ValueAndPushforward<{{.*}}> _t3 = {{.*}}at_pushforward(&v, i, &_d_v, _d_i); +// CHECK-NEXT: _d_res += _t3.pushforward; +// CHECK-NEXT: res += _t3.value; +// CHECK-NEXT: } +// CHECK-NEXT: } +// CHECK-NEXT: const std::vector _d_v2 = _d_v; +// CHECK-NEXT: const std::vector v2 = v; +// CHECK-NEXT: {{.*}}ValueAndPushforward<{{.*}}> _t4 = {{.*}}front_pushforward(&v, &_d_v); +// CHECK-NEXT: {{.*}}ValueAndPushforward<{{.*}}> _t5 = {{.*}}back_pushforward(&v, &_d_v); +// CHECK-NEXT: {{.*}}ValueAndPushforward< ::std::size_t, ::std::size_t> _t6 = {{.*}}size_pushforward(&v, &_d_v); +// CHECK-NEXT: {{.*}}ValueAndPushforward<{{.*}}> _t7 = {{.*}}operator_subscript_pushforward(&v, _t6.value - 1, &_d_v, _t6.pushforward - 0); +// CHECK-NEXT: {{.*}}ValueAndPushforward _t8 = {{.*}}at_pushforward(&v2, 0, &_d_v2, 0); +// CHECK-NEXT: {{.*}}ValueAndPushforward _t9 = {{.*}}front_pushforward(&v2, &_d_v2); +// CHECK-NEXT: {{.*}}ValueAndPushforward _t10 = {{.*}}back_pushforward(&v2, &_d_v2); +// CHECK-NEXT: {{.*}}ValueAndPushforward< ::std::size_t, ::std::size_t> _t11 = {{.*}}size_pushforward(&v2, &_d_v2); +// CHECK-NEXT: {{.*}}ValueAndPushforward _t12 = {{.*}}operator_subscript_pushforward(&v2, _t11.value - 1, &_d_v2, _t11.pushforward - 0); +// CHECK-NEXT: return _d_res + _t4.pushforward + _t5.pushforward - _t7.pushforward + _t8.pushforward + _t9.pushforward + _t10.pushforward - _t12.pushforward; +// CHECK-NEXT: } + double fnArr1(double x) { std::array a; a.fill(x); @@ -214,6 +409,9 @@ int main() { INIT_DIFFERENTIATE(fnVec2, "u"); INIT_DIFFERENTIATE(fnVec3, "u"); INIT_DIFFERENTIATE(fnVec4, "u"); + INIT_DIFFERENTIATE(fnVec5, "x"); + INIT_DIFFERENTIATE(fnVec6, "x"); + INIT_DIFFERENTIATE(fnVec7, "x"); INIT_DIFFERENTIATE(fnArr1, "x"); INIT_DIFFERENTIATE(fnArr2, "x"); INIT_DIFFERENTIATE(fnTuple1, "x"); @@ -222,6 +420,9 @@ int main() { TEST_DIFFERENTIATE(fnVec2, 3, 5); // CHECK-EXEC: {5.00} TEST_DIFFERENTIATE(fnVec3, 3, 5); // CHECK-EXEC: {2.00} TEST_DIFFERENTIATE(fnVec4, 3, 5); // CHECK-EXEC: {30.00} + TEST_DIFFERENTIATE(fnVec5, 3, 4); // CHECK-EXEC: {11.00} + TEST_DIFFERENTIATE(fnVec6, 3, 4); // CHECK-EXEC: {10.00} + TEST_DIFFERENTIATE(fnVec7, 3, 4); // CHECK-EXEC: {3.00} TEST_DIFFERENTIATE(fnArr1, 3); // CHECK-EXEC: {3.00} TEST_DIFFERENTIATE(fnArr2, 3); // CHECK-EXEC: {108.00} TEST_DIFFERENTIATE(fnTuple1, 3, 4); // CHECK-EXEC: {2.00} diff --git a/test/ForwardMode/UserDefinedTypes.C b/test/ForwardMode/UserDefinedTypes.C index 922270c96..fc7d6c865 100644 --- a/test/ForwardMode/UserDefinedTypes.C +++ b/test/ForwardMode/UserDefinedTypes.C @@ -1,8 +1,6 @@ // RUN: %cladclang -std=c++14 %s -I%S/../../include -oUserDefinedTypes.out | %filecheck %s // RUN: ./UserDefinedTypes.out | %filecheck_exec %s -// XFAIL: asserts - #include "clad/Differentiator/Differentiator.h" #include "clad/Differentiator/STLBuiltins.h" From fd2ac312db62e2e1871bb1163b9d357ea8b89f1b Mon Sep 17 00:00:00 2001 From: Atell Krasnopolski Date: Wed, 18 Sep 2024 08:53:23 +0200 Subject: [PATCH 11/14] Add verbose tag to debug the tests --- test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 715af0971..a1d17f51d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -95,7 +95,7 @@ add_lit_testsuite(check-clad "Running the Clad regression tests" LIT ${LIT_COMMAND} PARAMS ${CLAD_TEST_PARAMS} DEPENDS ${CLAD_TEST_DEPS} - ARGS ${CLAD_TEST_EXTRA_ARGS} --show-skipped --show-unsupported + ARGS ${CLAD_TEST_EXTRA_ARGS} --verbose --show-skipped --show-unsupported ) set_target_properties(check-clad PROPERTIES FOLDER "Clad tests") From dc1ebff4d88055235e9ffae52e03fef2e61c7c9b Mon Sep 17 00:00:00 2001 From: Austeja Date: Mon, 16 Sep 2024 23:39:22 +0300 Subject: [PATCH 12/14] Add support for 'std::atan2' and 'std::acos' --- .../clad/Differentiator/BuiltinDerivatives.h | 22 ++++++++ test/FirstDerivative/BuiltinDerivatives.C | 52 +++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/include/clad/Differentiator/BuiltinDerivatives.h b/include/clad/Differentiator/BuiltinDerivatives.h index 3f9dcae67..557274a56 100644 --- a/include/clad/Differentiator/BuiltinDerivatives.h +++ b/include/clad/Differentiator/BuiltinDerivatives.h @@ -183,6 +183,25 @@ CUDA_HOST_DEVICE ValueAndPushforward floor_pushforward(T x, T /*d_x*/) { return {::std::floor(x), (T)0}; } +template +CUDA_HOST_DEVICE ValueAndPushforward atan2_pushforward(T y, T x, T d_y, + T d_x) { + return {::std::atan2(y, x), + -(y / ((x * x) + (y * y))) * d_x + x / ((x * x) + (y * y)) * d_y}; +} + +template +CUDA_HOST_DEVICE void atan2_pullback(T y, T x, U d_z, T* d_y, T* d_x) { + *d_y += x / ((x * x) + (y * y)) * d_z; + + *d_x += -(y / ((x * x) + (y * y))) * d_z; +} + +template +CUDA_HOST_DEVICE ValueAndPushforward acos_pushforward(T x, T d_x) { + return {::std::acos(x), ((-1) / (::std::sqrt(1 - x * x))) * d_x}; +} + template CUDA_HOST_DEVICE ValueAndPushforward ceil_pushforward(T x, T /*d_x*/) { return {::std::ceil(x), (T)0}; @@ -321,6 +340,9 @@ inline void free_pushforward(void* ptr, void* d_ptr) { // These are required because C variants of mathematical functions are // defined in global namespace. using std::abs_pushforward; +using std::acos_pushforward; +using std::atan2_pullback; +using std::atan2_pushforward; using std::ceil_pushforward; using std::cos_pushforward; using std::exp_pushforward; diff --git a/test/FirstDerivative/BuiltinDerivatives.C b/test/FirstDerivative/BuiltinDerivatives.C index e608473bc..0ff3b6e62 100644 --- a/test/FirstDerivative/BuiltinDerivatives.C +++ b/test/FirstDerivative/BuiltinDerivatives.C @@ -248,6 +248,44 @@ double f14(double x) { return __builtin_pow(x, 3); } +double f15(double y, double x) { + return std::atan2(y, x); +} + +//CHECK: {{float|double}} f15_darg0({{float|double}} y, {{float|double}} x) { +//CHECK-NEXT: {{float|double}} _d_y = 1; +//CHECK-NEXT: {{float|double}} _d_x = 0; +//CHECK-NEXT: {{.*}}ValueAndPushforward<{{float|double}}, {{float|double}}> _t0 = {{.*}}atan2_pushforward(y, x, _d_y, _d_x); +//CHECK-NEXT: return _t0.pushforward; +//CHECK-NEXT: } + +//CHECK: {{float|double}} f15_darg1({{float|double}} y, {{float|double}} x) { +//CHECK-NEXT: {{float|double}} _d_y = 0; +//CHECK-NEXT: {{float|double}} _d_x = 1; +//CHECK-NEXT: {{.*}}ValueAndPushforward<{{float|double}}, {{float|double}}> _t0 = {{.*}}atan2_pushforward(y, x, _d_y, _d_x); +//CHECK-NEXT: return _t0.pushforward; +//CHECK-NEXT: } + +void f15_grad(double y, double x, double *_d_y, double *_d_x); +//CHECK: void f15_grad(double y, double x, double *_d_y, double *_d_x) { +//CHECK: { +//CHECK-NEXT: double _r0 = 0{{.*}}; +//CHECK-NEXT: double _r1 = 0{{.*}}; +//CHECK-NEXT: {{.*}}atan2_pullback(y, x, 1, &_r0, &_r1); +//CHECK-NEXT: *_d_y += _r0; +//CHECK-NEXT: *_d_x += _r1; +//CHECK-NEXT: } +//CHECK-NEXT: } + +float f16(float x) { + return std::acos(x); +} +// CHECK: {{float|double}} f16_darg0({{float|double}} x) { +//CHECK-NEXT: {{float|double}} _d_x = 1; +//CHECK-NEXT: {{.*}}ValueAndPushforward<{{float|double}}, {{float|double}}> _t0 = {{.*}}acos_pushforward(x, _d_x); +//CHECK-NEXT: return _t0.pushforward; +//CHECK-NEXT: } + int main () { //expected-no-diagnostics float f_result[2]; double d_result[2]; @@ -326,5 +364,19 @@ int main () { //expected-no-diagnostics auto f14_ddarg0 = clad::differentiate<2>(f14, 0); printf("Result is = %f\n", f14_ddarg0.execute(1)); //CHECK-EXEC: Result is = 6.000000 + auto f15_darg0 = clad::differentiate(f15, 0); + printf("Result is = %f\n", f15_darg0.execute(4, 3)); //CHECK-EXEC: Result is = 0.120000 + + auto f15_darg1 = clad::differentiate(f15, 1); + printf("Result is = %f\n", f15_darg1.execute(4, 3)); //CHECK-EXEC: Result is = -0.160000 + + d_result[0] = d_result[1] = 0; + clad::gradient(f15); + f15_grad(4, 3, &d_result[0], &d_result[1]); + printf("Result is = {%f, %f}\n", d_result[0], d_result[1]); //CHECK-EXEC: Result is = {0.120000, -0.160000} + + auto f16_darg0 = clad::differentiate(f16, 0); + printf("Result is = %f\n", f16_darg0.execute(0.9)); //CHECK-EXEC: Result is = -2.294157 + return 0; } From b9a390d43d4a356b0269015e19cbf7d466073f61 Mon Sep 17 00:00:00 2001 From: Atell Krasnopolski Date: Wed, 18 Sep 2024 16:07:19 +0200 Subject: [PATCH 13/14] Enhance the support of std::vector and std::array in the rvs mode Fixes: #1081 --- include/clad/Differentiator/STLBuiltins.h | 56 +++++++ test/Gradient/STLCustomDerivatives.C | 182 ++++++++++++++++++++++ 2 files changed, 238 insertions(+) diff --git a/include/clad/Differentiator/STLBuiltins.h b/include/clad/Differentiator/STLBuiltins.h index fc240d11e..744bdff38 100644 --- a/include/clad/Differentiator/STLBuiltins.h +++ b/include/clad/Differentiator/STLBuiltins.h @@ -421,6 +421,22 @@ void operator_subscript_pullback(::std::vector* vec, (*d_vec)[idx] += d_y; } +template +clad::ValueAndAdjoint +at_reverse_forw(::std::vector* vec, typename ::std::vector::size_type idx, + ::std::vector* d_vec, + typename ::std::vector::size_type d_idx) { + return {(*vec)[idx], (*d_vec)[idx]}; +} + +template +void at_pullback(::std::vector* vec, + typename ::std::vector::size_type idx, P d_y, + ::std::vector* d_vec, + typename ::std::vector::size_type* d_idx) { + (*d_vec)[idx] += d_y; +} + template ::clad::ValueAndAdjoint<::std::vector, ::std::vector> constructor_reverse_forw(::clad::ConstructorReverseForwTag<::std::vector>, @@ -443,6 +459,43 @@ void constructor_pullback(::std::vector* v, S count, U val, d_v->clear(); } +template +void assign_pullback(::std::vector* v, + typename ::std::vector::size_type n, U /*val*/, + ::std::vector* d_v, + typename ::std::vector::size_type* /*d_n*/, dU* d_val) { + for (typename ::std::vector::size_type i = 0; i < n; ++i) { + (*d_val) += (*d_v)[i]; + (*d_v)[i] = 0; + } +} + +template +void reserve_pullback(::std::vector* v, + typename ::std::vector::size_type n, + ::std::vector* d_v, + typename ::std::vector::size_type* /*d_n*/) noexcept {} + +template +void shrink_to_fit_pullback(::std::vector* /*v*/, + ::std::vector* /*d_v*/) noexcept {} + +template +void size_pullback(::std::vector* /*v*/, + ::std::vector* /*d_v*/) noexcept {} + +template +void capacity_pullback(::std::vector* /*v*/, + ::std::vector* /*d_v*/) noexcept {} + +template +void size_pullback(::std::vector* /*v*/, U /*d_y*/, + ::std::vector* /*d_v*/) noexcept {} + +template +void capacity_pullback(::std::vector* /*v*/, U /*d_y*/, + ::std::vector* /*d_v*/) noexcept {} + // array reverse mode template @@ -514,6 +567,9 @@ void front_pullback(::std::array* arr, } template void size_pullback(::std::array* a, ::std::array* d_a) noexcept {} +template +void size_pullback(::std::array* /*a*/, U /*d_y*/, + ::std::array* /*d_a*/) noexcept {} template ::clad::ValueAndAdjoint<::std::array, ::std::array> constructor_reverse_forw(::clad::ConstructorReverseForwTag<::std::array>, diff --git a/test/Gradient/STLCustomDerivatives.C b/test/Gradient/STLCustomDerivatives.C index ba89aa34d..f5739109f 100644 --- a/test/Gradient/STLCustomDerivatives.C +++ b/test/Gradient/STLCustomDerivatives.C @@ -147,6 +147,36 @@ double fn18(double x, double y) { return a[1]; } +double fn19(double x, double y) { + std::vector v; + for (size_t i = 0; i < 3; ++i) { + v.push_back(x); + } + double res = 0; + for (size_t i = 0; i < v.size(); ++i) { + res += v.at(i); + } + + v.assign(3, 0); + v.assign(2, y); + + return res + v[0] + v[1] + v[2]; // 3x+2y +} + +double fn20(double x, double y) { + std::vector v; + + v.reserve(10); + + double res = x*v.capacity(); + + v.push_back(x); + v.shrink_to_fit(); + res += y*v.capacity() + x*v.size(); + + return res; // 11x+y +} + int main() { double d_i, d_j; INIT_GRADIENT(fn10); @@ -158,6 +188,8 @@ int main() { INIT_GRADIENT(fn16); INIT_GRADIENT(fn17); INIT_GRADIENT(fn18); + INIT_GRADIENT(fn19); + INIT_GRADIENT(fn20); TEST_GRADIENT(fn10, /*numOfDerivativeArgs=*/2, 3, 5, &d_i, &d_j); // CHECK-EXEC: {1.00, 1.00} TEST_GRADIENT(fn11, /*numOfDerivativeArgs=*/2, 3, 5, &d_i, &d_j); // CHECK-EXEC: {2.00, 1.00} @@ -168,6 +200,8 @@ int main() { TEST_GRADIENT(fn16, /*numOfDerivativeArgs=*/2, 3, 4, &d_i, &d_j); // CHECK-EXEC: {108.00, 27.00} TEST_GRADIENT(fn17, /*numOfDerivativeArgs=*/2, 3, 4, &d_i, &d_j); // CHECK-EXEC: {4.00, 2.00} TEST_GRADIENT(fn18, /*numOfDerivativeArgs=*/2, 3, 4, &d_i, &d_j); // CHECK-EXEC: {2.00, 0.00} + TEST_GRADIENT(fn19, /*numOfDerivativeArgs=*/2, 3, 4, &d_i, &d_j); // CHECK-EXEC: {3.00, 2.00} + TEST_GRADIENT(fn20, /*numOfDerivativeArgs=*/2, 3, 4, &d_i, &d_j); // CHECK-EXEC: {11.00, 1.00} } // CHECK: void fn10_grad(double u, double v, double *_d_u, double *_d_v) { @@ -659,3 +693,151 @@ int main() { // CHECK-NEXT: {{.*}}operator_subscript_pullback(&_t0, 1, 0., &_d_a, &_r0); // CHECK-NEXT: } // CHECK-NEXT: } + +// CHECK: void fn19_grad(double x, double y, double *_d_x, double *_d_y) { +// CHECK-NEXT: size_t _d_i = {{0U|0UL|0}}; +// CHECK-NEXT: size_t i = {{0U|0UL|0}}; +// CHECK-NEXT: {{.*}}tape _t1 = {}; +// CHECK-NEXT: {{.*}}tape<{{.*}}vector > _t2 = {}; +// CHECK-NEXT: size_t _d_i0 = {{0U|0UL|0}}; +// CHECK-NEXT: size_t i0 = {{0U|0UL|0}}; +// CHECK-NEXT: {{.*}}tape<{{.*}}vector > _t4 = {}; +// CHECK-NEXT: {{.*}}tape _t5 = {}; +// CHECK-NEXT: {{.*}}tape<{{.*}}vector > _t6 = {}; +// CHECK-NEXT: {{.*}}vector _d_v({}); +// CHECK-NEXT: {{.*}}vector v; +// CHECK-NEXT: {{.*}} _t0 = {{0U|0UL|0}}; +// CHECK-NEXT: for (i = 0; ; ++i) { +// CHECK-NEXT: { +// CHECK-NEXT: if (!(i < 3)) +// CHECK-NEXT: break; +// CHECK-NEXT: } +// CHECK-NEXT: _t0++; +// CHECK-NEXT: {{.*}}push(_t1, x); +// CHECK-NEXT: {{.*}}push(_t2, v); +// CHECK-NEXT: {{.*}}push_back_reverse_forw(&v, x, &_d_v, *_d_x); +// CHECK-NEXT: } +// CHECK-NEXT: double _d_res = 0.; +// CHECK-NEXT: double res = 0; +// CHECK-NEXT: {{.*}} _t3 = {{0U|0UL|0}}; +// CHECK-NEXT: for (i0 = 0; ; ++i0) { +// CHECK-NEXT: { +// CHECK-NEXT: { +// CHECK-NEXT: {{.*}}push(_t4, v); +// CHECK-NEXT: } +// CHECK-NEXT: if (!(i0 < v.size())) +// CHECK-NEXT: break; +// CHECK-NEXT: } +// CHECK-NEXT: _t3++; +// CHECK-NEXT: {{.*}}push(_t5, res); +// CHECK-NEXT: {{.*}}push(_t6, v); +// CHECK-NEXT: {{.*}}ValueAndAdjoint _t7 = {{.*}}at_reverse_forw(&v, i0, &_d_v, _r0); +// CHECK-NEXT: res += _t7.value; +// CHECK-NEXT: } +// CHECK-NEXT: {{.*}}vector _t8 = v; +// CHECK-NEXT: v.assign(3, 0); +// CHECK-NEXT: double _t9 = y; +// CHECK-NEXT: {{.*}}vector _t10 = v; +// CHECK-NEXT: v.assign(2, y); +// CHECK-NEXT: {{.*}}vector _t11 = v; +// CHECK-NEXT: {{.*}}ValueAndAdjoint _t12 = {{.*}}operator_subscript_reverse_forw(&v, 0, &_d_v, _r4); +// CHECK-NEXT: {{.*}}vector _t13 = v; +// CHECK-NEXT: {{.*}}ValueAndAdjoint _t14 = {{.*}}operator_subscript_reverse_forw(&v, 1, &_d_v, _r5); +// CHECK-NEXT: {{.*}}vector _t15 = v; +// CHECK-NEXT: {{.*}}ValueAndAdjoint _t16 = {{.*}}operator_subscript_reverse_forw(&v, 2, &_d_v, _r6); +// CHECK-NEXT: { +// CHECK-NEXT: _d_res += 1; +// CHECK-NEXT: {{.*}}size_type _r4 = {{0U|0UL|0}}; +// CHECK-NEXT: {{.*}}operator_subscript_pullback(&_t11, 0, 1, &_d_v, &_r4); +// CHECK-NEXT: {{.*}}size_type _r5 = {{0U|0UL|0}}; +// CHECK-NEXT: {{.*}}operator_subscript_pullback(&_t13, 1, 1, &_d_v, &_r5); +// CHECK-NEXT: {{.*}}size_type _r6 = {{0U|0UL|0}}; +// CHECK-NEXT: {{.*}}operator_subscript_pullback(&_t15, 2, 1, &_d_v, &_r6); +// CHECK-NEXT: } +// CHECK-NEXT: { +// CHECK-NEXT: y = _t9; +// CHECK-NEXT: {{.*}}size_type _r3 = {{0U|0UL|0}}; +// CHECK-NEXT: {{.*}}assign_pullback(&_t10, 2, _t9, &_d_v, &_r3, &*_d_y); +// CHECK-NEXT: } +// CHECK-NEXT: { +// CHECK-NEXT: {{.*}}size_type _r1 = {{0U|0UL|0}}; +// CHECK-NEXT: {{.*}}value_type _r2 = 0.; +// CHECK-NEXT: {{.*}}assign_pullback(&_t8, 3, 0, &_d_v, &_r1, &_r2); +// CHECK-NEXT: } +// CHECK-NEXT: for (;; _t3--) { +// CHECK-NEXT: { +// CHECK-NEXT: { +// CHECK-NEXT: {{.*}}size_pullback(&{{.*}}back(_t4), &_d_v); +// CHECK-NEXT: {{.*}}pop(_t4); +// CHECK-NEXT: } +// CHECK-NEXT: if (!_t3) +// CHECK-NEXT: break; +// CHECK-NEXT: } +// CHECK-NEXT: --i0; +// CHECK-NEXT: { +// CHECK-NEXT: res = {{.*}}pop(_t5); +// CHECK-NEXT: double _r_d0 = _d_res; +// CHECK-NEXT: size_t _r0 = {{0U|0UL|0}}; +// CHECK-NEXT: {{.*}}at_pullback(&{{.*}}back(_t6), i0, _r_d0, &_d_v, &_r0); +// CHECK-NEXT: _d_i0 += _r0; +// CHECK-NEXT: {{.*}}pop(_t6); +// CHECK-NEXT: } +// CHECK-NEXT: } +// CHECK-NEXT: for (;; _t0--) { +// CHECK-NEXT: { +// CHECK-NEXT: if (!_t0) +// CHECK-NEXT: break; +// CHECK-NEXT: } +// CHECK-NEXT: --i; +// CHECK-NEXT: { +// CHECK-NEXT: x = {{.*}}back(_t1); +// CHECK-NEXT: {{.*}}push_back_pullback(&{{.*}}back(_t2), {{.*}}back(_t1), &_d_v, &*_d_x); +// CHECK-NEXT: {{.*}}pop(_t1); +// CHECK-NEXT: {{.*}}pop(_t2); +// CHECK-NEXT: } +// CHECK-NEXT: } +// CHECK-NEXT: } + +// CHECK: void fn20_grad(double x, double y, double *_d_x, double *_d_y) { +// CHECK-NEXT: {{.*}}vector _d_v({}); +// CHECK-NEXT: {{.*}}vector v; +// CHECK-NEXT: {{.*}}vector _t0 = v; +// CHECK-NEXT: v.reserve(10); +// CHECK-NEXT: {{.*}}vector _t2 = v; +// CHECK-NEXT: double _t1 = v.capacity(); +// CHECK-NEXT: double _d_res = 0.; +// CHECK-NEXT: double res = x * _t1; +// CHECK-NEXT: double _t3 = x; +// CHECK-NEXT: {{.*}}vector _t4 = v; +// CHECK-NEXT: {{.*}}push_back_reverse_forw(&v, x, &_d_v, *_d_x); +// CHECK-NEXT: {{.*}}vector _t5 = v; +// CHECK-NEXT: v.shrink_to_fit(); +// CHECK-NEXT: double _t6 = res; +// CHECK-NEXT: {{.*}}vector _t8 = v; +// CHECK-NEXT: double _t7 = v.capacity(); +// CHECK-NEXT: {{.*}}vector _t10 = v; +// CHECK-NEXT: double _t9 = v.size(); +// CHECK-NEXT: res += y * _t7 + x * _t9; +// CHECK-NEXT: _d_res += 1; +// CHECK-NEXT: { +// CHECK-NEXT: res = _t6; +// CHECK-NEXT: double _r_d0 = _d_res; +// CHECK-NEXT: *_d_y += _r_d0 * _t7; +// CHECK-NEXT: {{.*}}capacity_pullback(&_t8, y * _r_d0, &_d_v); +// CHECK-NEXT: *_d_x += _r_d0 * _t9; +// CHECK-NEXT: {{.*}}size_pullback(&_t10, x * _r_d0, &_d_v); +// CHECK-NEXT: } +// CHECK-NEXT: {{.*}}shrink_to_fit_pullback(&_t5, &_d_v); +// CHECK-NEXT: { +// CHECK-NEXT: x = _t3; +// CHECK-NEXT: {{.*}}push_back_pullback(&_t4, _t3, &_d_v, &*_d_x); +// CHECK-NEXT: } +// CHECK-NEXT: { +// CHECK-NEXT: *_d_x += _d_res * _t1; +// CHECK-NEXT: {{.*}}capacity_pullback(&_t2, x * _d_res, &_d_v); +// CHECK-NEXT: } +// CHECK-NEXT: { +// CHECK-NEXT: {{.*}}size_type _r0 = {{0U|0UL|0}}; +// CHECK-NEXT: {{.*}}reserve_pullback(&_t0, 10, &_d_v, &_r0); +// CHECK-NEXT: } +// CHECK-NEXT: } From e2b8e354d13193041a1210888061f12f950b1154 Mon Sep 17 00:00:00 2001 From: Christina Koutsou <74819775+kchristin22@users.noreply.github.com> Date: Mon, 23 Sep 2024 08:21:21 +0300 Subject: [PATCH 14/14] Fix appendage of nullptrs to args of a CUDA kernel (#1102) --- include/clad/Differentiator/Differentiator.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/include/clad/Differentiator/Differentiator.h b/include/clad/Differentiator/Differentiator.h index 3a8f35faf..72b4d62ab 100644 --- a/include/clad/Differentiator/Differentiator.h +++ b/include/clad/Differentiator/Differentiator.h @@ -125,8 +125,18 @@ CUDA_HOST_DEVICE T push(tape& to, ArgsT... val) { CUDA_ARGS CUDA_REST_ARGS Args&&... args) { #if defined(__CUDACC__) && !defined(__CUDA_ARCH__) if (CUDAkernel) { - void* argPtrs[] = {(void*)&args..., (void*)static_cast(nullptr)...}; - cudaLaunchKernel((void*)f, grid, block, argPtrs, shared_mem, stream); + constexpr size_t totalArgs = sizeof...(args) + sizeof...(Rest); + std::vector argPtrs; + argPtrs.reserve(totalArgs); + (argPtrs.push_back(static_cast(&args)), ...); + + void* null_param = nullptr; + for (size_t i = sizeof...(args); i < totalArgs; ++i) + argPtrs[i] = &null_param; + + cudaLaunchKernel((void*)f, grid, block, argPtrs.data(), shared_mem, + stream); + return return_type_t(); } else { return f(static_cast(args)..., static_cast(nullptr)...); }