-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
29 lines (22 loc) · 679 Bytes
/
main.cpp
File metadata and controls
29 lines (22 loc) · 679 Bytes
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
#include <iostream>
#include <cstdlib>
#include <ctime>
// Declare the function defined in the CUDA file
void bitonicSort(int* h_arr, int n);
int main() {
const int N = 1024; // must be power of 2 and divisible by BLOCK_SIZE
int* data = new int[N];
std::srand(std::time(nullptr));
for (int i = 0; i < N; ++i) {
data[i] = std::rand() % 1000;
}
std::cout << "Before sort:\n";
for (int i = 0; i < 20; ++i) std::cout << data[i] << " ";
std::cout << "\n";
bitonicSort(data, N);
std::cout << "After sort:\n";
for (int i = 0; i < 20; ++i) std::cout << data[i] << " ";
std::cout << "\n";
delete[] data;
return 0;
}