当前位置: 首页>>代码示例>>C++>>正文


C++ CHECK_ALLOCATION函数代码示例

本文整理汇总了C++中CHECK_ALLOCATION函数的典型用法代码示例。如果您正苦于以下问题:C++ CHECK_ALLOCATION函数的具体用法?C++ CHECK_ALLOCATION怎么用?C++ CHECK_ALLOCATION使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CHECK_ALLOCATION函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sizeof

int 
ScanLargeArrays::setupScanLargeArrays()
{
    // input buffer size
    cl_uint sizeBytes = length * sizeof(cl_float);

    // allocate memory for input arrray
    input = (cl_float*)malloc(sizeBytes);
    CHECK_ALLOCATION(input, "Failed to allocate host memory. (input)");

    // random initialisation of input
    sampleCommon->fillRandom<cl_float>(input, length, 1, 0, 255);

    // allocate memory for output buffer
    output = (cl_float*)malloc(sizeBytes);
    CHECK_ALLOCATION(output, "Failed to allocate host memory. (output)");

    // if verification is enabled
    if(verify)
    {
        // allocate memory for verification output array
        verificationOutput = (cl_float*)malloc(sizeBytes);
        CHECK_ALLOCATION(verificationOutput, "Failed to allocate host memory. (verify)");
        memset(verificationOutput, 0, sizeBytes);
    }
    // Unless quiet mode has been enabled, print the INPUT array
    if(!quiet) 
    {
        sampleCommon->printArray<cl_float>("Input", 
                                           input, 
                                           length, 
                                           1);
    }
    return SDK_SUCCESS;
}
开发者ID:CryDevPortal,项目名称:amd-app-sdk-fixes,代码行数:35,代码来源:ScanLargeArrays.cpp

示例2: CHECK_ALLOCATION

int ScanLargeArrays::initialize()
{
    // Call base class Initialize to get default configuration
    if(this->SDKSample::initialize() != SDK_SUCCESS)
        return SDK_FAILURE;

    streamsdk::Option* array_length = new streamsdk::Option;
    CHECK_ALLOCATION(array_length,"Memory Allocation error.(array_length)");

    array_length->_sVersion = "x";
    array_length->_lVersion = "length";
    array_length->_description = "Length of the input array";
    array_length->_type = streamsdk::CA_ARG_INT;
    array_length->_value = &length;
    sampleArgs->AddOption(array_length);
    delete array_length;

    streamsdk::Option* iteration_option = new streamsdk::Option;
    CHECK_ALLOCATION(iteration_option,"Memory Allocation error.(iteration_option)");

    iteration_option->_sVersion = "i";
    iteration_option->_lVersion = "iterations";
    iteration_option->_description = "Number of iterations to execute kernel";
    iteration_option->_type = streamsdk::CA_ARG_INT;
    iteration_option->_value = &iterations;

    sampleArgs->AddOption(iteration_option);
    delete iteration_option;

    return SDK_SUCCESS;
}
开发者ID:CryDevPortal,项目名称:amd-app-sdk-fixes,代码行数:31,代码来源:ScanLargeArrays.cpp

示例3: CHECK_ERROR

int BinomialOption::initialize()
{
    // Call base class Initialize to get default configuration
    CHECK_ERROR(this->SDKSample::initialize(), SDK_SUCCESS, "OpenCL Resource Intilization failed");

    streamsdk::Option* num_samples = new streamsdk::Option;
    CHECK_ALLOCATION(num_samples, "Error. Failed to allocate memory (num_samples)\n");

    num_samples->_sVersion = "x";
    num_samples->_lVersion = "samples";
    num_samples->_description = "Number of samples to be calculated";
    num_samples->_type = streamsdk::CA_ARG_INT;
    num_samples->_value = &numSamples;

    sampleArgs->AddOption(num_samples);

    delete num_samples;

    streamsdk::Option* num_iterations = new streamsdk::Option;
    CHECK_ALLOCATION(num_iterations, "Error. Failed to allocate memory (num_iterations)\n");

    num_iterations->_sVersion = "i";
    num_iterations->_lVersion = "iterations";
    num_iterations->_description = "Number of iterations for kernel execution";
    num_iterations->_type = streamsdk::CA_ARG_INT;
    num_iterations->_value = &iterations;

    sampleArgs->AddOption(num_iterations);

    delete num_iterations;

    return SDK_SUCCESS;
}
开发者ID:grubbymits,项目名称:esdg-opencl,代码行数:33,代码来源:BinomialOption.cpp

