N3PDF / mcgpu

Proof of concept of GPU integration
0 stars 0 forks source link

pyCuda #9

Closed scarrazza closed 5 years ago

scarrazza commented 5 years ago

Some numbers for cpp-cuda:

$ ./cpp-cuda 
For iteration 1, result: 0.78588 +- 0.07910
For iteration 2, result: 0.92347 +- 0.05658
For iteration 3, result: 0.97621 +- 0.03772
For iteration 4, result: 0.98942 +- 0.02457
For iteration 5, result: 0.99158 +- 0.01623
Final result: 0.98124 +- 0.01228
It took: 0.3828860 seconds

Some numbers for this PR:

$ python vegas_mc_pycuda.py 
VEGAS MC numba, ncalls=1000000:
Results for interation 1: 0.785875600908212 +/- 0.07909754587281996
Results for interation 2: 0.8829776344750644 +/- 0.05672589997574821
Results for interation 3: 0.943219695510895 +/- 0.04175459380823545
Results for interation 4: 0.9744406929295115 +/- 0.03049130566893956
Results for interation 5: 0.9889151600046362 +/- 0.022307278548146008
(0.9629659800421778, 0.015561754834867658)
time (s): 0.3642749786376953

Well, seems better than c++?!?

scarlehoff commented 5 years ago

I tip my hat... there is no overhead at all from the other python stuff...

scarrazza commented 5 years ago

And here this PR code without numba:

VEGAS MC numba, ncalls=1000000:
Results for interation 1: 0.785875600908212 +/- 0.07909754587281996
Results for interation 2: 0.8829776344750646 +/- 0.056725899975748215
Results for interation 3: 0.9432196955108947 +/- 0.04175459380823546
Results for interation 4: 0.9744406929295116 +/- 0.030491305668939577
Results for interation 5: 0.9889151600046369 +/- 0.022307278548146032
(0.9629659800421783, 0.01556175483486767)
time (s): 116.2196056842804
scarlehoff commented 5 years ago

Ok, so pure python can be discarded for eko :P

scarlehoff commented 5 years ago

I've been playing a bit more with this, python uses about 1.3-1.4 more memory than the C++ version (gpu memory) which in turns makes it slower as the size of the arrays grow.

There's also a few more memory movements in the python code which I imagine are the cause.

scarrazza commented 5 years ago

I start thinking that python is only good for fast prototyping and numba may help if you are lazy to convert the code into a C style library with python wrapper. ;-)

scarrazza commented 5 years ago

Ahaha, ok...