-
Notifications
You must be signed in to change notification settings - Fork 0
/
Managed.cuh
executable file
·49 lines (39 loc) · 1.23 KB
/
Managed.cuh
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
/* CREDITS
* Author : Martin Garaj <garaj.martin@gmail.com>
* Date : 12/2017
* Project : HPC MPI Testing application
*
* REDISTRIBUTION
* The software is meant for internal use at City University of Hong Kong only.
* Further redistribution/sharing of the software or any parts of the source code without author's permission is disapproved.
*
* DISCLAIMER
* This software comes as is, without any warranty. Use on your own risk.
*
* CHANGE LOG
* Please log any changes below, log the Author, Date and Change done.
* Author | Date | Change
* | YYYY/MM/DD |
*/
#include <cuda_runtime_api.h>
#include <cuda.h>
#ifndef MANAGED_INHERIT_CUH_
#define MANAGED_INHERIT_CUH_
//==========================================================//
// CLASS DEFINITION //
//==========================================================//
/** Inheriting from this object gives the object ability to get automatically
* allocated in Unified Memory, when using "new" operator
*/
class Managed{
public:
void *operator new(size_t len){
void *ptr;
cudaMallocManaged(&ptr, len);
return ptr;
}
void operator delete(void *ptr){
cudaFree(ptr);
}
};
#endif /* MANAGED_INHERIT_CUH_ */