Skip to content

Commit

Permalink
Replace std vector with std array in GradientCuda
Browse files Browse the repository at this point in the history
  • Loading branch information
kchristin22 committed Mar 7, 2024
1 parent ae7cc7d commit 20be1f3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test/CUDA/GradientCuda.cu
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// XFAIL: clang-15

#include "clad/Differentiator/Differentiator.h"
#include <vector>
#include <array>

#define N 3

Expand Down Expand Up @@ -110,7 +110,7 @@ int main(void) {
cudaMemcpy(d_x, x, N * sizeof(double), cudaMemcpyHostToDevice);
cudaMalloc(&d_p, N * sizeof(double));
cudaMemcpy(d_p, p, N * sizeof(double), cudaMemcpyHostToDevice);
std::vector<double> result(N, 0);
std::array<double, N> result{0};
double *d_result;

cudaMalloc(&d_result, N * sizeof(double));
Expand All @@ -121,7 +121,7 @@ int main(void) {
cudaMemcpy(result.data(), d_result, N * sizeof(double), cudaMemcpyDeviceToHost);
printf("%f,%f,%f\n", result[0], result[1], result[2]);

std::vector<double> result_cpu(N, 0);
std::array<double, N> result_cpu{0};
auto gauss_g = clad::gradient(gauss, "p");
gauss_g.execute(x, p, 2.0, N, result_cpu.data());

Expand Down

0 comments on commit 20be1f3

Please sign in to comment.