-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcuda-api.rkt
59 lines (53 loc) · 1.53 KB
/
cuda-api.rkt
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
57
58
;; Provides interfaces to the nvidia cuda api
;;Typed tensors
#lang typed/racket
(require/typed
"lib-cudann.rkt"
[_cudnn-status_t CType]
[_cudnnHandle_t CType]
[_cudaEvent_t CType]
[_cuda-memcpy-kind_t CType]
[cuda-create-handle ( -> CPointer)]
[initGPUData (CPointer Exact-Nonnegative-Integer Flonum -> Void)]
[dref-handle (CPointer -> CPointer)]
[dref-int-ptr (CPointer -> Positive-Integer)]
[dref-ptr (CPointer -> CPointer)]
[cudaDeviceSynchronize ( -> Symbol)]
[cudaEventCreate (CType -> CType)]
[cudaEventRecord (CType -> CType)]
[cudaEventSynchronize (CType -> CType)]
[cudaMemcpy (CPointer CPointer Exact-Nonnegative-Integer CType -> Symbol)]
[cudaFree (CType -> CType)]
[cudaMalloc (CPointer Exact-Nonnegative-Integer -> Symbol)]
[cudnnDestroy (CType -> CType)]
[cuda-host-to-device-copy (CPointer CPointer Exact-Nonnegative-Integer -> Symbol)]
[cuda-device-to-host-copy (CPointer CPointer Exact-Nonnegative-Integer -> Symbol)]
[cuda-host-to-host-copy (CPointer CPointer Exact-Nonnegative-Integer -> Symbol)]
)
(require "ffi-functional.rkt")
;; Pointer size
(: POINTER-SIZE Exact-Nonnegative-Integer)
(define POINTER-SIZE 8)
;;Get a pointer
(: get-pointer (-> CPointer))
(define (get-pointer )
(malloc 'atomic-interior POINTER-SIZE))
(provide
cudaDeviceSynchronize
cudaEventCreate
cudaEventRecord
cudaEventSynchronize
cudaMemcpy
cudaMalloc
cudaFree
cudnnDestroy
get-pointer
cuda-create-handle
cuda-host-to-device-copy
cuda-device-to-host-copy
cuda-host-to-host-copy
dref-handle
dref-ptr
initGPUData
dref-int-ptr
)