-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtiling_test.cpp
More file actions
86 lines (42 loc) · 1.54 KB
/
tiling_test.cpp
File metadata and controls
86 lines (42 loc) · 1.54 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
#include <iostream>
#include "include/kernels.cuh"
void printOutput(float *r, int NUM_OF_POINTS){
// Print output.
for (int i = 0; i < NUM_OF_POINTS; i++){
for (int j = 0; j < NUM_OF_POINTS; j++){
std::cout << r[i * NUM_OF_POINTS + j] << " ";
}
std::cout << "\n";
}
}
int main(){
// Initialize tile size and number of tiles.
int NUM_OF_POINTS = 1000;
int BLOCKSIZE;
// Initialize array of points p_i
float p[NUM_OF_POINTS];
// Initialize matrix r_ij (of size NUM_OF_POINTS^2) that represents the interaction calculated between r_i and r_j.
float r[NUM_OF_POINTS * NUM_OF_POINTS];
// Initialize each point with a value.
for (int i = 0; i < NUM_OF_POINTS; i++) {
p[i] = float(i);
for (int j = 0; j < NUM_OF_POINTS; j++) {
r[i * NUM_OF_POINTS + j] = 0.0;
}
}
// Run tiling calculations on GPU.
tiling_calculation(p, r, NUM_OF_POINTS, 1);
tiling_calculation(p, r, NUM_OF_POINTS, 2);
tiling_calculation(p, r, NUM_OF_POINTS, 4);
tiling_calculation(p, r, NUM_OF_POINTS, 8);
tiling_calculation(p, r, NUM_OF_POINTS, 16);
tiling_calculation(p, r, NUM_OF_POINTS, 32);
tiling_calculation(p, r, NUM_OF_POINTS, 64);
tiling_calculation(p, r, NUM_OF_POINTS, 128);
tiling_calculation(p, r, NUM_OF_POINTS, 256);
tiling_calculation(p, r, NUM_OF_POINTS, 512);
tiling_calculation(p, r, NUM_OF_POINTS, 1024);
// Print output.
//printOutput(r, NUM_OF_POINTS);
return 0;
}