opencl4py
=========
Python cffi OpenCL bindings and helper classes.
Tested with Python 2.7, Python 3.3, Python 3.4 and PyPy on Linux and Windows.
Covered OpenCL API:
```
clBuildProgram
clCreateBuffer
clCreateCommandQueue
clCreateCommandQueueWithProperties
clCreateContext
clCreateKernel
clCreatePipe
clCreateProgramWithSource
clCreateProgramWithBinary
clCreateSubBuffer
clEnqueueCopyBuffer
clEnqueueCopyBufferRect
clEnqueueFillBuffer
clEnqueueMapBuffer
clEnqueueNDRangeKernel
clEnqueueReadBuffer
clEnqueueSVMMap
clEnqueueSVMMemcpy
clEnqueueSVMMemFill
clEnqueueSVMUnmap
clEnqueueUnmapMemObject
clEnqueueWriteBuffer
clFinish
clFlush
clGetDeviceIDs
clGetDeviceInfo
clGetEventProfilingInfo
clGetKernelInfo
clGetKernelWorkGroupInfo
clGetPlatformIDs
clGetPlatformInfo
clGetProgramInfo
clGetProgramBuildInfo
clReleaseCommandQueue
clReleaseContext
clReleaseEvent
clReleaseKernel
clReleaseMemObject
clReleaseProgram
clSetKernelArg
clSetKernelArgSVMPointer
clSVMAlloc
clSVMFree
clWaitForEvents
```
To install the module run:
```bash
pip install .
```
or just copy src/opencl4py to any place where python
interpreter will be able to find it.
To run the tests, execute:
for Python 2.7:
```bash
PYTHONPATH=src nosetests -w tests
```
for Python 3.3, 3.4:
```bash
PYTHONPATH=src nosetests3 -w tests
```
for PyPy:
```bash
PYTHONPATH=src pypy tests/test_api.py
```
Currently, PyPy numpy support may be incomplete,
so tests which use numpy arrays may fail.
Example usage:
```python
import opencl4py as cl
import logging
import numpy
if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG)
platforms = cl.Platforms()
logging.info("OpenCL devices available:\n\n%s\n",
platforms.dump_devices())
ctx = platforms.create_some_context()
queue = ctx.create_queue(ctx.devices[0])
prg = ctx.create_program(
"""
__kernel void test(__global const float *a, __global const float *b,
__global float *c, const float k) {
size_t i = get_global_id(0);
c[i] = (a[i] + b[i]) * k;
}
""")
krn = prg.get_kernel("test")
a = numpy.arange(1000000, dtype=numpy.float32)
b = numpy.arange(1000000, dtype=numpy.float32)
c = numpy.empty(1000000, dtype=numpy.float32)
k = numpy.array([0.5], dtype=numpy.float32)
a_buf = ctx.create_buffer(cl.CL_MEM_READ_ONLY | cl.CL_MEM_COPY_HOST_PTR,
a)
b_buf = ctx.create_buffer(cl.CL_MEM_READ_ONLY | cl.CL_MEM_COPY_HOST_PTR,
b)
c_buf = ctx.create_buffer(cl.CL_MEM_WRITE_ONLY | cl.CL_MEM_ALLOC_HOST_PTR,
size=c.nbytes)
krn.set_arg(0, a_buf)
krn.set_arg(1, b_buf)
krn.set_arg(2, c_buf)
krn.set_arg(3, k[0:1])
queue.execute_kernel(krn, [a.size], None)
queue.read_buffer(c_buf, c)
max_diff = numpy.fabs(c - (a + b) * k[0]).max()
logging.info("max_diff = %.6f", max_diff)
```
Released under Simplified BSD License.
Copyright (c) 2014, Samsung Electronics Co.,Ltd.
=========
Python cffi OpenCL bindings and helper classes.
Tested with Python 2.7, Python 3.3, Python 3.4 and PyPy on Linux and Windows.
Covered OpenCL API:
```
clBuildProgram
clCreateBuffer
clCreateCommandQueue
clCreateCommandQueueWithProperties
clCreateContext
clCreateKernel
clCreatePipe
clCreateProgramWithSource
clCreateProgramWithBinary
clCreateSubBuffer
clEnqueueCopyBuffer
clEnqueueCopyBufferRect
clEnqueueFillBuffer
clEnqueueMapBuffer
clEnqueueNDRangeKernel
clEnqueueReadBuffer
clEnqueueSVMMap
clEnqueueSVMMemcpy
clEnqueueSVMMemFill
clEnqueueSVMUnmap
clEnqueueUnmapMemObject
clEnqueueWriteBuffer
clFinish
clFlush
clGetDeviceIDs
clGetDeviceInfo
clGetEventProfilingInfo
clGetKernelInfo
clGetKernelWorkGroupInfo
clGetPlatformIDs
clGetPlatformInfo
clGetProgramInfo
clGetProgramBuildInfo
clReleaseCommandQueue
clReleaseContext
clReleaseEvent
clReleaseKernel
clReleaseMemObject
clReleaseProgram
clSetKernelArg
clSetKernelArgSVMPointer
clSVMAlloc
clSVMFree
clWaitForEvents
```
To install the module run:
```bash
pip install .
```
or just copy src/opencl4py to any place where python
interpreter will be able to find it.
To run the tests, execute:
for Python 2.7:
```bash
PYTHONPATH=src nosetests -w tests
```
for Python 3.3, 3.4:
```bash
PYTHONPATH=src nosetests3 -w tests
```
for PyPy:
```bash
PYTHONPATH=src pypy tests/test_api.py
```
Currently, PyPy numpy support may be incomplete,
so tests which use numpy arrays may fail.
Example usage:
```python
import opencl4py as cl
import logging
import numpy
if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG)
platforms = cl.Platforms()
logging.info("OpenCL devices available:\n\n%s\n",
platforms.dump_devices())
ctx = platforms.create_some_context()
queue = ctx.create_queue(ctx.devices[0])
prg = ctx.create_program(
"""
__kernel void test(__global const float *a, __global const float *b,
__global float *c, const float k) {
size_t i = get_global_id(0);
c[i] = (a[i] + b[i]) * k;
}
""")
krn = prg.get_kernel("test")
a = numpy.arange(1000000, dtype=numpy.float32)
b = numpy.arange(1000000, dtype=numpy.float32)
c = numpy.empty(1000000, dtype=numpy.float32)
k = numpy.array([0.5], dtype=numpy.float32)
a_buf = ctx.create_buffer(cl.CL_MEM_READ_ONLY | cl.CL_MEM_COPY_HOST_PTR,
a)
b_buf = ctx.create_buffer(cl.CL_MEM_READ_ONLY | cl.CL_MEM_COPY_HOST_PTR,
b)
c_buf = ctx.create_buffer(cl.CL_MEM_WRITE_ONLY | cl.CL_MEM_ALLOC_HOST_PTR,
size=c.nbytes)
krn.set_arg(0, a_buf)
krn.set_arg(1, b_buf)
krn.set_arg(2, c_buf)
krn.set_arg(3, k[0:1])
queue.execute_kernel(krn, [a.size], None)
queue.read_buffer(c_buf, c)
max_diff = numpy.fabs(c - (a + b) * k[0]).max()
logging.info("max_diff = %.6f", max_diff)
```
Released under Simplified BSD License.
Copyright (c) 2014, Samsung Electronics Co.,Ltd.
Metadata
Release files for opencl4py 1.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| opencl4py-1.5.1.tar.gz | 30.7 kB | Without provenance | Details |
Release files / opencl4py-1.5.1.tar.gz
| Download URL | opencl4py-1.5.1.tar.gz |
|---|---|
| Size | 30.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eea17700124bb3f244fc22b100817586316709f25ff04dbbec0b3ca0e7e4b696
|
|
BLAKE2b-256 checksum How to use checksums |
7be41fcb58a4040c19fa67abf66473019f030bb9c0ca7f81c970bf2c86f00bf7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for opencl4py 1.5.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.