Beispiel #1
0
void solve(void) {
    
    int     n  = gi();
    int     m1 = gi();
    IVector x  = gis();
    int     m2 = gi();
    IVector y  = gis();
    
    int i;
    IVector h = newIV(n + 1);
    IVector f = newIV(n + 1);
    IVector r = newIV(0);
    
    REP(i,m1) {
        h->value[x->value[i]] = 1;
    }
    
    REP(i,m2) {
        int t = y->value[i];
        if (h->value[t] == 0) f->value[t] = 1;
    }
Beispiel #2
0
generic_info
program::get_info(cl_uint param) const
{
    switch ((cl_program_info)param) {
    case CL_PROGRAM_CONTEXT:
        return pyopencl_get_opaque_info(context, Program, this, param);
    case CL_PROGRAM_REFERENCE_COUNT:
    case CL_PROGRAM_NUM_DEVICES:
        return pyopencl_get_int_info(cl_uint, Program, this, param);
    case CL_PROGRAM_DEVICES:
        return pyopencl_get_opaque_array_info(device, Program, this, param);
    case CL_PROGRAM_SOURCE:
        return pyopencl_get_str_info(Program, this, param);
    case CL_PROGRAM_BINARY_SIZES:
        return pyopencl_get_array_info(size_t, Program, this, param);
    case CL_PROGRAM_BINARIES: {
        auto sizes = pyopencl_get_vec_info(size_t, Program, this,
                                           CL_PROGRAM_BINARY_SIZES);
        pyopencl_buf<char*> result_ptrs(sizes.len());
        for (size_t i  = 0;i < sizes.len();i++) {
            result_ptrs[i] = (char*)malloc(sizes[i]);
        }
        try {
            pyopencl_call_guarded(clGetProgramInfo, this, CL_PROGRAM_BINARIES,
                                  sizes.len() * sizeof(char*),
                                  result_ptrs.get(), nullptr);
        } catch (...) {
            for (size_t i  = 0;i < sizes.len();i++) {
                free(result_ptrs[i]);
            }
        }
        pyopencl_buf<generic_info> gis(sizes.len());
        for (size_t i  = 0;i < sizes.len();i++) {
            gis[i].value = result_ptrs[i];
            gis[i].dontfree = 0;
            gis[i].opaque_class = CLASS_NONE;
            gis[i].type =  _copy_str(std::string("char[") +
                                     tostring(sizes[i]) + "]");
        }
        return pyopencl_convert_array_info(generic_info, gis);
    }

#if PYOPENCL_CL_VERSION >= 0x1020
    case CL_PROGRAM_NUM_KERNELS:
        return pyopencl_get_int_info(size_t, Program, this, param);
    case CL_PROGRAM_KERNEL_NAMES:
        return pyopencl_get_str_info(Program, this, param);
#endif
    default:
        throw clerror("Program.get_info", CL_INVALID_VALUE);
    }
}
Beispiel #3
0
IVVector ngis(int n) { IVVector r=newIVV(n); int i; for(i=0;i<n;i++)r->value[i]=gis(); return r; }