-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
68 lines (54 loc) · 1.97 KB
/
main.cpp
File metadata and controls
68 lines (54 loc) · 1.97 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
#include <iostream>
#include <stdio.h>
#include <ctime>
#include "loadFile.h";
#include "galaxyKernel.h"
constexpr auto HISTOGRAM = 720 ;
constexpr auto size = 100000;
using namespace std;
int main(int argc, char** argv)
{
//get the size of the array
size_t size = VectorSize("Data/data_100k_arcmin.txt");
std::cout << "The size of the array galaxy is " << size << std::endl;
//allocate memory for the two device real and flat
float* hostReal_ascension = CreateDeviceVector("Data/data_100k_arcmin.txt", size, true);
float* hostReal_descension = CreateDeviceVector("Data/data_100k_arcmin.txt", size, false);
float* hostFlat_ascension = CreateDeviceVector("Data/flat_100k_arcmin.txt", size, true);
float* hostFlat_descension = CreateDeviceVector("Data/flat_100k_arcmin.txt", size, false);
//allocate memory for the histogram
unsigned long long int* hostDD = (unsigned long long int*)malloc(HISTOGRAM * sizeof(unsigned long long int));
unsigned long long int* hostRR = (unsigned long long int*)malloc(HISTOGRAM * sizeof(unsigned long long int));
unsigned long long int* hostDR = (unsigned long long int*)malloc(HISTOGRAM * sizeof(unsigned long long int));
float* scientificDifference = (float*)malloc(HISTOGRAM * sizeof(float));
//initialize to 0
for (int i = 0; i < HISTOGRAM; i++)
{
hostDD[i] = 0;
hostRR[i] = 0;
hostDR[i] = 0;
scientificDifference[i] = 0;
}
//invoke kernel
Kernel_handler_single(hostReal_ascension, hostReal_descension, hostDD, size);
bool debug = false;
if (debug)
{
unsigned long long int sumDD = 0;
for (int i = 0; i < HISTOGRAM; i++)
{
std::cout << "HistDD[" << i << "] => " << hostDD[i] << std::endl;
sumDD += hostDD[i];
}
std::cout << "The sum of histDD is " << sumDD << std::endl;
}
//free the memory
delete[] hostReal_ascension;
delete[] hostReal_descension;
delete[] hostFlat_ascension;
delete[] hostFlat_descension;
delete[] hostDD;
delete[] hostRR;
delete[] hostDR;
delete[] scientificDifference;
}