Weird question: Which memory is code executed in ?

Is there a special memory where the run-time code is executed ? Is there a way to access it from the program using pointers ? If the executed program is small, there should be much memory left to be usable for other purpose. If it would be as fast as shared-mem, it would be worth to be used.

Code is stored in video memory like everything else, although I believe it is cached. I wouldn’t recommend trying self-modifying code, if that’s what you’re thinking.

This sounds interesting. I dont want to create self-modifying code, but I thought about to use the code cache for storing additional data. Are there any informations how many kb this might be ?

… I somehow doubt you want to use the instruction cache …

Imagine the case where your warp is scheduled out to bring in another warp (while waiting on a memory transaction, for example) - the instruction cache would change radically, potentially wanting to consuming any memory you might be using in said instruction cache - adding another complexity of the scheduler having to know how much (and where) memory you’re using in said instruction cache, or the scheduler having to notify you that your cache has now been consumed - and you’ve lost all your data…

Then the possibility that your warp won’t necessarily be brought back in the same MP (I’m guessing smem and the instruction cache get dumped to video memory when the warp is scheduled out, and a new warp is scheduled in - allowing it to be brought back to ‘any’ arbitrary MP running that kernel).

Just assumptions, but I’m guessing these are the types of complexities you’d run into even if it were possible - and as such, the exact reasons nVidia don’t make it possible.

Oh, and don’t get me started on the fact the instruction cache is a hardware & cuda implementation detail - and you ‘never’ want the users of an API to have to worry about implementation specifics.