Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pyopencl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Klöckner
pyopencl
Commits
71d5b537
Commit
71d5b537
authored
10 years ago
by
Yichao Yu
Browse files
Options
Downloads
Patches
Plain Diff
nullptr
parent
fd6d963f
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/c_wrapper/error.h
+1
-1
1 addition, 1 deletion
src/c_wrapper/error.h
src/c_wrapper/pyhelper.h
+1
-1
1 addition, 1 deletion
src/c_wrapper/pyhelper.h
src/c_wrapper/utils.h
+8
-6
8 additions, 6 deletions
src/c_wrapper/utils.h
src/c_wrapper/wrap_cl.cpp
+37
-36
37 additions, 36 deletions
src/c_wrapper/wrap_cl.cpp
with
47 additions
and
44 deletions
src/c_wrapper/error.h
+
1
−
1
View file @
71d5b537
...
@@ -140,7 +140,7 @@ c_handle_error(std::function<void()> func)
...
@@ -140,7 +140,7 @@ c_handle_error(std::function<void()> func)
{
{
try
{
try
{
func
();
func
();
return
NULL
;
return
nullptr
;
}
catch
(
const
clerror
&
e
)
{
}
catch
(
const
clerror
&
e
)
{
auto
err
=
(
::
error
*
)
malloc
(
sizeof
(
::
error
));
auto
err
=
(
::
error
*
)
malloc
(
sizeof
(
::
error
));
err
->
routine
=
strdup
(
e
.
routine
());
err
->
routine
=
strdup
(
e
.
routine
());
...
...
This diff is collapsed.
Click to expand it.
src/c_wrapper/pyhelper.h
+
1
−
1
View file @
71d5b537
...
@@ -19,7 +19,7 @@ class WrapFunc<Ret(Args...)> {
...
@@ -19,7 +19,7 @@ class WrapFunc<Ret(Args...)> {
return
f
?
f
:
([]
(
Args
...)
{
return
Ret
();});
return
f
?
f
:
([]
(
Args
...)
{
return
Ret
();});
}
}
public
:
public
:
WrapFunc
(
_FuncType
func
=
NULL
)
WrapFunc
(
_FuncType
func
=
nullptr
)
:
m_func
(
check_func
(
func
))
:
m_func
(
check_func
(
func
))
{}
{}
Ret
Ret
...
...
This diff is collapsed.
Click to expand it.
src/c_wrapper/utils.h
+
8
−
6
View file @
71d5b537
...
@@ -38,7 +38,8 @@ class pyopencl_buf : public std::unique_ptr<T, _D<T> > {
...
@@ -38,7 +38,8 @@ class pyopencl_buf : public std::unique_ptr<T, _D<T> > {
size_t
m_len
;
size_t
m_len
;
public:
public:
pyopencl_buf
(
size_t
len
=
1
)
:
pyopencl_buf
(
size_t
len
=
1
)
:
std
::
unique_ptr
<
T
,
_D
<
T
>
>
((
T
*
)(
len
?
malloc
(
sizeof
(
T
)
*
len
)
:
NULL
)),
std
::
unique_ptr
<
T
,
_D
<
T
>
>
((
T
*
)(
len
?
malloc
(
sizeof
(
T
)
*
len
)
:
nullptr
)),
m_len
(
len
)
m_len
(
len
)
{
{
}
}
...
@@ -214,7 +215,7 @@ get_vec_info(cl_int (*func)(ArgTypes...), const char *name,
...
@@ -214,7 +215,7 @@ get_vec_info(cl_int (*func)(ArgTypes...), const char *name,
ArgTypes2
&&
...
args
)
ArgTypes2
&&
...
args
)
{
{
size_t
size
=
0
;
size_t
size
=
0
;
call_guarded
(
func
,
name
,
args
...,
0
,
NULL
,
&
size
);
call_guarded
(
func
,
name
,
args
...,
0
,
nullptr
,
&
size
);
pyopencl_buf
<
T
>
buf
(
size
/
sizeof
(
T
));
pyopencl_buf
<
T
>
buf
(
size
/
sizeof
(
T
));
call_guarded
(
func
,
name
,
args
...,
size
,
buf
.
get
(),
&
size
);
call_guarded
(
func
,
name
,
args
...,
size
,
buf
.
get
(),
&
size
);
return
buf
;
return
buf
;
...
@@ -278,7 +279,8 @@ get_opaque_info(cl_int (*func)(ArgTypes...), const char *name,
...
@@ -278,7 +279,8 @@ get_opaque_info(cl_int (*func)(ArgTypes...), const char *name,
ArgTypes2
&&
...
args
)
ArgTypes2
&&
...
args
)
{
{
CLType
param_value
;
CLType
param_value
;
call_guarded
(
func
,
name
,
args
...,
sizeof
(
param_value
),
&
param_value
,
NULL
);
call_guarded
(
func
,
name
,
args
...,
sizeof
(
param_value
),
&
param_value
,
nullptr
);
generic_info
info
;
generic_info
info
;
info
.
dontfree
=
0
;
info
.
dontfree
=
0
;
info
.
opaque_class
=
Cls
::
get_class_t
();
info
.
opaque_class
=
Cls
::
get_class_t
();
...
@@ -286,7 +288,7 @@ get_opaque_info(cl_int (*func)(ArgTypes...), const char *name,
...
@@ -286,7 +288,7 @@ get_opaque_info(cl_int (*func)(ArgTypes...), const char *name,
if
(
param_value
)
{
if
(
param_value
)
{
info
.
value
=
(
void
*
)(
new
Cls
(
param_value
,
/*retain*/
true
));
info
.
value
=
(
void
*
)(
new
Cls
(
param_value
,
/*retain*/
true
));
}
else
{
}
else
{
info
.
value
=
NULL
;
info
.
value
=
nullptr
;
}
}
return
info
;
return
info
;
}
}
...
@@ -300,7 +302,7 @@ get_str_info(cl_int (*func)(ArgTypes...), const char *name,
...
@@ -300,7 +302,7 @@ get_str_info(cl_int (*func)(ArgTypes...), const char *name,
ArgTypes2
&&
...
args
)
ArgTypes2
&&
...
args
)
{
{
size_t
param_value_size
;
size_t
param_value_size
;
call_guarded
(
func
,
name
,
args
...,
0
,
NULL
,
&
param_value_size
);
call_guarded
(
func
,
name
,
args
...,
0
,
nullptr
,
&
param_value_size
);
pyopencl_buf
<
char
>
param_value
(
param_value_size
);
pyopencl_buf
<
char
>
param_value
(
param_value_size
);
call_guarded
(
func
,
name
,
args
...,
param_value_size
,
call_guarded
(
func
,
name
,
args
...,
param_value_size
,
param_value
.
get
(),
&
param_value_size
);
param_value
.
get
(),
&
param_value_size
);
...
@@ -320,7 +322,7 @@ get_int_info(cl_int (*func)(ArgTypes...), const char *name,
...
@@ -320,7 +322,7 @@ get_int_info(cl_int (*func)(ArgTypes...), const char *name,
const
char
*
tpname
,
ArgTypes2
&&
...
args
)
const
char
*
tpname
,
ArgTypes2
&&
...
args
)
{
{
pyopencl_buf
<
T
>
param_value
;
pyopencl_buf
<
T
>
param_value
;
call_guarded
(
func
,
name
,
args
...,
sizeof
(
T
),
param_value
.
get
(),
NULL
);
call_guarded
(
func
,
name
,
args
...,
sizeof
(
T
),
param_value
.
get
(),
nullptr
);
generic_info
info
;
generic_info
info
;
info
.
dontfree
=
0
;
info
.
dontfree
=
0
;
info
.
opaque_class
=
CLASS_NONE
;
info
.
opaque_class
=
CLASS_NONE
;
...
...
This diff is collapsed.
Click to expand it.
src/c_wrapper/wrap_cl.cpp
+
37
−
36
View file @
71d5b537
...
@@ -71,7 +71,7 @@ platform::get_devices(cl_device_type devtype) const
...
@@ -71,7 +71,7 @@ platform::get_devices(cl_device_type devtype) const
cl_uint
num_devices
=
0
;
cl_uint
num_devices
=
0
;
try
{
try
{
pyopencl_call_guarded
(
clGetDeviceIDs
,
pyopencl_call_guarded
(
clGetDeviceIDs
,
data
(),
devtype
,
0
,
NULL
,
&
num_devices
);
data
(),
devtype
,
0
,
nullptr
,
&
num_devices
);
}
catch
(
const
clerror
&
e
)
{
}
catch
(
const
clerror
&
e
)
{
if
(
e
.
code
()
!=
CL_DEVICE_NOT_FOUND
)
if
(
e
.
code
()
!=
CL_DEVICE_NOT_FOUND
)
throw
e
;
throw
e
;
...
@@ -118,7 +118,7 @@ public:
...
@@ -118,7 +118,7 @@ public:
cl_platform_id
plat
;
cl_platform_id
plat
;
pyopencl_call_guarded
(
clGetDeviceInfo
,
data
(),
pyopencl_call_guarded
(
clGetDeviceInfo
,
data
(),
CL_DEVICE_PLATFORM
,
sizeof
(
plat
),
CL_DEVICE_PLATFORM
,
sizeof
(
plat
),
&
plat
,
NULL
);
&
plat
,
nullptr
);
#endif
#endif
pyopencl_call_guarded
(
pyopencl_call_guarded
(
pyopencl_get_ext_fun
(
plat
,
clRetainDeviceEXT
),
did
);
pyopencl_get_ext_fun
(
plat
,
clRetainDeviceEXT
),
did
);
...
@@ -147,7 +147,7 @@ public:
...
@@ -147,7 +147,7 @@ public:
#if PYOPENCL_CL_VERSION >= 0x1020
#if PYOPENCL_CL_VERSION >= 0x1020
cl_platform_id
plat
;
cl_platform_id
plat
;
pyopencl_call_guarded
(
clGetDeviceInfo
,
data
(),
CL_DEVICE_PLATFORM
,
pyopencl_call_guarded
(
clGetDeviceInfo
,
data
(),
CL_DEVICE_PLATFORM
,
sizeof
(
plat
),
&
plat
,
NULL
);
sizeof
(
plat
),
&
plat
,
nullptr
);
#endif
#endif
pyopencl_call_guarded_cleanup
(
pyopencl_call_guarded_cleanup
(
pyopencl_get_ext_fun
(
plat
,
clReleaseDeviceEXT
),
data
());
pyopencl_get_ext_fun
(
plat
,
clReleaseDeviceEXT
),
data
());
...
@@ -388,17 +388,17 @@ public:
...
@@ -388,17 +388,17 @@ public:
// properties.push_back(0);
// properties.push_back(0);
// cl_device_partition_property *props_ptr
// cl_device_partition_property *props_ptr
// = properties.empty( ) ?
NULL
: &properties.front();
// = properties.empty( ) ?
nullptr
: &properties.front();
// cl_uint num_entries;
// cl_uint num_entries;
// PYOPENCL_CALL_GUARDED(clCreateSubDevices,
// PYOPENCL_CALL_GUARDED(clCreateSubDevices,
// (m_device, props_ptr, 0,
NULL
, &num_entries));
// (m_device, props_ptr, 0,
nullptr
, &num_entries));
// std::vector<cl_device_id> result;
// std::vector<cl_device_id> result;
// result.resize(num_entries);
// result.resize(num_entries);
// PYOPENCL_CALL_GUARDED(clCreateSubDevices,
// PYOPENCL_CALL_GUARDED(clCreateSubDevices,
// (m_device, props_ptr, num_entries, &result.front(),
NULL
));
// (m_device, props_ptr, num_entries, &result.front(),
nullptr
));
// py::list py_result;
// py::list py_result;
// BOOST_FOREACH(cl_device_id did, result)
// BOOST_FOREACH(cl_device_id did, result)
...
@@ -417,7 +417,7 @@ public:
...
@@ -417,7 +417,7 @@ public:
// #if PYOPENCL_CL_VERSION >= 0x1020
// #if PYOPENCL_CL_VERSION >= 0x1020
// cl_platform_id plat;
// cl_platform_id plat;
// PYOPENCL_CALL_GUARDED(clGetDeviceInfo, (m_device, CL_DEVICE_PLATFORM,
// PYOPENCL_CALL_GUARDED(clGetDeviceInfo, (m_device, CL_DEVICE_PLATFORM,
// sizeof(plat), &plat,
NULL
));
// sizeof(plat), &plat,
nullptr
));
// #endif
// #endif
// PYOPENCL_GET_EXT_FUN(plat, clCreateSubDevicesEXT, create_sub_dev);
// PYOPENCL_GET_EXT_FUN(plat, clCreateSubDevicesEXT, create_sub_dev);
...
@@ -426,17 +426,17 @@ public:
...
@@ -426,17 +426,17 @@ public:
// properties.push_back(CL_PROPERTIES_LIST_END_EXT);
// properties.push_back(CL_PROPERTIES_LIST_END_EXT);
// cl_device_partition_property_ext *props_ptr
// cl_device_partition_property_ext *props_ptr
// = properties.empty( ) ?
NULL
: &properties.front();
// = properties.empty( ) ?
nullptr
: &properties.front();
// cl_uint num_entries;
// cl_uint num_entries;
// PYOPENCL_CALL_GUARDED(create_sub_dev,
// PYOPENCL_CALL_GUARDED(create_sub_dev,
// (m_device, props_ptr, 0,
NULL
, &num_entries));
// (m_device, props_ptr, 0,
nullptr
, &num_entries));
// std::vector<cl_device_id> result;
// std::vector<cl_device_id> result;
// result.resize(num_entries);
// result.resize(num_entries);
// PYOPENCL_CALL_GUARDED(create_sub_dev,
// PYOPENCL_CALL_GUARDED(create_sub_dev,
// (m_device, props_ptr, num_entries, &result.front(),
NULL
));
// (m_device, props_ptr, num_entries, &result.front(),
nullptr
));
// py::list py_result;
// py::list py_result;
// BOOST_FOREACH(cl_device_id did, result)
// BOOST_FOREACH(cl_device_id did, result)
...
@@ -540,10 +540,11 @@ public:
...
@@ -540,10 +540,11 @@ public:
{
{
cl_uint
num_image_formats
;
cl_uint
num_image_formats
;
pyopencl_call_guarded
(
clGetSupportedImageFormats
,
data
(),
flags
,
pyopencl_call_guarded
(
clGetSupportedImageFormats
,
data
(),
flags
,
image_type
,
0
,
NULL
,
&
num_image_formats
);
image_type
,
0
,
nullptr
,
&
num_image_formats
);
pyopencl_buf
<
cl_image_format
>
formats
(
num_image_formats
);
pyopencl_buf
<
cl_image_format
>
formats
(
num_image_formats
);
pyopencl_call_guarded
(
clGetSupportedImageFormats
,
data
(),
flags
,
pyopencl_call_guarded
(
clGetSupportedImageFormats
,
data
(),
flags
,
image_type
,
formats
.
len
(),
formats
.
get
(),
NULL
);
image_type
,
formats
.
len
(),
formats
.
get
(),
nullptr
);
return
pyopencl_convert_array_info
(
cl_image_format
,
formats
);
return
pyopencl_convert_array_info
(
cl_image_format
,
formats
);
}
}
};
};
...
@@ -622,7 +623,7 @@ public:
...
@@ -622,7 +623,7 @@ public:
{
{
cl_context
param_value
;
cl_context
param_value
;
pyopencl_call_guarded
(
clGetCommandQueueInfo
,
data
(),
CL_QUEUE_CONTEXT
,
pyopencl_call_guarded
(
clGetCommandQueueInfo
,
data
(),
CL_QUEUE_CONTEXT
,
sizeof
(
param_value
),
&
param_value
,
NULL
);
sizeof
(
param_value
),
&
param_value
,
nullptr
);
return
std
::
unique_ptr
<
context
>
(
return
std
::
unique_ptr
<
context
>
(
new
context
(
param_value
,
/*retain*/
true
));
new
context
(
param_value
,
/*retain*/
true
));
}
}
...
@@ -762,7 +763,7 @@ class nanny_event : public event {
...
@@ -762,7 +763,7 @@ class nanny_event : public event {
private:
private:
void
*
m_ward
;
void
*
m_ward
;
public:
public:
nanny_event
(
cl_event
evt
,
bool
retain
,
void
*
ward
=
NULL
)
nanny_event
(
cl_event
evt
,
bool
retain
,
void
*
ward
=
nullptr
)
:
event
(
evt
,
retain
),
m_ward
(
ward
)
:
event
(
evt
,
retain
),
m_ward
(
ward
)
{
{
if
(
ward
)
{
if
(
ward
)
{
...
@@ -785,7 +786,7 @@ public:
...
@@ -785,7 +786,7 @@ public:
{
{
// No lock needed because multiple release is safe here.
// No lock needed because multiple release is safe here.
void
*
ward
=
m_ward
;
void
*
ward
=
m_ward
;
m_ward
=
NULL
;
m_ward
=
nullptr
;
py
::
deref
(
ward
);
py
::
deref
(
ward
);
}
}
};
};
...
@@ -808,7 +809,7 @@ public:
...
@@ -808,7 +809,7 @@ public:
{
{
size_t
param_value
;
size_t
param_value
;
pyopencl_call_guarded
(
clGetMemObjectInfo
,
data
(),
CL_MEM_SIZE
,
pyopencl_call_guarded
(
clGetMemObjectInfo
,
data
(),
CL_MEM_SIZE
,
sizeof
(
param_value
),
&
param_value
,
NULL
);
sizeof
(
param_value
),
&
param_value
,
nullptr
);
return
param_value
;
return
param_value
;
}
}
generic_info
generic_info
...
@@ -917,7 +918,7 @@ public:
...
@@ -917,7 +918,7 @@ public:
// PYOPENCL_RETRY_IF_MEM_ERROR(
// PYOPENCL_RETRY_IF_MEM_ERROR(
// PYOPENCL_CALL_GUARDED(clEnqueueMigrateMemObjects, (
// PYOPENCL_CALL_GUARDED(clEnqueueMigrateMemObjects, (
// cq.data(),
// cq.data(),
// mem_objects.size(), mem_objects.empty( ) ?
NULL
: &mem_objects.front(),
// mem_objects.size(), mem_objects.empty( ) ?
nullptr
: &mem_objects.front(),
// flags,
// flags,
// PYOPENCL_WAITLIST_ARGS, &evt
// PYOPENCL_WAITLIST_ARGS, &evt
// ));
// ));
...
@@ -940,10 +941,10 @@ public:
...
@@ -940,10 +941,10 @@ public:
// // {{{ get platform
// // {{{ get platform
// cl_device_id dev;
// cl_device_id dev;
// PYOPENCL_CALL_GUARDED(clGetCommandQueueInfo, (cq.data(), CL_QUEUE_DEVICE,
// PYOPENCL_CALL_GUARDED(clGetCommandQueueInfo, (cq.data(), CL_QUEUE_DEVICE,
// sizeof(dev), &dev,
NULL
));
// sizeof(dev), &dev,
nullptr
));
// cl_platform_id plat;
// cl_platform_id plat;
// PYOPENCL_CALL_GUARDED(clGetDeviceInfo, (cq.data(), CL_DEVICE_PLATFORM,
// PYOPENCL_CALL_GUARDED(clGetDeviceInfo, (cq.data(), CL_DEVICE_PLATFORM,
// sizeof(plat), &plat,
NULL
));
// sizeof(plat), &plat,
nullptr
));
// // }}}
// // }}}
// #endif
// #endif
...
@@ -958,7 +959,7 @@ public:
...
@@ -958,7 +959,7 @@ public:
// PYOPENCL_RETRY_IF_MEM_ERROR(
// PYOPENCL_RETRY_IF_MEM_ERROR(
// PYOPENCL_CALL_GUARDED(enqueue_migrate_fn, (
// PYOPENCL_CALL_GUARDED(enqueue_migrate_fn, (
// cq.data(),
// cq.data(),
// mem_objects.size(), mem_objects.empty( ) ?
NULL
: &mem_objects.front(),
// mem_objects.size(), mem_objects.empty( ) ?
nullptr
: &mem_objects.front(),
// flags,
// flags,
// PYOPENCL_WAITLIST_ARGS, &evt
// PYOPENCL_WAITLIST_ARGS, &evt
// ));
// ));
...
@@ -984,7 +985,7 @@ public:
...
@@ -984,7 +985,7 @@ public:
memcpy
(
&
m_format
,
fmt
,
sizeof
(
m_format
));
memcpy
(
&
m_format
,
fmt
,
sizeof
(
m_format
));
}
else
{
}
else
{
pyopencl_call_guarded
(
clGetImageInfo
,
data
(),
CL_IMAGE_FORMAT
,
pyopencl_call_guarded
(
clGetImageInfo
,
data
(),
CL_IMAGE_FORMAT
,
sizeof
(
m_format
),
&
m_format
,
NULL
);
sizeof
(
m_format
),
&
m_format
,
nullptr
);
}
}
}
}
generic_info
generic_info
...
@@ -1322,7 +1323,7 @@ enqueue_gl_objects(clEnqueueGLObjectFunc func, const char *name,
...
@@ -1322,7 +1323,7 @@ enqueue_gl_objects(clEnqueueGLObjectFunc func, const char *name,
// "clGetGLContextInfoKHR extension function not present");
// "clGetGLContextInfoKHR extension function not present");
// cl_context_properties *props_ptr
// cl_context_properties *props_ptr
// = props.empty( ) ?
NULL
: &props.front();
// = props.empty( ) ?
nullptr
: &props.front();
// switch (param_name)
// switch (param_name)
// {
// {
...
@@ -1346,7 +1347,7 @@ enqueue_gl_objects(clEnqueueGLObjectFunc func, const char *name,
...
@@ -1346,7 +1347,7 @@ enqueue_gl_objects(clEnqueueGLObjectFunc func, const char *name,
// PYOPENCL_CALL_GUARDED(func_ptr,
// PYOPENCL_CALL_GUARDED(func_ptr,
// (props_ptr, param_name, size,
// (props_ptr, param_name, size,
// devices.empty( ) ?
NULL
: &devices.front(), &size));
// devices.empty( ) ?
nullptr
: &devices.front(), &size));
// py::list result;
// py::list result;
// BOOST_FOREACH(cl_device_id did, devices)
// BOOST_FOREACH(cl_device_id did, devices)
...
@@ -1445,7 +1446,7 @@ public:
...
@@ -1445,7 +1446,7 @@ public:
if
(
!
m_valid
.
exchange
(
false
))
if
(
!
m_valid
.
exchange
(
false
))
return
;
return
;
pyopencl_call_guarded_cleanup
(
clEnqueueUnmapMemObject
,
m_queue
.
data
(),
pyopencl_call_guarded_cleanup
(
clEnqueueUnmapMemObject
,
m_queue
.
data
(),
m_mem
.
data
(),
m_ptr
,
0
,
NULL
,
NULL
);
m_mem
.
data
(),
m_ptr
,
0
,
nullptr
,
nullptr
);
}
}
event
*
event
*
release
(
const
command_queue
*
queue
,
const
clobj_t
*
_wait_for
,
release
(
const
command_queue
*
queue
,
const
clobj_t
*
_wait_for
,
...
@@ -1476,7 +1477,7 @@ public:
...
@@ -1476,7 +1477,7 @@ public:
void
*
void
*
data
()
const
data
()
const
{
{
return
m_valid
?
m_ptr
:
NULL
;
return
m_valid
?
m_ptr
:
nullptr
;
}
}
};
};
...
@@ -1591,7 +1592,7 @@ public:
...
@@ -1591,7 +1592,7 @@ public:
pyopencl_call_guarded
(
clGetProgramInfo
,
data
(),
pyopencl_call_guarded
(
clGetProgramInfo
,
data
(),
CL_PROGRAM_BINARIES
,
CL_PROGRAM_BINARIES
,
sizes
.
len
()
*
sizeof
(
char
*
),
sizes
.
len
()
*
sizeof
(
char
*
),
result_ptrs
.
get
(),
NULL
);
result_ptrs
.
get
(),
nullptr
);
}
catch
(...)
{
}
catch
(...)
{
for
(
size_t
i
=
0
;
i
<
sizes
.
len
();
i
++
)
{
for
(
size_t
i
=
0
;
i
<
sizes
.
len
();
i
++
)
{
free
(
result_ptrs
[
i
]);
free
(
result_ptrs
[
i
]);
...
@@ -1644,7 +1645,7 @@ public:
...
@@ -1644,7 +1645,7 @@ public:
{
{
auto
devices
=
buf_from_class
<
device
>
(
_devices
,
num_devices
);
auto
devices
=
buf_from_class
<
device
>
(
_devices
,
num_devices
);
pyopencl_call_guarded
(
clBuildProgram
,
data
(),
num_devices
,
pyopencl_call_guarded
(
clBuildProgram
,
data
(),
num_devices
,
devices
.
get
(),
options
,
NULL
,
NULL
);
devices
.
get
(),
options
,
nullptr
,
nullptr
);
}
}
// #if PYOPENCL_CL_VERSION >= 0x1020
// #if PYOPENCL_CL_VERSION >= 0x1020
...
@@ -1679,8 +1680,8 @@ public:
...
@@ -1679,8 +1680,8 @@ public:
// PYOPENCL_CALL_GUARDED(clCompileProgram,
// PYOPENCL_CALL_GUARDED(clCompileProgram,
// (data(), num_devices, devices,
// (data(), num_devices, devices,
// options.c_str(), header_names.size(),
// options.c_str(), header_names.size(),
// programs.empty() ?
NULL
: &programs.front(),
// programs.empty() ?
nullptr
: &programs.front(),
// header_name_ptrs.empty() ?
NULL
: &header_name_ptrs.front(),
// header_name_ptrs.empty() ?
nullptr
: &header_name_ptrs.front(),
// 0, 0));
// 0, 0));
// }
// }
// #endif
// #endif
...
@@ -1866,7 +1867,7 @@ get_platforms(clobj_t **_platforms, uint32_t *num_platforms)
...
@@ -1866,7 +1867,7 @@ get_platforms(clobj_t **_platforms, uint32_t *num_platforms)
{
{
return
c_handle_error
([
&
]
{
return
c_handle_error
([
&
]
{
*
num_platforms
=
0
;
*
num_platforms
=
0
;
pyopencl_call_guarded
(
clGetPlatformIDs
,
0
,
NULL
,
num_platforms
);
pyopencl_call_guarded
(
clGetPlatformIDs
,
0
,
nullptr
,
num_platforms
);
pyopencl_buf
<
cl_platform_id
>
platforms
(
*
num_platforms
);
pyopencl_buf
<
cl_platform_id
>
platforms
(
*
num_platforms
);
pyopencl_call_guarded
(
clGetPlatformIDs
,
*
num_platforms
,
pyopencl_call_guarded
(
clGetPlatformIDs
,
*
num_platforms
,
platforms
.
get
(),
num_platforms
);
platforms
.
get
(),
num_platforms
);
...
@@ -1955,7 +1956,7 @@ create_buffer(clobj_t *buffer, clobj_t _ctx, cl_mem_flags flags,
...
@@ -1955,7 +1956,7 @@ create_buffer(clobj_t *buffer, clobj_t _ctx, cl_mem_flags flags,
flags
,
size
,
hostbuf
);
flags
,
size
,
hostbuf
);
});
});
*
buffer
=
new_buffer
(
mem
,
(
flags
&
CL_MEM_USE_HOST_PTR
?
*
buffer
=
new_buffer
(
mem
,
(
flags
&
CL_MEM_USE_HOST_PTR
?
hostbuf
:
NULL
));
hostbuf
:
nullptr
));
});
});
}
}
...
@@ -2136,7 +2137,7 @@ create_image_2d(clobj_t *img, clobj_t _ctx, cl_mem_flags flags,
...
@@ -2136,7 +2137,7 @@ create_image_2d(clobj_t *img, clobj_t _ctx, cl_mem_flags flags,
fmt
,
width
,
height
,
pitch
,
buffer
);
fmt
,
width
,
height
,
pitch
,
buffer
);
});
});
*
img
=
new_image
(
mem
,
(
flags
&
CL_MEM_USE_HOST_PTR
?
*
img
=
new_image
(
mem
,
(
flags
&
CL_MEM_USE_HOST_PTR
?
buffer
:
NULL
),
fmt
);
buffer
:
nullptr
),
fmt
);
});
});
}
}
...
@@ -2153,7 +2154,7 @@ create_image_3d(clobj_t *img, clobj_t _ctx, cl_mem_flags flags,
...
@@ -2153,7 +2154,7 @@ create_image_3d(clobj_t *img, clobj_t _ctx, cl_mem_flags flags,
height
,
depth
,
pitch_x
,
pitch_y
,
buffer
);
height
,
depth
,
pitch_x
,
pitch_y
,
buffer
);
});
});
*
img
=
new_image
(
mem
,
(
flags
&
CL_MEM_USE_HOST_PTR
?
*
img
=
new_image
(
mem
,
(
flags
&
CL_MEM_USE_HOST_PTR
?
buffer
:
NULL
),
fmt
);
buffer
:
nullptr
),
fmt
);
});
});
}
}
...
@@ -2340,7 +2341,7 @@ _convert_memory_map(clobj_t *_evt, cl_event evt, command_queue *queue,
...
@@ -2340,7 +2341,7 @@ _convert_memory_map(clobj_t *_evt, cl_event evt, command_queue *queue,
pyopencl_call_guarded_cleanup
(
clReleaseEvent
,
evt
);
pyopencl_call_guarded_cleanup
(
clReleaseEvent
,
evt
);
}
}
pyopencl_call_guarded_cleanup
(
clEnqueueUnmapMemObject
,
queue
->
data
(),
pyopencl_call_guarded_cleanup
(
clEnqueueUnmapMemObject
,
queue
->
data
(),
buf
->
data
(),
res
,
0
,
NULL
,
NULL
);
buf
->
data
(),
res
,
0
,
nullptr
,
nullptr
);
throw
;
throw
;
}
}
}
}
...
@@ -2403,10 +2404,10 @@ enqueue_copy_buffer(clobj_t *_evt, clobj_t _queue, clobj_t _src, clobj_t _dst,
...
@@ -2403,10 +2404,10 @@ enqueue_copy_buffer(clobj_t *_evt, clobj_t _queue, clobj_t _src, clobj_t _dst,
size_t
byte_count_dst
=
0
;
size_t
byte_count_dst
=
0
;
pyopencl_call_guarded
(
pyopencl_call_guarded
(
clGetMemObjectInfo
,
src
->
data
(),
CL_MEM_SIZE
,
clGetMemObjectInfo
,
src
->
data
(),
CL_MEM_SIZE
,
sizeof
(
byte_count
),
&
byte_count_src
,
NULL
);
sizeof
(
byte_count
),
&
byte_count_src
,
nullptr
);
pyopencl_call_guarded
(
pyopencl_call_guarded
(
clGetMemObjectInfo
,
src
->
data
(),
CL_MEM_SIZE
,
clGetMemObjectInfo
,
src
->
data
(),
CL_MEM_SIZE
,
sizeof
(
byte_count
),
&
byte_count_dst
,
NULL
);
sizeof
(
byte_count
),
&
byte_count_dst
,
nullptr
);
byte_count
=
std
::
min
(
byte_count_src
,
byte_count_dst
);
byte_count
=
std
::
min
(
byte_count_src
,
byte_count_dst
);
}
}
auto
wait_for
=
buf_from_class
<
event
>
(
_wait_for
,
num_wait_for
);
auto
wait_for
=
buf_from_class
<
event
>
(
_wait_for
,
num_wait_for
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment