adding to the above…is there anyway to restrict local-memory usage by making it use more register ? as my code uses 56bytes of local memory and 31 registers… I dont mind it using moe registers just to see the performance benifit.
yup am aware of the pitfalls like that… but am not declaring any array … just two float 4 structs rest floats and ints… I want to find out which variables are going to local memory . Even though its just 56 bytes but its still significant so I was thinking is there a way by which you can find in ptx which variable corresponds to which register or .local ?
PTX does support .local declarations. However, these are not typically used for register spills because PTX works with an infinite register set that represents what a program would look like before register allocation. You would have to disassemble a .cubin file or have a tool that actually performs register allocation at the PTX level. I am not sure whether or not such a tool exists…
EDIT: Actually if anyone could use such a tool, I have considered writing one for a little while now. It would not produce exactly the same results as nvcc, but it would probably be pretty close.
EDIT2: After re-reading your post, I don’t think that knowing exactly which variable is being spilled would help very much in determining how to reduce the number of spilled variables. Most compilers try to assign all variables to registers. There typically are not enough registers to hold all variables in the program, so the compiler will try to intelligently reuse registers for multiple variables. It can do this safely, assign the same register to two or more variables, as long as the variables are not alive – holding a value that may eventually be used – at the same time. When many variables are alive at the same time, the compiler may run out of registers to hold them all, and in this case it will try to spill them to memory intelligently so as to minimize the expected number of spill operations during execution. The point is that exactly which variable is chosen to be spilled to memory will be chosen based on not only what happens to that variable, but also what the program is doing with other variables.