The Stack Overflow podcast is back! Listen to an interview with our new CEO.

New answers tagged

3

The lookup table lut should be hard-coded in the source code and defined outside the kernel function as a __constant space global variable. As it is now, every thread would have to recalculate the entire table. Also they take too much space for thread's private memory space. Alternately, maybe pre-calculate it on the host and pass it to the kernel in a ...


3

A few points: Reversing the string m multiple times is unnecessary. Slicing can be done on the original string using correct indices. m[::-1][i:i+3][::-1] is equivalent to m[-i-3:len(m)-i]. Another approach is to traverse the indices in the reverse order for i in range(len(m)-1, -1, -3) and then perform slicing accordingly. The logic can be simplified using ...


Top 50 recent answers are included