예제 #1
0
파일: testext.c 프로젝트: uarka/gawk
static awk_value_t *
test_array_param(int nargs, awk_value_t *result)
{
	awk_value_t new_array;
	awk_value_t arg0;

	(void) nargs;		/* silence warnings */
	make_number(0.0, result);

	if (! get_argument(0, AWK_UNDEFINED, & arg0)) {
		printf("test_array_param: could not get argument\n");
		goto out;
	}

	if (arg0.val_type != AWK_UNDEFINED) {
		printf("test_array_param: argument is not undefined (%d)\n",
				arg0.val_type);
		goto out;
	}

	fill_in_array(& new_array);
	if (! set_argument(0, new_array.array_cookie)) {
		printf("test_array_param: could not change type of argument\n");
		goto out;
	}

	make_number(1.0, result);
out:
	return result;	/* for now */
}
예제 #2
0
/*
 * Default kernel arguments
 * arg0:
 *     input,   __read_only image2d_t
 * arg1:
 *     output,  __write_only image2d_t
 * suppose cl can get width/height pixels from
 * get_image_width/get_image_height
 */
XCamReturn
CLImageKernel::pre_execute (SmartPtr<DrmBoBuffer> &input, SmartPtr<DrmBoBuffer> &output)
{
    XCamReturn ret = XCAM_RETURN_NO_ERROR;
    SmartPtr<CLContext> context = get_context ();
#define XCAM_CL_MAX_ARGS 256
    CLArgument args[XCAM_CL_MAX_ARGS];
    uint32_t arg_count = XCAM_CL_MAX_ARGS;
    CLWorkSize work_size;

    ret = prepare_arguments (input, output, args, arg_count, work_size);

    XCAM_ASSERT (arg_count);
    for (uint32_t i = 0; i < arg_count; ++i) {
        ret = set_argument (i, args[i].arg_adress, args[i].arg_size);
        XCAM_FAIL_RETURN (
            WARNING,
            ret == XCAM_RETURN_NO_ERROR,
            ret,
            "cl image kernel(%s) set argc(%d) failed", get_kernel_name (), i);
    }

    XCAM_ASSERT (work_size.global[0]);
    ret = set_work_size (work_size.dim, work_size.global, work_size.local);
    XCAM_FAIL_RETURN (
        WARNING,
        ret == XCAM_RETURN_NO_ERROR,
        ret,
        "cl image kernel(%s) set work size failed", get_kernel_name ());

    return XCAM_RETURN_NO_ERROR;
}
예제 #3
0
XCamReturn
CLKernel::set_arguments (const CLArgList &args, const CLWorkSize &work_size)
{
    XCamReturn ret = XCAM_RETURN_NO_ERROR;
    uint32_t i_count = 0;

    XCAM_FAIL_RETURN (
        ERROR, _arg_list.empty (), XCAM_RETURN_ERROR_PARAM,
        "cl image kernel(%s) arguments was already set, can NOT be set twice", get_kernel_name ());

    for (CLArgList::const_iterator iter = args.begin (); iter != args.end (); ++iter, ++i_count) {
        const SmartPtr<CLArgument> &arg = *iter;
        XCAM_FAIL_RETURN (
            WARNING, arg.ptr (),
            XCAM_RETURN_ERROR_PARAM, "cl image kernel(%s) argc(%d) is NULL", get_kernel_name (), i_count);

        void *adress = NULL;
        uint32_t size = 0;
        arg->get_value (adress, size);
        ret = set_argument (i_count, adress, size);
        XCAM_FAIL_RETURN (
            WARNING, ret == XCAM_RETURN_NO_ERROR,
            ret, "cl image kernel(%s) set argc(%d) failed", get_kernel_name (), i_count);
    }

    ret = set_work_size (work_size);
    XCAM_FAIL_RETURN (
        WARNING, ret == XCAM_RETURN_NO_ERROR, ret,
        "cl image kernel(%s) set worksize(global:%dx%dx%d, local:%dx%dx%d) failed",
        XCAM_STR(get_kernel_name ()),
        (int)work_size.global[0], (int)work_size.global[1], (int)work_size.global[2],
        (int)work_size.local[0], (int)work_size.local[1], (int)work_size.local[2]);

    _arg_list = args;
    return ret;
}
예제 #4
0
//-----------------------------------------------------------------------------
void kernel::set_argument( uint32_t arg_index, const generic_sampler* sampler_ptr )
{
    cl_sampler samp = (reinterpret_cast<const sampler*>( sampler_ptr ))->get_id();
    //std::cerr << "arg sampler: " << (void*) samp << std::endl;
    set_argument( arg_index, sizeof(cl_sampler), &samp );
}
예제 #5
0
//-----------------------------------------------------------------------------
void kernel::set_argument( uint32_t arg_index, const generic_image* image_ptr )
{
    cl_mem mem = (reinterpret_cast<const image*>( image_ptr ))->get_id();
    //std::cerr << "arg image: " << (void*) mem << std::endl;
    set_argument( arg_index, sizeof(cl_mem), &mem );
}
예제 #6
0
int parse_script_section(char *combuf, char *arg1buf, char *arg2buf, ffscript **script, int com, int &retcode)
{
    (*script)[com].arg1 = 0;
    (*script)[com].arg2 = 0;
    bool found_command=false;
    
    for(int i=0; i<NUMCOMMANDS&&!found_command; ++i)
    {
        if(strcmp(combuf,command_list[i].name)==0)
        {
            found_command=true;
            (*script)[com].command = i;
            
            if(((strnicmp(combuf,"GOTO",4)==0)||(strnicmp(combuf,"LOOP",4)==0)) && stricmp(combuf, "GOTOR"))
            {
                bool nomatch = true;
                
                for(int j=0; j<numlines; j++)
                {
                    if(stricmp(arg1buf,labels[j])==0)
                    {
                        (*script)[com].arg1 = lines[j];
                        nomatch = false;
                        j=numlines;
                    }
                }
                
                if(nomatch)
                {
                    (*script)[com].arg1 = atoi(arg1buf)-1;
                }
                
                if(strnicmp(combuf,"LOOP",4)==0)
                {
                    if(command_list[i].arg2_type==1)  //this should NEVER happen with a loop, as arg2 needs to be a variable
                    {
                        if(!ffcheck(arg2buf))
                        {
                            retcode=ERR_PARAM2;
                            return 0;
                        }
                        
                        (*script)[com].arg2 = ffparse(arg2buf);
                    }
                    else
                    {
                        if(!set_argument(arg2buf, script, com, 1))
                        {
                            retcode=ERR_PARAM2;
                            return 0;
                        }
                    }
                }
            }
            else
            {
                if(command_list[i].args>0)
                {
                    if(command_list[i].arg1_type==1)
                    {
                        if(!ffcheck(arg1buf))
                        {
                            retcode=ERR_PARAM1;
                            return 0;
                        }
                        
                        (*script)[com].arg1 = ffparse(arg1buf);
                    }
                    else
                    {
                        if(!set_argument(arg1buf, script, com, 0))
                        {
                            retcode=ERR_PARAM1;
                            return 0;
                        }
                    }
                    
                    if(command_list[i].args>1)
                    {
                        if(command_list[i].arg2_type==1)
                        {
                            if(!ffcheck(arg2buf))
                            {
                                retcode=ERR_PARAM2;
                                return 0;
                            }
                            
                            (*script)[com].arg2 = ffparse(arg2buf);
                        }
                        else
                        {
                            if(!set_argument(arg2buf, script, com, 1))
                            {
                                retcode=ERR_PARAM2;
                                return 0;
                            }
                        }
                    }
                }
            }
        }
    }
    
    if(found_command)
    {
        return 1;
    }
    
    retcode=ERR_INSTRUCTION;
    return 0;
}
	void set_argument(int idx, T *arg) {
		set_argument(idx, sizeof(T), (void *)arg);
	}
예제 #8
0
파일: main.cpp 프로젝트: CCJY/coliru
 Test(HeadArg&& head, TailArgs&&... tail) : 
     Test(std::forward<TailArgs>(tail)...)
 {
     std::cout << "Test( " << typeid(head).name() << ", ... )\n";
     set_argument(head);
 }