N3PDF / mcgpu

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

fortranized numba #5

Closed scarlehoff closed 5 years ago

scarlehoff commented 5 years ago

There are two differences with respect to #3

Now, I have very mixed feelings about numba. On one hand it is true that it is much faster than python (if with the plain implementation it was already obvious, with importance sampling -just because it is more convoluted- it is amazing) but, on the other hand, it is like writing C code with python libraries. You cannot iterate over arrays, things have to keep a correct order, classes are not a thing etc...

I'll add comments and so to the code.

scarlehoff commented 5 years ago

Results:

Numba

VEGAS MC numba, ncalls=1000000:
Results for interation 1: 1.0068863514734332 +/- 0.0038763874874775247
Results for interation 2: 1.0001247749124316 +/- 0.0006095103217092258
Results for interation 3: 1.000058365072126 +/- 0.00031354103361556793
Results for interation 4: 0.9996772964565548 +/- 0.0003163815329884173
Results for interation 5: 1.0000089017687233 +/- 0.00032768866848104333
(0.9999456107218219, 0.0001761353858374322)
time (s): 2.3265390396118164

Python

VEGAS MC python, ncalls=1000000:
Results for interation 1: 0.9978657007216113 +/- 0.0038554557398151864
Results for interation 2: 1.000954451628871 +/- 0.0006100921886321291
Results for interation 3: 0.9993206919187996 +/- 0.00031470739925196044
Results for interation 4: 0.9996120511418793 +/- 0.0003158448099749237
Results for interation 5: 1.000328131140663 +/- 0.00033031359317361786
(0.9998339695751459, 0.00017666537787961053)
time (s): 197.74353575706482
scarrazza commented 5 years ago

A brute force motivation to like numba.

scarlehoff commented 5 years ago

Well, it's like medicine. I would not say "I like it" but it is better than dying from the flu...

scarrazza commented 5 years ago

Here the numba parallel (openmp) diagnostics.txt.

scarlehoff commented 5 years ago

Do you tell it what to parallelize or tries to be clever?

scarrazza commented 5 years ago

I am happy.