コード例 #1
0
ファイル: nompi.c プロジェクト: Aetet/labs
int
main (
	int		argc,
	char		*argv[]
) {
	int		i;
	int		speed_flag = 0;
	int		practice_flag = 0;
	unsigned long	p[64], c[64], k[56];

	set_bitlength ();

	for (i=1; i<argc; i++) {
	    if (argv[i][0] != '-')
		continue;

	    if (argv[i][1] == 'S')
		speed_flag = 1;
	    else if (argv[i][1] == 'P')
		practice_flag = 1;
	}

	build_samples (p, c, k, practice_flag);
	set_low_keys(k);
		
	if (speed_flag)
	    test_speed (p, c, k);
	else
	    keysearch (p, c, k);

	return 0;
}
コード例 #2
0
ファイル: Test.cpp プロジェクト: GHScan/DailyProjects
int main()
{
    srand((unsigned)time(NULL));

    EventListener eventReceiver;
    g_device = createDevice(
        video::EDT_DIRECT3D9, core::dimension2d<u32>(566, 310), 32, false, false, false, &eventReceiver);

    g_physicsWorld = Physics::IWorld::createSingleton();
    g_physicsWorld->addListener(Graphics::IWorld::createSingleton("3d", g_device));
    g_physicsWorld->addListener(Sound::IWorld::createSingleton());

    build_samples();

    video::IVideoDriver *d3d = g_device->getVideoDriver();
    scene::ISceneManager *sceneMgr = g_device->getSceneManager();
    while (g_device->run())
    {
        if (g_device->isWindowActive())
        {
            d3d->beginScene(true, true, video::SColor(255, 70, 163, 255));

            u32 nowTime = g_device->getTimer()->getTime();
            Physics::IWorld::getSingletonPtr()->update(nowTime);
            Graphics::IWorld::getSingletonPtr()->update(nowTime);

            sceneMgr->drawAll();
            d3d->endScene();
        }
        else Sleep(1);
    }

    
    g_physicsWorld->removeAllListener();

    Sound::IWorld::destroySingleton();
    Graphics::IWorld::destroySingleton();
    Physics::IWorld::destroySingleton();

    g_device->drop();
}
コード例 #3
0
ファイル: mpi.c プロジェクト: Aetet/labs
int main(int argc, char *argv[])
{
	int 	numprocs;
	int 	myid;
	int		i;
	int		speed_flag = 0;
	int		practice_flag = 0;
	unsigned long	p[64], c[64], k[56];

	MPI_Init(&argc,&argv);
	MPI_Comm_size(MPI_COMM_WORLD,&numprocs); 
	MPI_Comm_rank(MPI_COMM_WORLD,&myid); 
	set_bitlength ();

	for (i=1; i<argc; i++) {
		if (argv[i][0] != '-')
		continue;

		if (argv[i][1] == 'S')
		speed_flag = 1;
		else if (argv[i][1] == 'P')
		practice_flag = 1;
	}

	build_samples (p, c, k, practice_flag);
	set_low_keys(k);
	set_high_keys(k, numprocs, myid);
	MPI_Barrier(MPI_COMM_WORLD);
	double t=MPI_Wtime();
	if (speed_flag)
		test_speed (p, c, k);
	else
		if(keysearch (p, c, k)) MPI_Abort(MPI_COMM_WORLD, 0);
	MPI_Barrier(MPI_COMM_WORLD);
	double t2=MPI_Wtime();
	if(myid==0)printf("time:%f\nspeed:%f\n",t2-t, (double)numprocs*1000000/(t2-t));
	MPI_Finalize();
	return 0;
}
コード例 #4
0
ファイル: Test.cpp プロジェクト: GHScan/DailyProjects
    virtual bool OnEvent(const SEvent& evt)
    {
        switch (evt.EventType)
        {
        case EET_KEY_INPUT_EVENT:
            if (evt.KeyInput.PressedDown) break;
            switch (evt.KeyInput.Key)
            {
            case KEY_ESCAPE:
                g_device->closeDevice();
                return true;
            case KEY_KEY_2:
            case KEY_KEY_3:
                g_physicsWorld->removeListener(Graphics::IWorld::getSingletonPtr());
                Graphics::IWorld::destroySingleton();
                g_physicsWorld->addListener(
                Graphics::IWorld::createSingleton(
                    evt.KeyInput.Key == KEY_KEY_2 ? "2d" : "3d", g_device));
                return true;
            case KEY_KEY_P:
                g_physicsWorld->pause();
                break;
            case KEY_SPACE:
                g_physicsWorld->removeAllPrimitive();
                build_samples();
                break;
            default:
                break;
            }

            break;
        default:
            break;
        }
        return false;
    }
