-
-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* link against the system boost-python library * add patch for Python 3.13 compatibility: new buffer interface
- Loading branch information
Showing
2 changed files
with
71 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- a/src/wrapper/wrap_cudadrv.cpp 2024-08-16 23:34:22.488898877 +0700 | ||
+++ b/src/wrapper/wrap_cudadrv.cpp 2024-08-16 23:57:36.164373451 +0700 | ||
@@ -355,9 +355,9 @@ | ||
module *module_from_buffer(py::object buffer, py::object py_options, | ||
py::object message_handler) | ||
{ | ||
- const char *mod_buf; | ||
PYCUDA_BUFFER_SIZE_T len; | ||
- if (PyObject_AsCharBuffer(buffer.ptr(), &mod_buf, &len)) | ||
+ Py_buffer py_buf; | ||
+ if (PyObject_GetBuffer(buffer.ptr(), &py_buf, PyBUF_ANY_CONTIGUOUS)) | ||
throw py::error_already_set(); | ||
CUmodule mod; | ||
|
||
@@ -387,10 +387,12 @@ | ||
|
||
CUDAPP_PRINT_CALL_TRACE("cuModuleLoadDataEx"); | ||
CUresult cu_status_code; \ | ||
- cu_status_code = cuModuleLoadDataEx(&mod, mod_buf, (unsigned int) options.size(), | ||
+ cu_status_code = cuModuleLoadDataEx(&mod, py_buf.buf, (unsigned int) options.size(), | ||
const_cast<CUjit_option *>(&*options.begin()), | ||
const_cast<void **>(&*option_values.begin())); | ||
|
||
+ PyBuffer_Release(&py_buf); | ||
+ | ||
size_t info_buf_size = size_t(option_values[1]); | ||
size_t error_buf_size = size_t(option_values[3]); | ||
|
||
@@ -407,7 +409,8 @@ | ||
throw pycuda::error("module_from_buffer", CUDA_ERROR_INVALID_VALUE, | ||
"non-empty options argument only supported on CUDA 2.1 and newer"); | ||
|
||
- CUDAPP_CALL_GUARDED(cuModuleLoadData, (&mod, mod_buf)); | ||
+ CUDAPP_CALL_GUARDED(cuModuleLoadData, (&mod, py_buf.buf)); | ||
+ PyBuffer_Release(&py_buf) | ||
#endif | ||
|
||
return new module(mod); | ||
@@ -500,16 +503,16 @@ | ||
|
||
void add_data(py::object py_data, CUjitInputType input_type, py::str py_name) | ||
{ | ||
- const char *data_buf; | ||
+ Py_buffer py_buf; | ||
PYCUDA_BUFFER_SIZE_T data_buf_len; | ||
- if (PyObject_AsCharBuffer(py_data.ptr(), &data_buf, &data_buf_len) != 0) { | ||
+ if (PyObject_GetBuffer(py_data.ptr(), &py_buf, PyBUF_ANY_CONTIGUOUS)) { | ||
throw py::error_already_set(); | ||
} | ||
const char* name = (py_name.ptr() != Py_None)? | ||
py::extract<const char*>(py_name) : NULL; | ||
- const CUresult cu_result = cuLinkAddData(m_link_state, input_type, | ||
- static_cast<void *>(const_cast<char *>(data_buf)), | ||
- data_buf_len, name, 0, NULL, NULL); | ||
+ const CUresult cu_result = cuLinkAddData(m_link_state, input_type, py_buf.buf, | ||
+ py_buf.len, name, 0, NULL, NULL); | ||
+ PyBuffer_Release(&py_buf); | ||
check_cu_result("cuLinkAddData", cu_result); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,12 +26,13 @@ | |
|
||
Name: %{python3}-pycuda | ||
Version: 2024.1.2 | ||
Release: 1 | ||
Release: 2 | ||
URL: http://mathema.tician.de/software/pycuda | ||
Summary: Python3 wrapper CUDA | ||
License: MIT | ||
Group: Development/Libraries/Python | ||
Source0: https://files.pythonhosted.org/packages/source/p/pycuda/pycuda-%{version}.tar.gz | ||
Patch0: pycuda-py3.13.patch | ||
BuildRoot: %{_tmppath}/%{name}-%{version}-build | ||
Provides: %{python3}-pycuda | ||
|
||
|
@@ -62,17 +63,21 @@ if [ "${sha256}" != "d110b727cbea859da4b63e91b6fa1e9fc32c5bade02d89ff449975996e9 | |
exit 1 | ||
fi | ||
%setup -q -n pycuda-%{version} | ||
%patch -P 0 -p1 | ||
|
||
%build | ||
CUDA=/opt/cuda | ||
# get the python version number like "312" for 3.12: | ||
%define py_mm %(%{python3} -c 'import sys;print("%i%i" % sys.version_info[:2])') | ||
%{python3} ./configure.py \ | ||
--cuda-enable-gl \ | ||
--cuda-root=$CUDA \ | ||
--cudadrv-lib-dir=%{_libdir} \ | ||
--boost-inc-dir=%{_includedir} \ | ||
--boost-lib-dir=%{_libdir} \ | ||
--no-use-shipped-boost \ | ||
--boost-python-libname=boost_python%{py_mm} \ | ||
--no-cuda-enable-curand | ||
# --boost-python-libname=boost_python37 | ||
# --boost-thread-libname=boost_thread | ||
LDFLAGS=-L$CUDA/%{STUBS_DIR} CXXFLAGS=-L$CUDA/%{STUBS_DIR} %{python3} setup.py build | ||
#make | ||
|
@@ -92,6 +97,10 @@ rm -rf %{buildroot} | |
%{python3_sitearch}/pycuda* | ||
|
||
%changelog | ||
* Fri Aug 16 2024 Antoine Martin <[email protected]> - 2024.1.2-2 | ||
- link against the system boost-python library | ||
- add patch for Python 3.13 compatibility: new buffer interface | ||
|
||
* Tue Jul 30 2024 Antoine Martin <[email protected]> - 2024.1.2-1 | ||
- new upstream release | ||
|
||
|