clray

diff src/ocl.cc @ 14:29f9330cfa4b

trying to debug the bloody thing
author John Tsiombikas
date Sat, 07 Aug 2010 03:36:36 +0100
parents 407935b73af3
children 97cfd9675310
line diff
     1.1 --- a/src/ocl.cc	Wed Aug 04 04:51:06 2010 +0100
     1.2 +++ b/src/ocl.cc	Sat Aug 07 03:36:36 2010 +0100
     1.3 @@ -156,6 +156,12 @@
     1.4  }
     1.5  
     1.6  
     1.7 +CLArg::CLArg()
     1.8 +{
     1.9 +	memset(this, 0, sizeof *this);
    1.10 +}
    1.11 +
    1.12 +
    1.13  CLProgram::CLProgram(const char *kname)
    1.14  {
    1.15  	prog = 0;
    1.16 @@ -242,7 +248,8 @@
    1.17  	printf("create argument %d buffer: %d bytes\n", idx, (int)sz);
    1.18  	CLMemBuffer *buf;
    1.19  
    1.20 -	if(!(buf = create_mem_buffer(rdwr, sz, ptr))) {
    1.21 +	if(sz <= 0 || !(buf = create_mem_buffer(rdwr, sz, ptr))) {
    1.22 +		fprintf(stderr, "invalid size while creating argument buffer %d: %d\n", idx, (int)sz);
    1.23  		return false;
    1.24  	}
    1.25  
    1.26 @@ -262,6 +269,17 @@
    1.27  	return args[arg].v.mbuf;
    1.28  }
    1.29  
    1.30 +int CLProgram::get_num_args() const
    1.31 +{
    1.32 +	int num_args = 0;
    1.33 +	for(size_t i=0; i<args.size(); i++) {
    1.34 +		if(args[i].type != ARGTYPE_NONE) {
    1.35 +			num_args++;
    1.36 +		}
    1.37 +	}
    1.38 +	return num_args;
    1.39 +}
    1.40 +
    1.41  bool CLProgram::build()
    1.42  {
    1.43  	int err;