コード例 #5
0
ファイル: ocldes.cpp プロジェクト: radixvinni/labs
int main(int argc, char **argv)
{
    int	start,end;
    unsigned long	p[64], c[64], k[56];
    unsigned long	res;

    build_samples (p, c, k, 0);
    set_low_keys(k);

    cl_platform_id cpPlatform;
    clGetPlatformIDs(1, &cpPlatform, NULL);

    cl_device_id cdDevice;
    clGetDeviceIDs(cpPlatform, CL_DEVICE_TYPE_GPU, 1, &cdDevice, NULL);

    char cBuffer[1024];
    clGetDeviceInfo(cdDevice, CL_DEVICE_NAME, sizeof(cBuffer), &cBuffer, NULL);
    printf("CL_DEVICE_NAME:\t\t%s\n", cBuffer);
    clGetDeviceInfo(cdDevice, CL_DRIVER_VERSION, sizeof(cBuffer), &cBuffer, NULL);
    printf("CL_DRIVER_VERSION:\t%s\n\n", cBuffer);
    cl_uint compute_units;
    clGetDeviceInfo(cdDevice, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(compute_units), &compute_units, NULL);
    printf("CL_DEVICE_MAX_COMPUTE_UNITS:\t%u\n", compute_units);
    size_t workitem_dims;
    clGetDeviceInfo(cdDevice, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, sizeof(workitem_dims), &workitem_dims, NULL);
    printf("CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS:\t%u\n", workitem_dims);
    size_t workitem_size[3];
    clGetDeviceInfo(cdDevice, CL_DEVICE_MAX_WORK_ITEM_SIZES, sizeof(workitem_size), &workitem_size, NULL);
    printf("CL_DEVICE_MAX_WORK_ITEM_SIZES:\t%u / %u / %u \n", workitem_size[0], workitem_size[1], workitem_size[2]);
    size_t workgroup_size;
    clGetDeviceInfo(cdDevice, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(workgroup_size), &workgroup_size, NULL);
    printf("CL_DEVICE_MAX_WORK_GROUP_SIZE:\t%u\n", workgroup_size);
    cl_uint clock_frequency;
    clGetDeviceInfo(cdDevice, CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof(clock_frequency), &clock_frequency, NULL);
    printf("CL_DEVICE_MAX_CLOCK_FREQUENCY:\t%u MHz\n", clock_frequency);

    cl_context GPUContext = clCreateContext(0, 1, &cdDevice, NULL, NULL, NULL);

    cl_command_queue cqCommandQueue = clCreateCommandQueue(GPUContext, cdDevice, 0, NULL);

    cl_mem GPUVector1 = clCreateBuffer(GPUContext, CL_MEM_READ_ONLY |
                                       CL_MEM_USE_HOST_PTR, sizeof(unsigned long) * 64, p, NULL);
    cl_mem GPUVector2 = clCreateBuffer(GPUContext, CL_MEM_READ_ONLY |
                                       CL_MEM_USE_HOST_PTR, sizeof(unsigned long) * 64, c, NULL);
    cl_mem GPUVector3 = clCreateBuffer(GPUContext, CL_MEM_READ_ONLY |
                                       CL_MEM_USE_HOST_PTR, sizeof(unsigned long) * 56, k, NULL);

    cl_mem GPUOutputVector = clCreateBuffer(GPUContext, CL_MEM_WRITE_ONLY | CL_MEM_ALLOC_HOST_PTR,
                                            sizeof(unsigned long), &res, NULL);

    size_t szKernelLength;
    char* cSourceCL = oclLoadProgSource("ocl_deseval.cl", "", &szKernelLength);
    cl_program OpenCLProgram = clCreateProgramWithSource(GPUContext, 1,
                               (const char **)&cSourceCL, &szKernelLength, NULL);

    if (clBuildProgram(OpenCLProgram, 0, NULL, NULL, NULL, NULL)!=CL_SUCCESS)
    {
        char cBuffer[2048];
        if(clGetProgramBuildInfo(OpenCLProgram,cdDevice,CL_PROGRAM_BUILD_LOG,sizeof(cBuffer),cBuffer,NULL)==CL_SUCCESS);
        printf("Build error:\n%s\n",cBuffer);
        exit(1);
    }
    cl_kernel OpenCLVectorAdd = clCreateKernel(OpenCLProgram, "keysearch", NULL);

    clSetKernelArg(OpenCLVectorAdd, 0, sizeof(cl_mem), (void*)&GPUOutputVector);
    clSetKernelArg(OpenCLVectorAdd, 1, sizeof(cl_mem), (void*)&GPUVector1);
    clSetKernelArg(OpenCLVectorAdd, 2, sizeof(cl_mem), (void*)&GPUVector2);
    clSetKernelArg(OpenCLVectorAdd, 3, sizeof(cl_mem), (void*)&GPUVector3);

    size_t WorkSize[1] = {1024};
    start=clock();
    for (int i=0; i<1024; i++) {
        //clEnqueueWriteBuffer(cqCommandQueue, GPUOutputVector, CL_TRUE, 0,
        //									56 * sizeof(unsigned long), k, 0, NULL, NULL);
        clEnqueueNDRangeKernel(cqCommandQueue, OpenCLVectorAdd, 1, NULL,
                               WorkSize, NULL, 0, NULL, NULL);
        //clEnqueueReadBuffer(cqCommandQueue, GPUOutputVector, CL_TRUE, 0,
        //									sizeof(unsigned long), &res, 0, NULL, NULL);
        if(res!=0) {
            printf("Key found\n");
            //key_found(res,k);
            break;
        }
        increment_key (k);
    }
    end=clock();

    clReleaseKernel(OpenCLVectorAdd);
    clReleaseProgram(OpenCLProgram);
    clReleaseCommandQueue(cqCommandQueue);
    clReleaseContext(GPUContext);
    clReleaseMemObject(GPUVector1);
    clReleaseMemObject(GPUVector2);
    clReleaseMemObject(GPUOutputVector);

    printf ("Searched %i keys in %.3f seconds\n", 1000000, ((double)(end-start))/CLOCKS_PER_SEC);
    return 0;
}