-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cu
66 lines (49 loc) · 1.38 KB
/
main.cu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <thrust/version.h>
#include <vector>
#include <iostream>
#include <stdio.h>
#include <assert.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include "Microbe.h"
struct printf_functor
{
__host__ __device__
void operator()(double x)
{
printf("%f\n", x);
}
};
__global__
void hellWorld(int test)
{
printf("Hello from block %d, thread %d\n", blockIdx.x, threadIdx.x);
}
int main(int argc, char *argv[])
{
int major = THRUST_MAJOR_VERSION;
int minor = THRUST_MINOR_VERSION;
std::cout << "Thrust v" << major << "." << minor << std::endl;
double dt = 0.1;
int num_microbes = 8;
// Microbe m(0, 0.1);
std::vector<Microbe> microbes;
for(int i = 0; i < num_microbes; i++)
{
Microbe newMicrobe(i, dt);
microbes.push_back(newMicrobe);
}
thrust::host_vector<MicrobeData> h_microbesData;
for(int i = 0; i < num_microbes; i++)
{
h_microbesData.push_back(microbes[i].GetGPUData());
}
thrust::device_vector<MicrobeData> d_microbesData;
d_microbesData = h_microbesData;
// thrust::device_vector<Microbe> d_microbes = microbes;
thrust::for_each(d_microbesData.begin(), d_microbesData.end(), functor_Simulate());
// kernal_Simulate <<<1, 32>>>(d_microbes.begin(), d_microbes.end());
// kernal_Simulate <<<5, 32>>>(num_microbes);
// cudaDeviceSynchronize();
return 0;
}