Example #1
0
int main()
{
	srand(0);

	init_GP();
	init_pop();

	oclInit();
	oclBuffer();

//	size_t ws, ls;
//	clGetKernelWorkGroupInfo(clKernel1, clDeviceId, CL_KERNEL_WORK_GROUP_SIZE, sizeof(ws), (void *) &ws, NULL);
//	printf("CL_KERNEL_WORK_GROUP_SIZE is: %i \n", ws);
//	clGetKernelWorkGroupInfo(clKernel1, clDeviceId, CL_KERNEL_LOCAL_MEM_SIZE , sizeof(ls), (void *) &ls, NULL);
//	printf("CL_KERNEL_LOCAL_MEM_SIZE is: %i \n", ls);

	fitness_func();
	ocl_fitness_func();

	for (int i=0; i<POP_SIZE; i++)
	{
		if (fitness_cpu[i] != fitness_gpu[i])
			printf("mismatch at i = %i \n", i);
		printf("fitness_gpu[%i] = %i, fitness_cpu[%i] = %i \n", i, fitness_gpu[i], i, fitness_cpu[i]);
	}
	for (int i=1; i<GENERATION; i++)
	{
		//printf("hello \n");
		next_gen();
		fitness_func();
		ocl_fitness_func();
		gen_per(i);
	}
	oclClean();
	test_gp();
	printResult();

	return 0;
}
Example #2
0
int main(int argc, char* argv[])
#endif
{
    // libCL requires a root path to find the .cl files	
    oclInit("../"); 

    // find the first available platform
    oclContext* lContext = oclContext::create(
                                              oclContext::VENDOR_NVIDIA, 
                                              CL_DEVICE_TYPE_GPU);
    if (!lContext)
    {
        lContext = oclContext::create(
                                      oclContext::VENDOR_AMD, 
                                      CL_DEVICE_TYPE_GPU);
        if (!lContext)
        {
            lContext = oclContext::create(
                                          oclContext::VENDOR_INTEL, 
                                          CL_DEVICE_TYPE_CPU);
            if (!lContext)
            {
                lContext = oclContext::create(
                                              oclContext::VENDOR_AMD, 
                                              CL_DEVICE_TYPE_CPU);
            }
        }
    }


    if (!lContext)
    {
        Log(ERR) << "no OpenCL capable platform detected";
        return -1; 
    }
    else 
    {
        Log(INFO) << "\n*\n*\n*" <<
            "Running LibCL 1.0 using vendor platform: " << 
            lContext->getName() << "\n*\n*";
    }
    Log(INFO) << "\n\n";

    // run tests
    Log(INFO) << "****** calling radix sort ...";
    testRadixSort(*lContext);
    Log(INFO) << "****** done\n";

    Log(INFO) << "****** calling fluid test 0 ...";
    testFluid3D0(*lContext);
    Log(INFO) << "****** done\n";

    Log(INFO) << "****** calling fluid test 1 ...";
    testFluid3D1(*lContext);
    Log(INFO) << "****** done\n";

#ifdef WIN32
    // ignore test to avoid crash
    Log(INFO) << "****** calling BVH construction ...";
    testBvhTrimesh(*lContext);
    Log(INFO) << "****** done\n";
#endif

    Log(INFO) << "****** compiling all ...";
    testCompile(*lContext);
    Log(INFO) << "****** done\n";

    return 0;
}