示例4: defined

int
BinomialOption::setupBinomialOption()
{

    // Make numSamples multiple of 4
    numSamples = (numSamples / 4)? (numSamples / 4) * 4: 4;

#if defined (_WIN32)
    randArray = (cl_float*)_aligned_malloc(numSamples * sizeof(cl_float4), 16);
#else
    randArray = (cl_float*)memalign(16, numSamples * sizeof(cl_float4));
#endif
    CHECK_ALLOCATION(randArray, "Failed to allocate host memory. (randArray)");
    
    for(int i = 0; i < numSamples * 4; i++)
    {
        randArray[i] = (float)rand() / (float)RAND_MAX;
    }

#if defined (_WIN32)
    output = (cl_float*)_aligned_malloc(numSamples * sizeof(cl_float4), 16);
#else
    output = (cl_float*)memalign(16, numSamples * sizeof(cl_float4));
#endif

    CHECK_ALLOCATION(output, "Failed to allocate host memory. (output)");
    memset(output, 0, numSamples * sizeof(cl_float4));

    return SDK_SUCCESS;
}
开发者ID:grubbymits,项目名称:esdg-opencl,代码行数:30,代码来源:BinomialOption.cpp

示例5: if

int SimpleConvolution::initialize()
{
   // Call base class Initialize to get default configuration
   if  (this->SDKSample::initialize() != SDK_SUCCESS)
       return SDK_FAILURE;

   // Now add customized options
    streamsdk::Option* width_option = new streamsdk::Option;
    CHECK_ALLOCATION(width_option, "Memory allocation error.\n");

    width_option->_sVersion = "x";
    width_option->_lVersion = "width";
    width_option->_description = "Width of the input matrix";
    width_option->_type = streamsdk::CA_ARG_INT;
    width_option->_value = &width;

    sampleArgs->AddOption(width_option);
    delete width_option;

    streamsdk::Option* height_option = new streamsdk::Option;
    CHECK_ALLOCATION(height_option, "Memory allocation error.\n");

    height_option->_sVersion = "y";
    height_option->_lVersion = "height";
    height_option->_description = "Height of the input matrix";
    height_option->_type = streamsdk::CA_ARG_INT;
    height_option->_value = &height;

    sampleArgs->AddOption(height_option);
    delete height_option;

    streamsdk::Option* mask_width = new streamsdk::Option;
    CHECK_ALLOCATION(mask_width, "Memory allocation error.\n");

    maskWidth = 3;
    mask_width->_sVersion = "m";
    mask_width->_lVersion = "masksize";
    mask_width->_description = "Width of the mask matrix";
    mask_width->_type = streamsdk::CA_ARG_INT;
    mask_width->_value = &maskWidth;
    sampleArgs->AddOption(mask_width);
    delete mask_width;

    streamsdk::Option* num_iterations = new streamsdk::Option;
    CHECK_ALLOCATION(num_iterations, "Memory allocation error.\n");

    num_iterations->_sVersion = "i";
    num_iterations->_lVersion = "iterations";
    num_iterations->_description = "Number of iterations for kernel execution";
    num_iterations->_type = streamsdk::CA_ARG_INT;
    num_iterations->_value = &iterations;

    sampleArgs->AddOption(num_iterations);
    delete num_iterations;

   return SDK_SUCCESS;
}
开发者ID:ChiahungTai,项目名称:OpenCL-playgorund,代码行数:57,代码来源:SimpleConvolution.cpp

示例6: get_desired_platform

