I'm running into a problme with Ocelot, the MonetDB with OpenCL extension. I apologize if this is not the right forum to post.

I'm seeing a query failure which was caused by MoneDB-OpenCL trying to cache an empty BAT and ended up calling clCreateBuffer with a 0 size buffer and failed. Any select with a where clause would trigger it. 

Has anyone seen this too? It fails whether I use 32 bit or 64 bit oid, Nvidia or AMD. I'm trying to figure if it's a real issue or if I'm missing anything. Any input greatly appreciated.

The database was generated by TPC-H dbgen (details below). The query I used was "select c_custkey, c_name from customer where c_custkey < 2", and here's a trace of the sequence of calls leading to the failure starting from the MAL statement:

1) X_52 := ocelot.thetasubselect(r1_10,A0,"<",0);(see log below)

2) ocl_select.c::ocl_subselect() line 142: ocl_cacheBAT

3) ocl_memmanager.c::ocl_cacheBAT() line 771: allocateBuffer

4) ocl_memmanager.c::allocateBuffer() line 432: clCreateBuffer

===== Source version and environment =====

1) Ocelot src installed from zip downloaded from monetdb-opencl:

msaecker-monetdb-opencl-b513b35eb84a.zip

2) Ocelot configure options:

./configure --prefix=/usr/local --enable-oid32 --enable-optimize --disable-test

ing --disable-developer --disable-debug --disable-assert --enable-sql --enable-m

onetdb5 --with-opencl=/usr

3) Operating System: Fedora 17 kernel 3.9.10-100

4) Hardware: NVIDIA GTX570 on Intel i7-3820 w/ 16GB mem

5) OpenCL: Nvidia OpenCL that came with CUDA 5.5 SDK

6) Database: generated w/ TPC-H dbgen using size factor s=0.01

===== operation log follows =====

[root@gen3-2 ocelot]# mclient -ddb001 -lmal

mal>ocelot.init();

mal>ocelot.listDevices();

# Device 0: NVIDIA Corporation - GeForce GTX 570 (default device)

mal>\q

[root@gen3-2 ocelot]# mclient -ddb001 -lsql

sql>\d

TABLE sys.customer

TABLE sys.lineitem

TABLE sys.nation

TABLE sys.orders

TABLE sys.part

TABLE sys.partsupp

TABLE sys.region

TABLE sys.supplier

sql>\d customer

CREATE TABLE "sys"."customer" (

"c_custkey" INTEGER NOT NULL,

"c_name" VARCHAR(25) NOT NULL,

"c_address" VARCHAR(40) NOT NULL,

"c_nationkey" INTEGER NOT NULL,

"c_phone" VARCHAR(15) NOT NULL,

"c_acctbal" DECIMAL(15,2) NOT NULL,

"c_mktsegment" VARCHAR(10) NOT NULL,

"c_comment" VARCHAR(117) NOT NULL,

CONSTRAINT "customer_c_custkey_pkey" PRIMARY KEY ("c_custkey"),

CONSTRAINT "customer_c_nationkey_fkey" FOREIGN KEY ("c_nationkey") REFERENCES "sys"."nation" ("n_nationkey")

);

sql>select count(*) from customer;

+------+

| L1 |

+======+

| 1500 |

+------+

1 tuple (1.311ms)

sql>select c_custkey, c_name from customer where c_custkey < 2;

+-----------+--------------------+

| c_custkey | c_name |

+===========+====================+

| 1 | Customer#000000001 |

+-----------+--------------------+

1 tuple (1.776ms)

sql>set optimizer='cl_pipe';

operation successful (0.981ms)

sql>select c_custkey, c_name from customer where c_custkey < 2;

invalid/unknown response from server, ignoring output

? #Could not allocate OpenCL buffer of size: 0.

Error caching input BAT.

sql>

sql>explain select c_custkey, c_name from customer where c_custkey < 2;

+------------------------------------------------------------------------------+

| mal

+==============================================================================+

| function user.s9_1{autoCommit=true}(A0:int):void; |

| ocelot.beginQuery(); |

| X_3 := sql.mvc(); |

| X_7 := sql.bind(X_3,"sys","customer","c_custkey",0); |

| X_4:bat[:oid,:oid] := sql.tid(X_3,"sys","customer"); |

| X_51 := ocelot.thetasubselect(X_7,X_4,A0,"<",0); |

| (X_10,r1_10) := sql.bind(X_3,"sys","customer","c_custkey",2); |

| X_52 := ocelot.thetasubselect(r1_10,A0,"<",0); |

| X_13 := sql.bind(X_3,"sys","customer","c_custkey",1); |

| X_53 := ocelot.thetasubselect(X_13,X_4,A0,"<",0); |

| ocelot.sync(X_51); |

| ocelot.sync(X_52); |

| ocelot.sync(X_53); |

| X_15 := sql.subdelta(X_51,X_4,X_10,X_52,X_53); |

| X_17 := sql.projectdelta(X_15,X_7,X_10,r1_10,X_13); |

| X_18 := sql.bind(X_3,"sys","customer","c_name",0); |

| (X_20,r1_23) := sql.bind(X_3,"sys","customer","c_name",2); |

| X_22 := sql.bind(X_3,"sys","customer","c_name",1); |

| X_23 := sql.projectdelta(X_15,X_18,X_20,r1_23,X_22); |

| X_24 := sql.resultSet(2,1,X_17); |

| sql.rsColumn(X_24,"sys.customer","c_custkey","int",32,0,X_17); |

| sql.rsColumn(X_24,"sys.customer","c_name","varchar",25,0,X_23); |

| X_32 := io.stdout(); |

| sql.exportResult(X_32,X_24); |

| ocelot.endQuery(); |

| end s9_1; |

| # querylog.define("explain select c_custkey, c_name from customer where c_cu |

: stkey < 2;","cl_pipe") :

+------------------------------------------------------------------------------+

27 tuples (1.408ms)

sql>

=======================================