Open takagi opened 10 years ago
Pushing to FEATURES\ may not interact well with saved images or executables whose runtime environment can vary.
Thanks. I will take it into account.
Following shows how to determine CUDA SDK is already installed or not.
Goal Determining that CUDA SDK is already installed or not.
Approach
Processing a CFFI-Grovel specification file without defsystem
forms and handling a condition signaled.
Detail
Put a CFFI-Grovel specification file foo.lisp
containing following contents in cl-cuda system's directory.
(include "cuda.h")
Evaluate the following form to process the CFFI-Grovel specification file.
(asdf:perform
(make-instance 'cffi-grovel::process-op)
(make-instance 'cffi-grovel::grovel-file :pathname "foo"
:parent (asdf:find-system "cl-cuda")))
As the result, if CUDA SDK is not installed, the following condition is signaled.
External process exited with code 1.
Command was: "cc" "-m64" "-I" "/opt/local/include/" "-I/Users/mtakagi/Lisp/quicklisp/dists/quicklisp/so..." "-o" "/Users/mtakagi/.cache/common-lisp/sbcl-1.0.55-maco..." "/Users/mtakagi/.cache/common-lisp/sbcl-1.0.55-maco..."
Output was:
/Users/mtakagi/.cache/common-lisp/sbcl-1.0.55-macosx-x64/Users/mtakagi/Lisp/cl-cuda/foo.c:6:10: fatal error: 'cud.h' file not found
#include <cuda.h>
^
1 error generated.
[Condition of type SIMPLE-ERROR]
It can be determined that CUDA SDK is installed or not, although some false negatives remained that the compiler can not find cuda.h
file because of some reasons such as appropriate environment variables are not specified.
Problems
how about subclassing cffi-grovel::grovel-file (e.g. cuda-header
) and make it have the :around
method
that handles the error?
well, I'm not concerned with cl-cuda, but responding just on curiosity.
What you mean is something like this?
(defclass cuda-header (cffi-grovel:grovel-file) ())
(defmethod asdf:perform :around ((op cffi-grovel::process-op) (c cuda-header))
(handler-case (call-next-method op c)
(error (lambda (c) (handle-the-error))))
It would be nice.
Following shows consideration on guicho271828's suggestion.
Goal To finish cl-cuda to be loaded without any conditions on environments where CUDA SDK is not installed even though it does not work.
Approach
Subclassing cffi-grovel:grovel-file
with an :around
method that handles the condition causing if CUDA SDK is not installed.
(defclass cuda-grovel-file (cffi-grovel:grovel-file) ())
(defmethod asdf:perform :around ((op cffi-grovel::process-op) (c cuda-grovel-file))
(handler-case (call-next-method op c)
(error (e))))
Then, use the following ASDF components in cl-cuda's defsystem
form.
(cuda-grovel-file "type-grovel")
(cuda-grovel-file "enum-grovel")
Result
Cl-cuda is finished to be loaded without causing any conditions.
cffi-grovel::process-op
asdf:compile-op
and asdf:load-op
also cause file-not-found error after cffi-grovel::process-op
Problems
asdf:compile-op
and asdf:load-op
following cffi-grovel::process-op
cffi-grovel
package's private symbol cffi-grovel::process-op
is usedcl-cuda-test
test will not pass, of courseVery cool. I hope it's enough for quicklisp.
I rewrite the result and problems on my previous comment.
For resolving undefined symbols, I will define them in working around for the case cuda.h
not found. Additionally, I will modify to use grovel only for architecture depending types: CUdeviceptr and size_t.
Currently, cl-cuda is not available in Quicklisp distribution because of its testing policy (see #514 in quicklisp-projects).
It may be accepted if it just finished to be compiled without condition on an environment where CUDA SDK is not installed even though it does not work.
Approach:
cuda.h
before evaluate thedefsystem
form incl-cuda.asd
*features*
which mentions CUDA SDK is not installeddefsystem
form, avoidcffi-grovel:grovel-file
form to be evaluated by looking*features*
Quetions:
cffi-grovel:grovel-file
?