static int get_desired_platform(const char *substr,
                                cl_platform_id *platform_id_out,
                                cl_int *err)
{
    cl_int _err = CL_SUCCESS;
    cl_uint i, num_platforms;
    cl_platform_id *platform_ids = NULL;
    char *platform_name = NULL;

    assert(platform_id_out != NULL);

    if (!err) err = &_err;

    *err = clGetPlatformIDs(0, NULL, &num_platforms);
    CHECK_CL_ERROR(*err);

    platform_ids = malloc(sizeof(*platform_ids) * num_platforms);
    CHECK_ALLOCATION(platform_ids);

    *err = clGetPlatformIDs(num_platforms, platform_ids, NULL);
    CHECK_CL_ERROR(*err);

    for (i = 0; i < num_platforms; i++) {
        size_t platform_name_size;

        *err = clGetPlatformInfo(platform_ids[i], CL_PLATFORM_NAME, 0, NULL,
                                 &platform_name_size);
        CHECK_CL_ERROR(*err);

        platform_name = realloc(platform_name,
                                sizeof(*platform_name) * platform_name_size);
        CHECK_ALLOCATION(platform_name);

        *err = clGetPlatformInfo(platform_ids[i], CL_PLATFORM_NAME,
                                 platform_name_size, platform_name, NULL);
        CHECK_CL_ERROR(*err);

        if (DEBUG)
            printf("Platform %u: \"%s\"\n", i, platform_name);

        if (strstr(platform_name, substr))
            break;
    }

    if (i < num_platforms)
        *platform_id_out = platform_ids[i];
    else
        goto error; /* No platforms found */

    free(platform_ids);
    free(platform_name);
    return 0;
error:
    free(platform_ids);
    free(platform_name);
    return -1;
}
开发者ID:mjn33,项目名称:OpenCL-Experiments,代码行数:57,代码来源:plugin.c

示例7: sobelFilterCPUReference

int
SobelFilter::verifyResults()
{
    if(!byteRWSupport)
    {
        return SDK_SUCCESS;
    }

    if(sampleArgs->verify)
    {
        // reference implementation
        sobelFilterCPUReference();

        float *outputDevice = new float[width * height * pixelSize];
        CHECK_ALLOCATION(outputDevice,
                         "Failed to allocate host memory! (outputDevice)");

        float *outputReference = new float[width * height * pixelSize];
        CHECK_ALLOCATION(outputReference, "Failed to allocate host memory!"
                         "(outputReference)");

        // copy uchar data to float array
        for(int i = 0; i < (int)(width * height); i++)
        {
            outputDevice[i * 4 + 0] = outputImageData[i].s[0];
            outputDevice[i * 4 + 1] = outputImageData[i].s[1];
            outputDevice[i * 4 + 2] = outputImageData[i].s[2];
            outputDevice[i * 4 + 3] = outputImageData[i].s[3];

            outputReference[i * 4 + 0] = verificationOutput[i * 4 + 0];
            outputReference[i * 4 + 1] = verificationOutput[i * 4 + 1];
            outputReference[i * 4 + 2] = verificationOutput[i * 4 + 2];
            outputReference[i * 4 + 3] = verificationOutput[i * 4 + 3];
        }


        // compare the results and see if they match
        if(compare(outputReference,
                   outputDevice,
                   width * height * 4))
        {
            std::cout << "Passed!\n" << std::endl;
            delete[] outputDevice;
            delete[] outputReference;
            return SDK_SUCCESS;
        }
        else
        {
            std::cout << "Failed\n" << std::endl;
            delete[] outputDevice;
            delete[] outputReference;
            return SDK_FAILURE;
        }
    }

    return SDK_SUCCESS;
}
开发者ID:liujames,项目名称:hello_world,代码行数:57,代码来源:SobelFilter.cpp

示例8: sizeof

