<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hello.
<br>
<br>
I have compiled PyOpenCL for my fc21 computer. My computer has an
Ivy Bridge chipset and fc21 sports Beignet version 0.9.2-2.fc21. I
am having trouble with a simple program that computes sums. This is
the program listing:
<br>
<br>
import pyopencl as cl
<br>
import numpy
<br>
import sys
<br>
import time
<br>
<br>
class CL(object):
<br>
def __init__(self, size=10):
<br>
self.size = size
<br>
self.ctx = cl.create_some_context()
<br>
self.queue = cl.CommandQueue(self.ctx)
<br>
<br>
def load_program(self):
<br>
fstr="""
<br>
__kernel void part1(__global float* a, __global float* b,
__global float* c)
<br>
{
<br>
unsigned int i = get_global_id(0);
<br>
<br>
c[i] = a[i] + b[i];
<br>
}
<br>
"""
<br>
self.program = cl.Program(self.ctx, fstr).build()
<br>
<br>
def popCorn(self):
<br>
mf = cl.mem_flags
<br>
<br>
self.a = numpy.array(range(self.size), dtype=numpy.float32)
<br>
self.b = numpy.array(range(self.size), dtype=numpy.float32)
<br>
<br>
self.a_buf = cl.Buffer(self.ctx, mf.READ_ONLY |
mf.COPY_HOST_PTR,
<br>
hostbuf=self.a)
<br>
self.b_buf = cl.Buffer(self.ctx, mf.READ_ONLY |
mf.COPY_HOST_PTR,
<br>
hostbuf=self.b)
<br>
self.dest_buf = cl.Buffer(self.ctx, mf.WRITE_ONLY,
self.b.nbytes)
<br>
<br>
def execute(self):
<br>
self.program.part1(self.queue, self.a.shape, None,
self.a_buf, self.b_buf, self.dest_buf)
<br>
c = numpy.empty_like(self.a)
<br>
cl.enqueue_read_buffer(self.queue, self.dest_buf, c).wait()
<br>
print ( "a", self.a)
<br>
print ( "b", self.b)
<br>
print ( "c", c )
<br>
<br>
def add(s=10) :
<br>
starttime = time.clock()
<br>
matrixmul = CL(s)
<br>
matrixmul.load_program()
<br>
matrixmul.popCorn()
<br>
matrixmul.execute()
<br>
endtime = time.clock()
<br>
print s, endtime - starttime
<br>
<br>
if __name__ == '__main__':
<br>
add(1)
<br>
add(2)
<br>
add(3)
<br>
<br>
<br>
This is the error I get when I run the program:
<br>
<br>
[dave@localhost awesome-test]$ ./arrays_opencl.py
<br>
Traceback (most recent call last):
<br>
File "./arrays_opencl.py", line 3, in <module>
<br>
import pyopencl as cl
<br>
File "<i class="moz-txt-slash"><span class="moz-txt-tag">/</span>usr/lib64/python2.7/site-packages/pyopencl-2014.1-py2.7-linux-x86_64.egg/pyopencl<span
class="moz-txt-tag">/</span></i>__init__.py", line 28, in
<module>
<br>
import pyopencl._cl as _cl
<br>
ImportError: libMesaOpenCL.so.1: cannot open shared object file: No
such file or directory
<br>
<br>
NOTE: I do not have libMesaOpenCL on this computer. I uninstalled it
and then re-installed pyopencl when I fedup'd to fc21. In fc20
Beignet worked correctly.
<br>
<br>
also for the record, this is the configuration line that I used when
installing pyopencl:
<br>
<br>
[dave@localhost awesome-test]$ ./configure.py
--cl-lib-dir=/usr/lib64/beignet --cl-libname=cl
</body>
</html>