Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ENH: Updated cl.Context init arguement device_type= to allow a string.

  • Loading branch information...
commit 036f009e1ce0d852a4c33b86202b3be112dc6208 1 parent 279d980
srossross authored
Showing with 10 additions and 2 deletions.
  1. +10 −2 opencl/context.pyx
View
12 opencl/context.pyx
@@ -1,6 +1,6 @@
from opencl.errors import OpenCLException
-from _cl cimport *
+from _cl cimport *
from opencl.copencl cimport CyPlatform_GetID, CyPlatform_Create
from opencl.copencl cimport CyDevice_GetID, CyDevice_Create
@@ -162,7 +162,15 @@ cdef class Context:
if err_code != CL_SUCCESS:
raise OpenCLException(err_code, _context_errors)
else:
- dtype = < cl_device_type > device_type
+ if isinstance(device_type, (str, bytes)):
+ if isinstance(device_type, bytes):
+ device_type = device_type.decode('utf-8')
+ import opencl
+
+ dtype = < cl_device_type > opencl.Device.DEV_TYPE_MAP[device_type.upper()]
+
+ else:
+ dtype = < cl_device_type > device_type
if props == NULL:
import opencl
Please sign in to comment.
Something went wrong with that request. Please try again.