int
MatrixMulDouble::setupMatrixMulDouble()
{
    // allocate and init memory used by host  inputA[widthA][heightA]
    cl_uint inputSizeBytes0 = widthA * heightA * sizeof(cl_double);

    inputA = (cl_double*) malloc(inputSizeBytes0);
    CHECK_ALLOCATION(inputA, "Failed to allocate host memory. (inputA)");


    // allocate and init memory used by host inputB[widthB][heightB]
    cl_uint inputSizeBytes1 = widthB * heightB * sizeof(cl_double);

    inputB = (cl_double*) malloc(inputSizeBytes1);
    CHECK_ALLOCATION(inputB, "Failed to allocate host memory. (inputB)");


    // random initialisation of input
    fillRandom<cl_double>(inputA, widthA, heightA, 0, 10);
    fillRandom<cl_double>(inputB, widthB, heightB, 0, 10);

    // allocate memory for output[widthB][heightA]
    cl_uint outputSizeBytes = heightA * widthB * sizeof(cl_double);

    output = (cl_double*) malloc(outputSizeBytes);
    CHECK_ALLOCATION(output, "Failed to allocate host memory. (output)");


    // allocate memory for output[widthB][heightA] of reference implemenation
    if(sampleArgs->verify)
    {
        refOutput = (cl_double*) malloc(outputSizeBytes);
        CHECK_ALLOCATION(refOutput, "Failed to allocate host memory. (refOutput)");
        memset(refOutput, 0, outputSizeBytes);
    }
    /*
     * Unless quiet mode has been enabled, print the INPUT arrays
     */
    if(!sampleArgs->quiet)
    {
        printArray<cl_double>(
            "inputA",
            inputA,
            widthA,
            1);
        printArray<cl_double>(
            "inputB",
            inputB,
            widthB,
            1);

    }

    return SDK_SUCCESS;
}
开发者ID:morellid,项目名称:featureBasedScheduling,代码行数:55,代码来源:MatrixMulDouble.cpp

示例9: CHECK_ALLOCATION

int DeviceFission::initialize()
{
    // Call base class Initialize to get default configuration
    if(this->SDKSample::initialize())
        return SDK_FAILURE;

    // Now add customized options
    streamsdk::Option* array_length = new streamsdk::Option;
    CHECK_ALLOCATION(array_length, "Memory allocation error.\n");

    array_length->_sVersion = "x";
    array_length->_lVersion = "length";
    array_length->_description = "Length of the Input array (Default value 1024)";
    array_length->_type = streamsdk::CA_ARG_INT;
    array_length->_value = &length;
    sampleArgs->AddOption(array_length);
    delete array_length;

	streamsdk::Option* bool_cpu2gpu = new streamsdk::Option;
	CHECK_ALLOCATION(bool_cpu2gpu, "Memory allocation error.\n");

	bool_cpu2gpu->_sVersion = "g";
	bool_cpu2gpu->_lVersion = "cpu2gpu";
	bool_cpu2gpu->_description = "Switch to migrate memory object from sub device to GPU before run kernels.(0 or 1, where 0 is disable, 1 is enable)";
	bool_cpu2gpu->_type = streamsdk::CA_ARG_INT;
	bool_cpu2gpu->_value = &cpu2gpuValue;
	sampleArgs->AddOption(bool_cpu2gpu);
	delete bool_cpu2gpu;

	streamsdk::Option* bool_cpu2cpu = new streamsdk::Option;
	CHECK_ALLOCATION(bool_cpu2cpu, "Memory allocation error.\n");

	bool_cpu2cpu->_sVersion = "c";
	bool_cpu2cpu->_lVersion = "cpu2cpu";
	bool_cpu2cpu->_description = "Switch to migrate memory object from sub device to another sub device before run kernels. (0 or 1, where 0 is disable, 1 is enable)";
	bool_cpu2cpu->_type = streamsdk::CA_ARG_INT;
	bool_cpu2cpu->_value = &cpu2cpuValue;
	sampleArgs->AddOption(bool_cpu2cpu);
	delete bool_cpu2cpu;

	streamsdk::Option* load_gpu = new streamsdk::Option;
	CHECK_ALLOCATION(load_gpu, "Memory allocation error.\n");

	load_gpu->_sVersion = "";
	load_gpu->_lVersion = "loadgpu";
	load_gpu->_description = "Load GPU binary image and execute on GPU";
	load_gpu->_type = streamsdk::CA_ARG_STRING;
	load_gpu->_value = &loadBinaryGPU;
	sampleArgs->AddOption(load_gpu);
	delete load_gpu;


    return SDK_SUCCESS;
}
开发者ID:CryDevPortal,项目名称:amd-app-sdk-fixes,代码行数:54,代码来源:DeviceFission.cpp

示例10: sizeof

