a744d027
Laila Saadatifard
upload the ivote3...
|
1
|
|
c9aba18a
Laila Saadatifard
ivote3 on the GPU...
|
2
3
|
#include "gaussian_blur3.cuh"
#include "gradient3.cuh"
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
4
|
#include "mag3.cuh"
|
a744d027
Laila Saadatifard
upload the ivote3...
|
5
|
#include "vote3_atomic_aabb.cuh"
|
1f55a874
Laila Saadatifard
upload the fixed ...
|
6
|
#include "update_dir3_aabb.cuh"
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
7
|
#include "local_max3.cuh"
|
310a1698
Laila Saadatifard
update the ivote3...
|
8
|
#include <fstream>
|
07e31b34
Laila Saadatifard
fix the bugs in i...
|
9
|
#include <sstream>
|
2558ee86
Laila Saadatifard
updating ivote3 t...
|
10
|
void ivote3(float* img, float sigma[], float phi, float d_phi, unsigned int r[],
|
310a1698
Laila Saadatifard
update the ivote3...
|
11
|
int iter, float t, unsigned int conn[], size_t x, size_t y, size_t z){
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
12
|
|
07e31b34
Laila Saadatifard
fix the bugs in i...
|
13
|
cudaSetDevice(0);
|
310a1698
Laila Saadatifard
update the ivote3...
|
14
|
size_t bytes = x * y * z * sizeof(float); // compute the number of bytes in the input data
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
15
|
|
1f55a874
Laila Saadatifard
upload the fixed ...
|
16
|
float* gpuI0; //assign memory on gpu for the input data
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
17
|
cudaMalloc(&gpuI0, bytes);
|
1f55a874
Laila Saadatifard
upload the fixed ...
|
18
|
cudaMemcpy(gpuI0, img, bytes, cudaMemcpyHostToDevice); //copy the image data to the GPU.
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
19
|
|
1f55a874
Laila Saadatifard
upload the fixed ...
|
20
|
gpu_gaussian_blur3<float>(gpuI0, sigma, x, y, z); //call the blurring function from the gpu.
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
21
22
|
cudaDeviceSynchronize();
|
1f55a874
Laila Saadatifard
upload the fixed ...
|
23
|
float* gpu_grad; //assign memory on the gpu for the gradient along the X, y, z.
|
c9aba18a
Laila Saadatifard
ivote3 on the GPU...
|
24
25
|
cudaMalloc(&gpu_grad, bytes*3);
|
310a1698
Laila Saadatifard
update the ivote3...
|
26
|
gpu_gradient3<float>(gpu_grad, gpuI0, x, y, z); //call the gradient function from the gpu.
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
27
28
|
cudaFree(gpuI0);
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
29
30
|
float* gpu_vote;
cudaMalloc(&gpu_vote, bytes);
|
c9aba18a
Laila Saadatifard
ivote3 on the GPU...
|
31
|
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
32
|
float cos_phi = cos(phi);
|
310a1698
Laila Saadatifard
update the ivote3...
|
33
|
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
34
35
|
//call the vote function.
for (int i = 0; i < iter; i++){
|
a744d027
Laila Saadatifard
upload the ivote3...
|
36
37
|
cudaMemset(gpu_vote, 0, bytes);
|
1f55a874
Laila Saadatifard
upload the fixed ...
|
38
|
gpu_vote3<float>(gpu_vote, gpu_grad, phi, cos_phi, r, x, y, z);
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
39
|
cudaDeviceSynchronize();
|
07e31b34
Laila Saadatifard
fix the bugs in i...
|
40
41
42
43
44
45
46
|
cudaMemcpy(img, gpu_vote, bytes, cudaMemcpyDeviceToHost);
std::string filename = "0-vote";
std::ofstream fvote(filename + std::to_string(i+1) + "_aabb.vol", std::ofstream::out | std::ofstream::binary);
fvote.write((char*)img, bytes);
fvote.close();
|
1f55a874
Laila Saadatifard
upload the fixed ...
|
47
|
gpu_update_dir3<float>(gpu_grad, gpu_vote, phi, cos_phi, r, x, y, z);
|
310a1698
Laila Saadatifard
update the ivote3...
|
48
49
50
|
cudaDeviceSynchronize();
phi = phi - d_phi;
cos_phi = cos(phi);
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
51
|
}
|
c9aba18a
Laila Saadatifard
ivote3 on the GPU...
|
52
|
|
2558ee86
Laila Saadatifard
updating ivote3 t...
|
53
|
cudaFree(gpu_grad);
|
46820b25
Laila Saadatifard
create an obj fil...
|
54
|
cudaMemcpy(img, gpu_vote, bytes, cudaMemcpyDeviceToHost);
|
2558ee86
Laila Saadatifard
updating ivote3 t...
|
55
|
|
46820b25
Laila Saadatifard
create an obj fil...
|
56
57
58
59
60
|
cudaFree(gpu_vote);
//cudaFree(gpu_output);
}
|
310a1698
Laila Saadatifard
update the ivote3...
|
61
|
void lmax(float* out, float* in, float t, unsigned int conn[], size_t x, size_t y, size_t z){
|
07e31b34
Laila Saadatifard
fix the bugs in i...
|
62
|
size_t bytes = x * y * z * sizeof(float);
|
46820b25
Laila Saadatifard
create an obj fil...
|
63
|
|
c986ebb7
Laila Saadatifard
fix ivote3 to work
|
64
|
cudaSetDevice(0);
|
a744d027
Laila Saadatifard
upload the ivote3...
|
65
|
|
1f55a874
Laila Saadatifard
upload the fixed ...
|
66
67
|
float* gpuV; //assign memory on gpu for the input data.
|
46820b25
Laila Saadatifard
create an obj fil...
|
68
69
|
cudaMalloc(&gpuV, bytes);
|
1f55a874
Laila Saadatifard
upload the fixed ...
|
70
|
cudaMemcpy(gpuV, in, bytes, cudaMemcpyHostToDevice); //copy the image data to the GPU.
|
46820b25
Laila Saadatifard
create an obj fil...
|
71
72
73
|
float* gpuOut;
cudaMalloc(&gpuOut, bytes);
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
74
|
|
1f55a874
Laila Saadatifard
upload the fixed ...
|
75
|
gpu_local_max3<float>(gpuOut, gpuV, t, conn, x, y, z); //call the local max function
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
76
|
|
1f55a874
Laila Saadatifard
upload the fixed ...
|
77
|
cudaMemcpy(out, gpuOut, bytes, cudaMemcpyDeviceToHost); //copy the final result to the cpu.
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
78
|
|
46820b25
Laila Saadatifard
create an obj fil...
|
79
80
|
cudaFree(gpuV);
cudaFree(gpuOut);
|
310a1698
Laila Saadatifard
update the ivote3...
|
81
|
}
|