-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGPU_loop_MultMat_free.c
56 lines (38 loc) · 1.3 KB
/
GPU_loop_MultMat_free.c
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
/** @file GPU_loop_MultMat_free.c
*/
#ifdef HAVE_CUDA
#include <cuda_runtime_api.h>
#include <cuda_runtime.h>
#include <cublas_v2.h>
#include "cudacomp_types.h"
extern GPUMATMULTCONF gpumatmultconf[20];
int GPU_loop_MultMat_free(int index)
{
int device;
cudaFree(gpumatmultconf[index].d_cMat);
cudaFree(gpumatmultconf[index].d_dmVec);
cudaFree(gpumatmultconf[index].d_wfsVec);
cudaFree(gpumatmultconf[index].d_wfsRef);
cudaFree(gpumatmultconf[index].d_dmRef);
free(gpumatmultconf[index].stream);
for(device = 0; device < gpumatmultconf[index].NBstreams; device++)
{
// free memory for stream
cublasDestroy(gpumatmultconf[index].handle[device]);
free(gpumatmultconf[index].cMat_part[device]);
free(gpumatmultconf[index].wfsVec_part[device]);
free(gpumatmultconf[index].dmVec_part[device]);
}
free(gpumatmultconf[index].cMat_part);
free(gpumatmultconf[index].dmVec_part);
free(gpumatmultconf[index].wfsVec_part);
free(gpumatmultconf[index].Nsize);
free(gpumatmultconf[index].Noffset);
free(gpumatmultconf[index].iret);
free(gpumatmultconf[index].threadarray);
free(gpumatmultconf[index].thdata);
free(gpumatmultconf[index].refWFSinit);
free(gpumatmultconf[index].GPUdevice);
return(0);
}
#endif