-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
89 lines (52 loc) · 1.81 KB
/
main.cpp
File metadata and controls
89 lines (52 loc) · 1.81 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include <iostream>
#include <string>
#include <CImg.h>
#include "image_descriptor.hpp"
#include "rotate.hpp"
#include "rotate_hip.hpp"
#include "utils.hpp"
#include "moving_average.hpp"
#include "moving_average_hip.hpp"
using namespace cimg_library;
void test_rotate()
{
//change this to test other data types
typedef float T;
std::string image_file =
"data/lena_bw.pgm";
//"data/lena_small.pgm";
CImg<T> cuda_image(image_file.c_str());
cuda_image.normalize(0.f, 1.f);
CImg<T> hip_image(image_file.c_str());
hip_image.normalize(0.f, 1.f);
T* cuda_data = cuda_image.data();
T* hip_data = hip_image.data();
std::cout << "Image : " << image_file << "\n"
<< "widht: " << cuda_image.width() << " "
<< "height: " << cuda_image.height() << " "
<< "depth: " << cuda_image.depth() << " "
<< "spectrum: " << cuda_image.spectrum() << " "
<< "size: " <<cuda_image.size() << std::endl;
image_description<T> img_desc;
img_desc.height = cuda_image.height();
img_desc.width = cuda_image.width();
img_desc.x_addr_mode = CLAMP;
img_desc.y_addr_mode = CLAMP;
transform_image(cuda_data, img_desc, 0.5f);
transform_host_image(hip_data, img_desc, 0.5f);
// std::string ref_image_file = "data/ref_rotated.pgm";
// CImg<T> ref_image(ref_image_file.c_str());
// ref_image.normalize(0.f, 1.f);
//compareData(ref_image.data(), d, img_desc.width*img_desc.height, 5e-2f, 0.15f);
cuda_image.normalize(0, 255);
cuda_image.save("data/lena_cuda_result.pgm");
hip_image.normalize(0, 255);
hip_image.save("data/lena_hip_result.pgm");
}
int main(int argc, char *argv[])
{
calculate_moving_average();
calculate_moving_average_hip();
//test_rotate();
return 0;
}