simit-lang / simit

A language for computing on sparse systems
http://simit-lang.org
Other
454 stars 52 forks source link

Print function fails on GPU #115

Open touste opened 6 years ago

touste commented 6 years ago

Hi everyone, I've got an issue with the print or println function when running a simit program on the GPU, which makes debugging rather unconvenient. In the simit linker log file, I get this message: error : Undefined reference to 'printf' in '<compiled-ptx>' Could you point me to where I could define this function?

Thanks

fredrikbk commented 6 years ago

Hi @touste, I don't think the printing functionality will work on GPUs. Can you debug on the CPU?

touste commented 6 years ago

Hi @fredrikbk, thanks for your reply. Yes I usually debug on the CPU however sometimes the program behaves a bit differently on the GPU. Not havint printing capabilities on the GPU is not a major issue, I was just wondering if there was an easy way to fix it.

fredrikbk commented 6 years ago

Yes, that makes sense, but unfortunately I don't think NVidia GPUs support printing (unless it's been added without me noticing). The program behaving different is worrying though. Perhaps it's just the non-associativity of floating point numbers. I think once we get a shared-memory parallel implementation we'll be able to diagnose some of that using prints.

fredrikbk commented 6 years ago

Aside, out of curiosity, what do you use Simit for? You might be interested in knowing that we have a new student here that will be picking it up, so it should start moving again.

touste commented 6 years ago

Hi Fredrik, I'm not sure about printing support from the GPUs, although I think it's possible using cuda.

Regarding the different behaviour, here are 3 cases where I noticed a difference between CPU and GPU:

  1. Some functions are missing an implementation for the GPU, for example the cross function, or linear solver functions.
  2. If I modifying a scalar variable in the c++ file that is binded to a simit function between 2 function calls (using runsafe), it is not modified in the simit workspace.
  3. Some slightly different numerical results, but as you say it must be due to numerical errors.

Anyway, I'm glad Simit is picking up steam again. I'm using it to prototype a fast finite element code for real-time simulations of surgical procedures. In my case the GPU implementation comes handy, and SIMIT is a very efficient and elegant way to get high performance code without facing GPU programming. You probably already have a lot of ideas for future development, but here are a few things that should be easy to implement and would improve performance a lot on my side:

  1. ability to launch different mapping functions simultaneously
  2. implementation of sparse system solvers for the gpu
  3. optimize gpu block size for each kernel

Thanks!