-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathgpu-thrust.cu
More file actions
27 lines (22 loc) · 789 Bytes
/
Copy pathgpu-thrust.cu
File metadata and controls
27 lines (22 loc) · 789 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
#include "gpu-thrust.h"
#include <thrust/device_ptr.h>
#include <thrust/functional.h>
#include <thrust/reduce.h>
#include <thrust/sort.h>
int NumVerticesGPU(int m, int* edges) {
thrust::device_ptr<int> ptr(edges);
return 1 + thrust::reduce(ptr, ptr + 2 * m, 0, thrust::maximum<int>());
}
void SortEdges(int m, int* edges) {
thrust::device_ptr<uint64_t> ptr((uint64_t*)edges);
thrust::sort(ptr, ptr + m);
}
void RemoveMarkedEdges(int m, int* edges, bool* flags) {
thrust::device_ptr<uint64_t> ptr((uint64_t*)edges);
thrust::device_ptr<bool> ptr_flags(flags);
thrust::remove_if(ptr, ptr + m, ptr_flags, thrust::identity<bool>());
}
uint64_t SumResults(int size, uint64_t* results) {
thrust::device_ptr<uint64_t> ptr(results);
return thrust::reduce(ptr, ptr + size);
}