Monday, March 16, 2009

Detecting presense of GPULib

Over the weekend, a user (Mort Canty) asked the GPULib user's mailing list for a way to detect the presence. One of our developers wrote a routine to do just that, and I thought it might be of use to other GPULib users as well.

Below is the routine GPU_DETECT that will return a boolean indicating if GPULib is present. It will also initialize the GPU if it finds GPUINIT. If you have any questions, feel free to ask!

; docformat = 'rst'

; Initializes GPULib if it is present.
; :Returns:
; 1 if GPULib is present, 0 if not
; :Params:
; devId: in, optional, type=numtype
; id of the GPU device to be used for GPU computations
; :Keywords:
; _ref_extra : in, optional, type=keywords
; keywords to GPUINIT
function gpu_detect, devId, _ref_extra=e
compile_opt strictarr

catch, error
if (error ne 0L) then begin
catch, /cancel
return, 0

gpuinit, devId, _extra

return, 1

No comments: