Debugging: finding all instances of gpuArray in large code base [or finding all instances of other function calls]
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
D. Plotnick
el 10 de Jul. de 2018
Comentada: D. Plotnick
el 13 de Jul. de 2018
Hello all,
I am building a code set that I prefer to run on the GPU, but would also like to be capable of executing on a non-CUDA enabled machine (like many Macs). The issue is that during the prototyping phase, I have hidden lots of a = gpuArray(a); type commands in the code, like little landmines. I have a flag called 'useTheGPU' that nominally flips on/off GPU acceleration, and I can just put a little if statement around the gpuArray command. However, first I need to find the calls to gpuArray. There are a couple of ways to do this I can think of, but they all have issues, and I am hoping for something more efficient/ that works:
- Brute force - go through every file and do a find. Lordy, I do NOT want to do that.
- Overload the function locally - I put a dummy version of the command in the local folder with an enabled breakpoint. Every time I call gpuArray, it gets caught by the local breakpoint. The issue is that many Matlab commands, including gpuArray, do not permit overloading and will still default to the Matlab version
- Put a breakpoint in the Matlab command - usually open functionName and then dropping the breakpoint there will work, but again not with gpuArray
- Disable the GPU entirely, so gpuArray throws an error the way a Mac will - I tried to do this, but cannot figure out how. I once had my machine start in something called opengl mode, where I could not access my GPU, but I haven't reproduced that state.
- Run it on a machine without a GPU and debug there - I don't have such a machine, and the point is to be able to do the coding locally.
- Some wizardry that lets you find all calls to a function, or view the dependency tree - This would be the best shot, similar to the profiler...well, maybe I can Macgyver something out of the profiler. I will check that out next.
Any ideas heartily welcomed. -Dan
0 comentarios
Respuesta aceptada
Joss Knight
el 12 de Jul. de 2018
On Linux? Use grep. On Windows? Just use Windows Explorer and type gpuArray into the search bar in the parent folder. Or write some MATLAB code to look for the string.
You can disable the GPU by starting MATLAB and typing
setenv CUDA_VISIBLE_DEVICES -1
Más respuestas (0)
Ver también
Categorías
Más información sobre GPU Computing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!