int
SobelFilter::readInputImage(std::string inputImageName)
{

    // load input bitmap image
    inputBitmap.load(inputImageName.c_str());

    // error if image did not load
    if(!inputBitmap.isLoaded())
    {
        std::cout << "Failed to load input image!";
        return SDK_FAILURE;
    }


    // get width and height of input image
    height = inputBitmap.getHeight();
    width = inputBitmap.getWidth();

    // allocate memory for input & output image data
    inputImageData  = (cl_uchar4*)malloc(width * height * sizeof(cl_uchar4));
    CHECK_ALLOCATION(inputImageData, "Failed to allocate memory! (inputImageData)");

    // allocate memory for output image data
    outputImageData = (cl_uchar4*)malloc(width * height * sizeof(cl_uchar4));
    CHECK_ALLOCATION(outputImageData,
                     "Failed to allocate memory! (outputImageData)");

    // initializa the Image data to NULL
    memset(outputImageData, 0, width * height * pixelSize);

    // get the pointer to pixel data
    pixelData = inputBitmap.getPixels();
    if(pixelData == NULL)
    {
        std::cout << "Failed to read pixel Data!";
        return SDK_FAILURE;
    }

    // Copy pixel data into inputImageData
    memcpy(inputImageData, pixelData, width * height * pixelSize);

    // allocate memory for verification output
    verificationOutput = (cl_uchar*)malloc(width * height * pixelSize);
    CHECK_ALLOCATION(verificationOutput,
                     "verificationOutput heap allocation failed!");

    // initialize the data to NULL
    memset(verificationOutput, 0, width * height * pixelSize);

    return SDK_SUCCESS;

}
开发者ID:liujames,项目名称:hello_world,代码行数:53,代码来源:SobelFilter.cpp

示例11: sizeof

int 
GlobalMemoryBandwidth::setupGlobalMemoryBandwidth()
{
    //Make vectorSize as 4 if -v option is 3. 

    //This memeory alignment is required as per OpenCL for type3 vectors 
    if(vectorSize == 3)
    {
        vec3 = true;
        vectorSize = 4;
    }

    /**
     * Allocate memory required for global buffer 
     * This includes both single and linear(cached and uncached) reads 
     */
    cl_uint sizeElement = vectorSize * sizeof(cl_float);
    cl_uint readLength = length + (NUM_READS * 1024 / sizeElement) + EXTRA_BYTES;
    cl_uint size = readLength * vectorSize * sizeof(cl_float);

    input = (cl_float*)malloc(size);
    CHECK_ALLOCATION(input, "Failed to allocate host memory. (input)");

    outputReadSingle = (cl_float*)malloc(length * vectorSize * sizeof(cl_float));
    CHECK_ALLOCATION(outputReadSingle, "Failed to allocate host memory. (outputReadSingle)");

    memset(outputReadSingle, 0, length * vectorSize * sizeof(cl_float));

    outputReadLinear = (cl_float*)malloc(length * vectorSize * sizeof(cl_float));
    CHECK_ALLOCATION(outputReadLinear, "Failed to allocate host memory. (outputReadLinear)");

    memset(outputReadLinear, 0, length * vectorSize * sizeof(cl_float));

    outputReadLU = (cl_float*)malloc(length * vectorSize * sizeof(cl_float));
    CHECK_ALLOCATION(outputReadLU, "Failed to allocate host memory. (outputReadLU)");

    memset(outputReadLU, 0, length * vectorSize * sizeof(cl_float));

    outputWriteLinear = (cl_float*)malloc(size);
    CHECK_ALLOCATION(outputWriteLinear, "Failed to allocate host memory. (outputWriteLinear)");

    memset(outputWriteLinear, 0, size);

    // random initialisation of input 
    sampleCommon->fillRandom<cl_float>(input,  
                                       readLength * vectorSize, 
                                       1, 
                                       0, 
                                       10);

    return SDK_SUCCESS;
}
开发者ID:CryDevPortal,项目名称:amd-app-sdk-fixes,代码行数:52,代码来源:GlobalMemoryBandwidth.cpp

示例12: sizeof

