diff --git a/demos/ComputerGraphics/cpp-smallpt-d/build.sh b/demos/ComputerGraphics/cpp-smallpt-d/build.sh index 6a847dd93..c70356a69 100755 --- a/demos/ComputerGraphics/cpp-smallpt-d/build.sh +++ b/demos/ComputerGraphics/cpp-smallpt-d/build.sh @@ -1,4 +1,3 @@ #!/bin/bash -clang -Ofast -Xclang -add-plugin -Xclang clad -Xclang -load -Xclang ../../../build/lib/clad.so -I../../../include/ -x c++ -std=c++14 -lstdc++ -lm cpp-smallpt.cpp -fopenmp=libiomp5 -o cpp-smallpt "$@" - -clang -Ofast -Xclang -add-plugin -Xclang clad -Xclang -load -Xclang ../../../lib/clad.so -I../../../include/ -x c++ -std=c++14 -lstdc++ -lm diff-tracer-1.cpp -fopenmp=libiomp5 -o diff-tracer-1 "$@" +clang-18 -Ofast -Xclang -add-plugin -Xclang clad -Xclang -load -Xclang ../../../inst/lib/clad.so -I../../../include/ -x c++ -std=c++14 -lstdc++ -lm cpp-smallpt.cpp -fopenmp=libiomp5 -o cpp-smallpt "$@" +clang-18 -Ofast -Xclang -add-plugin -Xclang clad -Xclang -load -Xclang ../../../inst/lib/clad.so -I../../../include/ -x c++ -std=c++14 -lstdc++ -lm diff-tracer-1.cpp -fopenmp=libiomp5 -o diff-tracer-1 "$@" diff --git a/demos/ComputerGraphics/cpp-smallpt-d/diff-tracer-1.cpp b/demos/ComputerGraphics/cpp-smallpt-d/diff-tracer-1.cpp index d682dfe0d..eca391652 100644 --- a/demos/ComputerGraphics/cpp-smallpt-d/diff-tracer-1.cpp +++ b/demos/ComputerGraphics/cpp-smallpt-d/diff-tracer-1.cpp @@ -99,8 +99,9 @@ void performStep(double& theta_0, double& theta_1, double& theta_2, Dataset dt, // The cost function to minimize using gradient descent // theta_x are the parameters to learn; x, y are the inputs and outputs of f double cost(double theta_0, double theta_1, double theta_2, Dataset dt) { - char fileName[4096]; - snprintf(fileName, sizeof(fileName), "image-%d.ppm", dt.step++); + const size_t fileNameMaxSize = 4096; + char fileName[fileNameMaxSize]; + snprintf(fileName, fileNameMaxSize, "image-%d.ppm", dt.step++); Render( scene, *(&scene + 1) - scene, // Geometry, Lights dt.Vx, dt.Vy, dt.Vz, // Params - Center of one sphere // must be Vector3() @@ -151,9 +152,9 @@ void optimize(double theta[3], Dataset dt, unsigned int maxSteps, double eps) { std::cout << "Steps #" << currentStep << " Theta 0: " << theta[0] << " Theta 1: " << theta[1] << " Theta 2: " << theta[2] << std::endl; - hasConverged = abs(diff[0] - theta[0]) <= eps && - abs(diff[1] - theta[1]) <= eps && - abs(diff[2] - theta[2]) <= eps; + hasConverged = std::abs(diff[0] - theta[0]) <= eps && + std::abs(diff[1] - theta[1]) <= eps && + std::abs(diff[2] - theta[2]) <= eps; diff = theta; } while (currentStep++ < maxSteps && !hasConverged); diff --git a/demos/ComputerGraphics/smallpt/build.sh b/demos/ComputerGraphics/smallpt/build.sh index 21078bb5b..9de7d5b1a 100755 --- a/demos/ComputerGraphics/smallpt/build.sh +++ b/demos/ComputerGraphics/smallpt/build.sh @@ -1,2 +1,2 @@ #!/bin/bash -clang -Ofast -Xclang -add-plugin -Xclang clad -Xclang -load -Xclang ../../../build/lib/clad.so -I../../../include/ -I/usr/lib/gcc/x86_64-linux-gnu/10/include -x c++ -std=c++14 -lstdc++ -lm SmallPT.cpp -fopenmp=libiomp5 -o SmallPT "$@" +clang-18 -Ofast -Xclang -add-plugin -Xclang clad -Xclang -load -Xclang ../../../inst/lib/clad.so -I../../../include/ -I/usr/lib/gcc/x86_64-linux-gnu/10/include -x c++ -std=c++14 -lstdc++ -lm SmallPT.cpp -fopenmp=libiomp5 -o SmallPT "$@"