[Beignet] [hpc12/tools] build of 'sum' on 'Intel(R) HD Graphics IvyBridge M GT2' failed

David Liebman david.c.liebman at gmail.com
Fri Aug 29 18:08:24 PDT 2014


On Aug 29, 2014 8:26 PM, "Zhigang Gong" <zhigang.gong at gmail.com> wrote:
>
> I guess you may only change the kernel. Please also replace all the
double with float in the cl-demo.c.Then rebuild and run it again. I just
tried, and it works well.
>
>
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet
>
How about this program? It has no double. C always prints zero.  It's
pyopencl.

import pyopencl as cl
import numpy
import sys
import time

class CL(object):
    def __init__(self, size=10):
        self.size = size
        self.ctx = cl.create_some_context()
        self.queue = cl.CommandQueue(self.ctx)

    def load_program(self):
        fstr="""
        __kernel void part1(__global float* a, __global float* b, __global
float* c)
        {
            unsigned int i = get_global_id(0);

           c[i] = a[i] + b[i];
        }
         """
        self.program = cl.Program(self.ctx, fstr).build()

    def popCorn(self):
        mf = cl.mem_flags

        self.a = numpy.array(range(self.size), dtype=numpy.float32)
        self.b = numpy.array(range(self.size), dtype=numpy.float32)

        self.a_buf = cl.Buffer(self.ctx, mf.READ_ONLY | mf.COPY_HOST_PTR,
                               hostbuf=self.a)
        self.b_buf = cl.Buffer(self.ctx, mf.READ_ONLY | mf.COPY_HOST_PTR,
                               hostbuf=self.b)
        self.dest_buf = cl.Buffer(self.ctx, mf.WRITE_ONLY, self.b.nbytes)

    def execute(self):
        self.program.part1(self.queue, self.a.shape, None, self.a_buf,
self.b_buf, self.dest_buf)
        c = numpy.empty_like(self.a)
        cl.enqueue_read_buffer(self.queue, self.dest_buf, c).wait()
        print ( "a", self.a)
        print ( "b", self.b)
        print ( "c", c )

def add(s=10) :
    starttime = time.clock()
    matrixmul = CL(s)
    matrixmul.load_program()
    matrixmul.popCorn()
    matrixmul.execute()
    endtime = time.clock()
    print s, endtime - starttime

if __name__ == '__main__':
        #add(1)
        #add(2)
        #add(3)
        #add(4)
        #add(5)
        add(50)
        add(500)
        add(5000)
        add(50000)
        add(500000)

        #add(10000000)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/beignet/attachments/20140829/df968f7f/attachment.html>


More information about the Beignet mailing list