int 
MatrixMulImage::setupMatrixMulImage()
{
    // allocate and init memory used by host  input0[width0][height0]
    cl_uint inputSizeBytes0 = width0 * height0 * sizeof(cl_float);

    input0 = (cl_float *) malloc(inputSizeBytes0);
    CHECK_ALLOCATION(input0, "Failed to allocate host memory. (input0)");

    // allocate and init memory used by host input1[width1][height1]
    cl_uint inputSizeBytes1 = width1 * height1 * sizeof(cl_float);

    input1 = (cl_float *) malloc(inputSizeBytes1);
    CHECK_ALLOCATION(input1, "Failed to allocate host memory. (input1)");
    
    // random initialisation of input
    sampleCommon->fillRandom<cl_float>(input0, width0, height0, 0, 10);
    sampleCommon->fillRandom<cl_float>(input1, width1, height1, 0, 10);

    // allocate memory for output[width1][height0]
    cl_uint outputSizeBytes = height0 * width1 * sizeof(cl_float);

    output = (cl_float *) malloc(outputSizeBytes);
    CHECK_ALLOCATION(output, "Failed to allocate host memory. (output)");

    // allocate memory for output[width1][height0] of reference implemenation
    if(verify)
    {
        verificationOutput = (cl_float *) malloc(outputSizeBytes);
        CHECK_ALLOCATION(verificationOutput, "Failed to allocate host memory. (verificationOutput)");
        memset(verificationOutput, 0, outputSizeBytes);
    }

    /* 
     * Unless quiet mode has been enabled, print the INPUT arrays
     */
    if(!quiet) 
    {
        sampleCommon->printArray<cl_float>(
            "Input0", 
            input0, 
            width0, 
            1);
        sampleCommon->printArray<cl_float>(
            "Input1", 
            input1, 
            width1, 
            1);
    }
    return SDK_SUCCESS;
}
开发者ID:ChiahungTai,项目名称:OpenCL-playgorund,代码行数:51,代码来源:MatrixMulImage.cpp

示例13: sizeof

int
ImageOverlap::readImage(std::string mapImageName,std::string verifyImageName)
{

    // load input bitmap image 
    mapBitmap.load(mapImageName.c_str());
	verifyBitmap.load(verifyImageName.c_str());
    // error if image did not load 
    if(!mapBitmap.isLoaded())
    {
        sampleCommon->error("Failed to load input image!");
        return SDK_FAILURE;
    }

    // get width and height of input image
    height = mapBitmap.getHeight();
    width = mapBitmap.getWidth();
	image_desc.image_width=width;
	image_desc.image_height=height;
    // allocate memory for map image data 
    mapImageData = (cl_uchar4*)malloc(width * height * sizeof(cl_uchar4));
    CHECK_ALLOCATION(mapImageData,"Failed to allocate memory! (mapImageData)");

    // allocate memory for fill image data 
    fillImageData = (cl_uchar4*)malloc(width * height * sizeof(cl_uchar4));
    CHECK_ALLOCATION(fillImageData,"Failed to allocate memory! (fillImageData)");

    // initializa the Image data to NULL 
    memset(fillImageData, 0, width * height * pixelSize);

    // get the pointer to pixel data 
    pixelData = mapBitmap.getPixels();
    CHECK_ALLOCATION(pixelData,"Failed to read mapBitmap pixel Data!");

    // Copy pixel data into mapImageData
    memcpy(mapImageData, pixelData, width * height * pixelSize);

    // allocate memory for verification output
    verificationImageData = (cl_uchar4*)malloc(width * height * pixelSize);
    CHECK_ALLOCATION(pixelData,"verificationOutput heap allocation failed!");

	pixelData = verifyBitmap.getPixels();
	CHECK_ALLOCATION(pixelData,"Failed to read verifyBitmap pixel Data!");

	// Copy pixel data into verificationOutput
	memcpy(verificationImageData, pixelData, width * height * pixelSize);
	
    return SDK_SUCCESS;
}
开发者ID:CryDevPortal,项目名称:amd-app-sdk-fixes,代码行数:49,代码来源:ImageOverlap.cpp

示例14: sizeof

