Skip to content

Commit

Permalink
Fix build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-penev committed Apr 12, 2024
1 parent 5eb784b commit 933b391
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
5 changes: 2 additions & 3 deletions demos/ComputerGraphics/cpp-smallpt-d/build.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"
11 changes: 6 additions & 5 deletions demos/ComputerGraphics/cpp-smallpt-d/diff-tracer-1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion demos/ComputerGraphics/smallpt/build.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"

0 comments on commit 933b391

Please sign in to comment.