cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

douglas125
Adept I

Strange compiler behavior

OpenCL compiles two codes separatedly but won't compile them together

Hi.

I'm using Radeon 5770, Windows 7 and SDK 2.2 to develop a text search tool. For some strange reason, the code attached won't compile using AMD OpenCL, although it compiles using NVidia (I tested using a Tesla C1060 card).

What happens is: when I try to compile, the program locks down. No error message, it just freezes.

The strange thing, though, is that the 3 functions that don't belong to the kernel compile when the kernel is not present and the kernel compiles if I set all functions to return 0.

Given that the code works with NVidia implementation, my only choice was to ask for help in this forum. Could you please try to compile the code?

 

Thanks in advance

float ByteSimilarityInPos(int b, int pos, int bigWord[]) { int bb = bigWord[pos]; if (bb == b) return 1.0f; else if (97 <= b && b <= 122) //b is lower case { if (b - 32 == bb) return 0.95f; } else if (65 <= b && b <= 90) //b is upper case { if (b + 32 == bb) return 0.95f; } //aáãâ, AÁÃÂ if ( ((b == 65) || (b == 97) || (224 <= b && b <= 228) || (192 <= b && b <= 196)) && ((bb == 65) || (bb == 97) || (224 <= bb && bb <= 228) || (192 <= bb && bb <= 196)) ) { return 0.93f; } //oóõö, OÔÕ else if ( ((b == 111) || (b == 79) || (210 <= b && b <= 214) || (242 <= b && b <= 246)) && ((bb == 111) || (bb == 79) || (210 <= bb && bb <= 214) || (242 <= bb && bb <= 246)) ) { return 0.93f; } //eéè, EÉÈ else if ( ((b == 101) || (b == 69) || (232 <= b && b <= 235) || (200 <= b && b <= 203)) && ((bb == 101) || (bb == 69) || (232 <= bb && bb <= 235) || (200 <= bb && bb <= 203)) ) { return 0.93f; } //iíI else if ( ((b == 105) || (b == 73) || (236 <= b && b <= 239) || (204 <= b && b <= 207)) && ((bb == 105) || (bb == 73) || (236 <= bb && bb <= 239) || (204 <= bb && bb <= 207)) ) { return 0.93f; } //uúU else if ( ((b == 117) || (b == 85) || (249 <= b && b <= 251) || (217 <= b && b <= 220)) && ((bb == 117) || (bb == 85) || (249 <= bb && bb <= 251) || (217 <= bb && bb <= 220)) ) { return 0.93f; } //cçCÇ else if ( ((b == 99) || (b == 231) || (b == 67) || (b == 199)) && ((bb == 99) || (bb == 231) || (bb == 67) || (bb == 199)) ) { return 0.95f; } return 0; } float GetByteSimilarity(int b, int pos0, int bigWord[], int bigWordLen) { float sim1, sim2 = 0; sim1 = ByteSimilarityInPos(b, pos0, bigWord); //Similarity found if (sim1 > 0) return sim1; //Level 1 repositioning if (pos0 > 0) sim1 = 0.8f * ByteSimilarityInPos(b, pos0 - 1, bigWord); if (pos0 < bigWordLen - 1) sim2 = 0.8f * ByteSimilarityInPos(b, pos0 + 1, bigWord); if (sim2 > sim1) sim1 = sim2; if (sim1 > 0) return sim1; //Level 2 repositioning if (pos0 > 1) sim1 = 0.5f * ByteSimilarityInPos(b, pos0 - 2, bigWord); if (pos0 < bigWordLen - 2) sim2 = 0.5f * ByteSimilarityInPos(b, pos0 + 2, bigWord); //Level 3 repositioning if (pos0 > 2) sim1 = 0.2f * ByteSimilarityInPos(b, pos0 - 3, bigWord); if (pos0 < bigWordLen - 3) sim2 = 0.2f * ByteSimilarityInPos(b, pos0 + 3, bigWord); return 0; } float WordDotProd(int word1[], int word2[], int word1Len, int word2Len) { float similarity = 0; if (word1Len > word2Len) { for (int i = 0; i < word2Len; i++) similarity += GetByteSimilarity(word2, i, word1, word1Len); return similarity / (float)word1Len; } else { for (int i = 0; i < word1Len; i++) similarity += GetByteSimilarity(word1, i, word2, word2Len); return similarity / (float)word2Len; } } __kernel void ClassifyKeyWords (__global read_only uchar * wordBytes1, __global read_only uchar * len1, __global read_only int * StartPos1, __global read_only uchar * wordBytes2, __global read_only uchar * len2, __global read_only int * StartPos2, __global read_only int * numWords2, __global write_only float * minSimilarity, __global write_only float * Similarities) { int i = get_global_id(0); int wb[50]; int stPos1 = StartPos1; int len1i = len1; len1i = len1i > 50 ? 50 : len1i; for (int k = 0; k < len1i; k++) { wb = wordBytes1[stPos1 + k]; } { int jj = get_global_id(1); int nWorkItems = get_global_size(1); int nWords2 = numWords2[0]; float similarity = 0; float minSim = minSimilarity[0]; int jmin = jj * nWords2 / nWorkItems; int jmax = (jj + 1) * nWords2 / nWorkItems; for (int j = jmin; j < jmax; j++) { int len2j = len2; len2j = len2j > 50 ? 50 : len2j; if (len2j > 1) { int wb2[50]; int stPos2 = StartPos2; for (int kk = 0; kk < len2j; kk++) { wb2[kk] = wordBytes2[stPos2 + kk]; } float dprod = WordDotProd(wb, wb2, len1i, len2j); if (dprod > minSim) similarity += dprod; } } Similarities[i * nWorkItems + jj] = similarity; } }

0 Likes
1 Reply

douglas125,
First off you have invalid OpenCL.

float ByteSimilarityInPos(int b, int pos, int bigWord[]) <-- this is not valid OpenCL, you can only pass via pointer and not unsized arrays
__global read_only uchar * len1, <-- this is also not valid OpenCL, read_only/write_only can only be attributed to images

That being said, SDK 2.3 should have this fixed as there was a bug in the compiler that went into an infinite loop.
0 Likes