Coverage report: /home/ellis/comp/core/ffi/cuda/cuda.lisp

KindCoveredAll%
expression037 0.0
branch00nil
Key
Not instrumented
Conditionalized out
Executed
Not executed
 
Both branches taken
One branch taken
Neither branch taken
1
 ;;; cuda.lisp --- CUDA API
2
 
3
 ;; 
4
 
5
 ;;; Code:
6
 (in-package :cuda)
7
 
8
 (defvar *cuda-device*)
9
 (defvar *cuda-context*)
10
 
11
 (defun device-compute-capability (dev-id)
12
   (with-alien ((maj int)
13
                (min int))
14
     (cu-device-compute-capability (addr maj) (addr min) dev-id)
15
     (values maj min)))
16
 
17
 (defun get-nvcc-arch (dev-id)
18
   (multiple-value-bind (maj min) (device-compute-capability dev-id)
19
     (format nil "-arch=sm_~D~D" maj min)))
20
 
21
 (defun get-cuda-device (dev-id)
22
   (with-alien ((dev cu-device))
23
     (cu-device-get (addr dev) dev-id)
24
     dev))
25
 
26
 (defun create-cuda-context (dev)
27
   (with-alien ((ctx cu-context))
28
     (cu-ctx-create (addr ctx) 0 dev)
29
     ctx))
30
 
31
 (defmacro with-cuda (dev-id &body body)
32
   `(progn
33
      (cu-init 0)
34
      (let* ((*cuda-device* (get-cuda-device ,dev-id))
35
             (*cuda-context* (create-cuda-context *cuda-device*)))
36
        (unwind-protect (progn ,@body)
37
          (cu-ctx-destroy *cuda-context*)))))
38
 
39
 (defvar *cuda-stream* nil)