cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

NurEinMensch
Journeyman III

Need some help for using calclImageWrite

Hello,

after several hours and google sessions failed i try to find here some help.

Motivation: I try to create a .dll for different programs for "outsourcing" different math operations. Now i want to optimize the performance by splitting device operations like init, compiling, alloc, execute, memfree, closing in subfuntions of the dll. So an external programs can call at the beginning init,compiling(saving Imagebinary an to a file) and then use ontime only the memory and execution funtions. (and cleaning at the end).

Problem: I don't get it to use calclImageWrite in the right way. Can someone give me an example. Starting at the kernel_compiling stage, then writing the Image to an external binary file i.e. "dllfunction.bin" and ending with loading of that external image.

Many thanks for any help !

Marek

0 Likes
4 Replies
riza_guntur
Journeyman III

Go to http://forums.amd.com/devforum/messageview.cfm?catid=328&threadid=110685

Looks like they didn't make it for RV770

0 Likes

Hello Riza.guntur,

thanks for your answer and the link.

As i understand this is , that one can write an own program which compile an Image (from ILKernel, i.e. copied from KernelAnalyzer), write it to a binary file, and use it in another "compatible" program.

Can anyone from the ATI Team confirm this ?? (and give a simple code sample for this or the described task above) That this can be done with HD4870 ?

Best wishes !

Marek

0 Likes

Hmm, I'm using code like this:

 

// char *pKernel; // our ps/cs kernel CALobject obj = NULL; CALimage image = NULL; CALlanguage lang = CAL_LANGUAGE_IL; calDeviceGetInfo(&info, 0); CALtarget target; target = info.target; CALresult result; result = calclCompile(&obj, lang, (char *)pKernel, target); if (result != CAL_RESULT_OK) { printf("Error %d in calclCompile [%s].\n", result, calGetErrorString()); return 0; } printf("Compiling done in %d ms, linking...\n", GetTickCount() - ticks); if (calclLink(&image, &obj, 1) != CAL_RESULT_OK) { return 0; } calclFreeObject(obj); { CALuint isize; calclImageGetSize(&isize, image); BYTE *px; px = (BYTE *)malloc(isize); calclImageWrite(px, isize, image); FILE *f; f = _tfopen(TEXT("compiled_image.bin"), TEXT("wb")); fwrite(px, isize, 1, f); fclose(f); free(px); } calclFreeImage(image); // and it can be used later as // load data from .bin file and calImageRead(&image, ptr, bin_size);

0 Likes

Thank you very much for your help! i will test this.

update:

It work's. I modified it a little bit. Here is the code, for those who had the same problem

 

// #include <fstream> CALuint size; calclImageGetSize(&size, image); CALvoid *outbuffer = malloc(size); CALvoid *outbuffer2 = malloc(size); if (calclImageWrite(outbuffer, size, image) != CAL_RESULT_OK) { fprintf(stdout, "Fehler beim ImageWrite.\n"); } printf("\nSpeichere Image..\n"); std::ofstream datei; datei.open("Image.bin", std::ios::out|std::ios::binary); datei.write((char *)outbuffer, size); datei.close(); printf("\nLade Image..\n"); std::ifstream datei2("Image.bin", std::ios::in|std::ios::binary); datei2.read((char *)outbuffer2, size); calImageRead(&image, outbuffer2, size);

0 Likes