6 #include <schroedinger/schro.h>
7 #include <cuda_runtime_api.h>
9 #include <schroedinger/schrogpuframe.h>
10 #include <schroedinger/schrogpumotion.h>
13 schro_cuda_init (void)
19 ret
= cudaGetDeviceCount (&n
);
20 SCHRO_DEBUG ("cudaGetDeviceCount returned %d", ret
);
22 SCHRO_DEBUG ("CUDA devices %d", n
);
24 for (i
= 0; i
< n
; i
++) {
25 struct cudaDeviceProp prop
;
27 cudaGetDeviceProperties (&prop
, i
);
28 SCHRO_DEBUG ("CUDA props: %d: %d.%d mem=%d %s", i
,
29 prop
.major
, prop
.minor
, prop
.totalGlobalMem
, prop
.name
);
35 schro_cuda_alloc (int size
)
40 SCHRO_DEBUG ("domain is %d", schro_async_get_exec_domain ());
41 //SCHRO_ASSERT(schro_async_get_exec_domain () == SCHRO_EXEC_DOMAIN_CUDA);
43 ret
= cudaMalloc (&ptr
, size
);
49 schro_cuda_free (void *ptr
, int size
)
51 //SCHRO_ASSERT(schro_async_get_exec_domain () == SCHRO_EXEC_DOMAIN_CUDA);
53 if (schro_async_get_exec_domain () == SCHRO_EXEC_DOMAIN_CUDA
) {
56 SCHRO_ERROR ("Freeing CUDA memory outside CUDA thread.");
61 schro_memory_domain_new_cuda (void)
63 SchroMemoryDomain
*domain
;
65 domain
= schro_memory_domain_new ();
66 domain
->flags
= SCHRO_MEMORY_DOMAIN_CUDA
;
67 domain
->alloc
= schro_cuda_alloc
;
68 domain
->free
= schro_cuda_free
;
75 schro_motion_render_cuda (SchroMotion
* motion
, SchroFrame
* dest
)
77 SchroGPUMotion
*gpumotion
;
79 gpumotion
= schro_gpumotion_new (0);
81 schro_gpumotion_init (gpumotion
, motion
);
83 schro_gpumotion_copy (gpumotion
, motion
);
84 schro_gpumotion_render (gpumotion
, motion
, dest
);
86 schro_gpumotion_free (gpumotion
);
90 schro_frame_inverse_iwt_transform_cuda (SchroFrame
* frame
,
91 SchroFrame
* transform_frame
, SchroParams
* params
)
93 schro_frame_to_gpu (frame
, transform_frame
);
95 schro_gpuframe_inverse_iwt_transform (frame
, params
);