thesquiff

CAL can't launch kernel

Discussion created by thesquiff on Feb 25, 2009
Latest reply on Feb 25, 2009 by thesquiff

Hi

I'm taking my first dive into CAL but am running into trouble. This will probably be trivial for someone to spot, but I can't work out what I'm doing wrong.

I have a very simple Brook+ kernel which I have compiled with brcc. I've then taken the IL code directly and used it unmodified.

When I run the program, the kernel doesn't execute and I get the error message: There was a problem running the program Error Code 1. The error string is Symbol "

...and the error string is cut short like that.

 

This error is coming from within RunProgram function from Samples.cpp.

 

Any ideas? The error is very vague for a beginner! Thanks in advance.

 


kernel void simpleMap(int g_idata[], out int g_odata<> {
    int idx = instance().x;
    //int idy = instance().y;
    g_odata = g_idata[idx];
}


 

// Device specific parameters
    unsigned int deviceNum  = 0;
    CALcontext ctx          = 0;
    CALdevice  device       = 0;   
    int numInputs = 1;
    int numOutputs = 1;
    int numConstantBuffers = 1;
    Data* data = NULL;
    CALresult r;


    printf("INITIALISING...\n");
    Initialize(&device, &ctx, deviceNum );

    //////////////////////////////////////////////////////////////////////////
    //
    //  Setup shader phase
    //
    //  Compile, Link and load the shader into a CALmodule.
    CALmodule stringMatchModule = 0;
    printf("LOADING AND COMPILING KERNEL...\n");
    if (!SetupKernel((CALchar*)stringMatchIL, &stringMatchModule, &ctx))
    {
        return 1;
    }

    //////////////////////////////////////////////////////////////////////////
    //
    //  Setup user data phase
    //
    //  Initialize CALresource's and CALmem handles,
    //  Map data into the respective memory handles
    //  and set up the context from the resources.
    printf("SETTING UP USER DATA SPACE...\n");  
    CALresource textRes  = 0;
    r = calResAllocLocal1D(&textRes, device, 512, CAL_FORMAT_INT_1, 0);
    calAssert(r, "There has been an error allocating resource.");
    // Mapping input resource to CPU
    // Returns 'fdata' as a CPU accessible pointer to resource 'inputRes'   
    // Filling values in input buffer
    int* textPtr     = NULL;
    CALuint inputPitch  = 0;   
    r = calResMap((CALvoid**)&textPtr, &inputPitch, textRes, 0);
    calAssert(r, "There has been an error mapping resource.");
    printf("Input pitch %d\n", inputPitch);

    for (int y = 0; y < 512; y++) {
        textPtr[y] = y;
    }


    r = calResUnmap(textRes);
    calAssert(r, "There has been an error unmapping resource."); 

   
    //allocate space for result

    // Mapping output resource to CPU and initializing values
    printf("ALLOCATING OUTPUT SPACE...\n");
    CALresource outputRes  = 0;
    void* outputPtr = NULL;
    unsigned int outputPitch = 0;
    r = calResAllocLocal1D(&outputRes, device, 512, CAL_FORMAT_INT_1, 0);
    r = calResMap(&outputPtr, &outputPitch, outputRes, 0);
   
    calAssert(r, "There has been an error mapping resource.");
    printf("Output pitch %d\n", outputPitch);
   
    memset(outputPtr, 0, 512);

    r = calResUnmap(outputRes);
    calAssert(r, "There has been an error unmapping resource.");


    //getting memory handles to resources

    calAssert(r, "There was an error getting memory handle.");
    r = calCtxGetMem((CALmem*)&textPtr, ctx, textRes);
    calAssert(r, "There was an error getting memory handle.");


    r = calCtxGetMem((CALmem*)&outputPtr, ctx, outputRes);
    calAssert(r, "There was an error getting memory handle.");


    printf("BINDING IO\n");

    CALname textInputName = 0;
    CALname outputName = 0;

    
    r = calModuleGetName(&textInputName, ctx, stringMatchModule, "i0");
    calAssert(r, "There was an error obtaining input name handle. (textInputName)");
   
    r = calModuleGetName(&outputName, ctx, stringMatchModule, "o0");
    calAssert(r, "There was an error obtaining output name handle. (outputName)");

    CALmem textMem = 0;
    CALmem hashTableMem = 0;
    CALmem hashChainMem = 0;
    CALmem outputMem = 0;

    r = calCtxSetMem(ctx, textInputName, textMem);
    calAssert(r, "There was an error binding resource. textRes");


    r = calCtxSetMem(ctx, outputName, outputMem);
    calAssert(r, "There was an error binding resource. outputRes");

    //////////////////////////////////////////////////////////////////////////
    //
    //  Execution phase
    //
    //  Run the program for give Iterations and collect statistics
    //  main is the entry point into the shader program.
    double elapsedTime = 0;
    SampleInfo Info;
    if(!RunProgram(&ctx, &stringMatchModule, 512, 1, &Info))
    {
        return 1;
    }

Outcomes