[Beignet] CL_MEM_USE_HOST_PTR usage in clCreateBuffer API
Edward Ching
edward.k.ching at gmail.com
Tue Jul 23 01:54:25 PDT 2013
I tried the CL_MEM_USE_HOST_PTR option from one of the recent Beignet
checkins using a simple test case but it failed. Did I misunderstand the
usage of CL_MEM_USE_HOST_TR? Same test cased worked OK when using Intel
OpenCL SDK 2012 (Windows) for IVB. The test case patch is attached and also
cut n pasted here.
/Ed
1) test_zcopy.cl:
__kernel void
test_zcopy(__global int *src, __global int *dst, int n, int num_threads)
{
int tid, pos;
tid = get_global_id(0);
for (pos=tid; pos < n; pos+=num_threads) {
dst[pos] = src[pos];
}
}
2) compiler_zcopy.cpp:
#include "utest_helper.hpp"
#include <sys/time.h>
#include <malloc.h>
#include <string.h>
#define T_GET(t) gettimeofday(&t, NULL);
#define T_LAPSE(t1, t2) \
((t2.tv_sec+t2.tv_usec*0.000001) - (t1.tv_sec+t1.tv_usec*0.000001))
#define ALIGN 4096
static void compiler_zcopy(void)
{
const size_t n = 32*1024*1024;
struct timeval t1, t2;
float t_fin;
int *in, *out;
in = (int *)memalign(ALIGN, n*sizeof(int));
out = (int *)memalign(ALIGN, n*sizeof(int));
OCL_ASSERT(in);
OCL_ASSERT(out);
for (int i=0; i<n; ++i) in[i] = i;
bzero(out, n);
// Setup kernel and buffers
OCL_CREATE_KERNEL("test_zcopy");
OCL_CREATE_BUFFER(buf[0], CL_MEM_USE_HOST_PTR, n * sizeof(int), in);
OCL_CREATE_BUFFER(buf[1], CL_MEM_USE_HOST_PTR, n * sizeof(int), out);
// Run the kernel
locals[0] = 64;
globals[0] = 32 * locals[0];
OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]);
OCL_SET_ARG(1, sizeof(cl_mem), &buf[1]);
OCL_SET_ARG(2, sizeof(int), &n);
OCL_SET_ARG(3, sizeof(int), &globals[0]);
T_GET(t1);
OCL_NDRANGE(1);
OCL_FINISH();
T_GET(t2);
t_fin = T_LAPSE(t1, t2);
printf("test_zcopy: lapse = %f\n",t_fin);
for (int i=0; i<n; ++i) OCL_ASSERT((out[i]==i));
}
MAKE_UTEST_FROM_FUNCTION(compiler_zcopy);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/beignet/attachments/20130723/ccfdc43d/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Test-CL_USE_HOST_PTR.patch
Type: application/octet-stream
Size: 2673 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/beignet/attachments/20130723/ccfdc43d/attachment-0001.obj>
More information about the Beignet
mailing list