-
Notifications
You must be signed in to change notification settings - Fork 16
/
device_copies.cu
53 lines (41 loc) · 1.09 KB
/
device_copies.cu
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
#include <cuda.h>
#include <stdio.h>
#include "datadef.h"
/**
* \brief function to do a host-to-device copy
* \details something
*
* @param[in] dest - cuda pointer on device
* @param[in] source - pointer on host
* @param[in] bytes - number of bytes to copy
*/
void copy_to_device(void* dest,void* source ,unsigned bytes){
cudaMemcpy(dest,source,bytes,cudaMemcpyHostToDevice);
}
/**
* \brief function to do a device-to-host copy
*
* @param[in] dest - pointer on host
* @param[in] source - cuda pointer on device
* @param[in] bytes - number of bytes to copy
*/
void copy_from_device(void* dest,void* source ,unsigned bytes){
cudaMemcpy(dest,source,bytes,cudaMemcpyDeviceToHost);
}
/**
* \brief function to do a device memory allocation
*
* @param[in] dest - pointer on host
* @param[in] bytes - number of bytes to copy
*/
void allocate_on_device(void** dest,unsigned bytes){
cudaMalloc(dest,bytes);
}
/**
* \brief function to do a device memory allocation
*
* @param[in] dest - pointer on device to deallocate
*/
void deallocate_on_device(void* dest){
cudaFree(dest);
}