1 Reply Latest reply on May 17, 2011 7:38 PM by MicahVillmow

    Large constant lookup table gives incorrect results on Radeon 5870

    rick.weber

      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?