Skip to content

Commit

Permalink
cuda: convert examples to 64-bit M
Browse files Browse the repository at this point in the history
  • Loading branch information
janden committed Dec 27, 2023
1 parent b4e1c4e commit 8594d1e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions examples/cuda/example2d1many.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int main(int argc, char *argv[])
int ier;
int N1 = 256;
int N2 = 256;
int M = 65536;
int64_t M = 65536;
int ntransf = 2;
int iflag = 1;
float tol = 1e-6;
Expand All @@ -58,12 +58,12 @@ int main(int argc, char *argv[])
std::default_random_engine eng(1);
std::uniform_real_distribution<float> distr(-1, 1);

for (int i = 0; i < M; i++) {
for (int64_t i = 0; i < M; i++) {
x[i] = M_PI * distr(eng);
y[i] = M_PI * distr(eng);
}

for (int i = 0; i < M * ntransf; i++) {
for (int64_t i = 0; i < M * ntransf; i++) {
c[i].real(distr(eng));
c[i].imag(distr(eng));
}
Expand Down
6 changes: 3 additions & 3 deletions examples/cuda/example2d2many.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int main(int argc, char *argv[])
int ier;
int N1 = 128;
int N2 = 128;
int M = 10;
int64_t M = 10;
int ntransf = 4;
int maxbatchsize = 4;
int iflag = 1;
Expand All @@ -59,7 +59,7 @@ int main(int argc, char *argv[])
std::default_random_engine eng(1);
std::uniform_real_distribution<double> distr(-1, 1);

for (int i = 0; i < M; i++) {
for (int64_t i = 0; i < M; i++) {
x[i] = M_PI * distr(eng);
y[i] = M_PI * distr(eng);
}
Expand Down Expand Up @@ -102,7 +102,7 @@ int main(int argc, char *argv[])
for (int t = 0; t < ntransf; t++) {
fkstart = fk + t * N1 * N2;
cstart = c + t * M;
int jt = M / 2; // check arbitrary choice of one targ pt
int64_t jt = M / 2; // check arbitrary choice of one targ pt
std::complex<double> J(0, iflag * 1);
std::complex<double> ct(0, 0);
int m = 0;
Expand Down
7 changes: 4 additions & 3 deletions examples/cuda/getting_started.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@

int main() {
// Problem size: number of nonuniform points (M) and grid size (N).
const int M = 100000, N = 10000;
const int64_t M = 100000;
const int N = 10000;

// Size of the grid as an array.
int64_t modes[1] = {N};
Expand Down Expand Up @@ -57,7 +58,7 @@ int main() {
// while strengths can be any value.
srand(0);

for (int j = 0; j < M; ++j) {
for (int64_t j = 0; j < M; ++j) {
x[j] = 2 * M_PI * (((float)rand()) / RAND_MAX - 1);
c[j] = (2 * ((float)rand()) / RAND_MAX - 1) + I * (2 * ((float)rand()) / RAND_MAX - 1);
}
Expand Down Expand Up @@ -100,7 +101,7 @@ int main() {
// transform.
f0 = 0;

for (int j = 0; j < M; ++j) {
for (int64_t j = 0; j < M; ++j) {
f0 += c[j] * cexp(I * x[j] * (idx - N / 2));
}

Expand Down

0 comments on commit 8594d1e

Please sign in to comment.