int
DeviceFission::setupDeviceFission()
{
    // Make sure length is multiple of group size * numSubDevices
    unsigned int mulFactor = (unsigned int)groupSize * numSubDevices;
    length = (length < mulFactor) ? mulFactor : length;
    length = (length / mulFactor) * mulFactor;

	// Calculate half length
	half_length = length >> 1;

	// Deal with options: cpu2cpu and cpu2gpu
	if(cpu2gpuValue != 0 && cpu2cpuValue != 0)
	{
		std::cout << "cpu2gpu and cpu2cpu can't be both true. Disable cpu2cpu."<< std::endl;
		cpu2cpuValue = 0;
	}
	if(cpu2gpuValue != 0)
	{
		std::cout << "Enable cpu2gpu mode."<< std::endl;
		cpu2gpu = CL_TRUE;
	}
	if(cpu2cpuValue != 0)
	{
		std::cout << "Enable cpu2cpu mode."<< std::endl;
		cpu2cpu = CL_TRUE;
	}

	// Get allocate memory for input buffer
    input = (cl_int*)malloc(half_length * sizeof(cl_int));
    CHECK_ALLOCATION(input, "Failed to allocate host memory. (input)");

    // Random initialisation of input
    sampleCommon->fillRandom<cl_int>(input, half_length, 1, 1, 8);

    // Unless quiet mode has been enabled, print the INPUT array
    if(!quiet) 
		sampleCommon->printArray<cl_int>("Input:", input, half_length, 1);

	// Get allocate memory for subOutput buffer
    subOutput = (cl_int*)malloc(length * sizeof(cl_int));
    CHECK_ALLOCATION(subOutput, "Failed to allocate host memory. (subOutput)");

	// Get allocate memory for gpuOutput buffer
	gpuOutput = (cl_int*)malloc(length * sizeof(cl_int));
	CHECK_ALLOCATION(gpuOutput, "Failed to allocate host memory. (gpuOutput)");

    return SDK_SUCCESS;
}
开发者ID:CryDevPortal,项目名称:amd-app-sdk-fixes,代码行数:49,代码来源:DeviceFission.cpp

示例15: CHECK_ALLOCATION

/******************************************************************************
* Implementation of BoltSample::initialize()                                  *
******************************************************************************/
int BoltSample::initialize()
{
    int defaultOptions = 6;

    boltsdk::Option *optionList = new boltsdk::Option[defaultOptions];
    CHECK_ALLOCATION(optionList, "Error. Failed to allocate memory (optionList)\n");

    optionList[0]._sVersion = "q";
    optionList[0]._lVersion = "quiet";
    optionList[0]._description = "Quiet mode. Suppress most text output.";
    optionList[0]._type = boltsdk::CA_NO_ARGUMENT;
    optionList[0]._value = &quiet;

    optionList[1]._sVersion = "e";
    optionList[1]._lVersion = "verify";
    optionList[1]._description = "Verify results against reference implementation.";
    optionList[1]._type = boltsdk::CA_NO_ARGUMENT;
    optionList[1]._value = &verify;

    optionList[2]._sVersion = "t";
    optionList[2]._lVersion = "timing";
    optionList[2]._description = "Print timing related statistics.";
    optionList[2]._type = boltsdk::CA_NO_ARGUMENT;
    optionList[2]._value = &timing;

    optionList[3]._sVersion = "v";
    optionList[3]._lVersion = "version";
    optionList[3]._description = "Bolt lib & runtime version string.";
    optionList[3]._type = boltsdk::CA_NO_ARGUMENT;
    optionList[3]._value = &version;

    optionList[4]._sVersion = "x";
    optionList[4]._lVersion = "samples";
    optionList[4]._description = "Number of sample input values.";
    optionList[4]._type = boltsdk::CA_ARG_INT;
    optionList[4]._value = &samples;

    optionList[5]._sVersion = "i";
    optionList[5]._lVersion = "iterations";
    optionList[5]._description = "Number of iterations.";
    optionList[5]._type = boltsdk::CA_ARG_INT;
    optionList[5]._value = &iterations;

    sampleArgs = new boltsdk::BoltCommandArgs(defaultOptions, optionList);
    CHECK_ALLOCATION(sampleArgs, "Failed to allocate memory. (sampleArgs)\n");
                
    return SDK_SUCCESS;
}
开发者ID:ChiahungTai,项目名称:OpenCL-playgorund,代码行数:51,代码来源:BoltSample.cpp


注:本文中的CHECK_ALLOCATION函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。