Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

Adept II

Large constant lookup table gives incorrect results on Radeon 5870

I have a fairly large lookup table containing the natural logs of some number of factorials. This table is computer generated into a header file and included by my OpenCL program, declared as __constant float gLogFact[65536] = {1.0f, 1.0f, 2.0f, 6.0f, ... };

I use this table to compute the binomial coefficient with large inputs (e.g. 1000 chose 30). This table contains the first 65k answers to n!. If I call logChoose with any values not computable at compile time, I get 0.0 every time, which is wrong. However, if I directly plug in constants, or even a loop index with a known trip count, I get the right answer. This leads me to believe the compiler avoids actually doing the lookups if it can, and just statically computes the answer based on the array entries (which is fairly impressive).

When I reduce the table's size to 8192 elements, I get the correct answer, even with dynamic indexing.  My guess is I was using too much constant memory. Shouldn't the compiler fail when you try to do something ludicrous like this?

1 Reply,
I thought that we had a check in the compiler for this. Is it possible to give a test case so that I can verify it is fixed?