Is possible to use GPU parallel computing in R for uniroot (or equivalent)?

Viewed 235

I am trying to speedup the following code in R, which is calling uniroot on 1000 different cases using mapply (one for each equation form with each element of the vectors a, ce and w -- see below).

In order to run this code faster, I would like to use my GPU (a NVIDIA card) in order to parallelize the computation. Here is a simple example (of the actual computation):

a  = exp(seq(log(1), log(401), length.out = 1000)) - 1
ce = runif(1000, min = 0.9, max = 4)
w  = runif(1000, min = 0.9, max = 4)

fun1 = function(ce, w, a) {
  return(uniroot(function(h) ce * 0.32 * (1 - h)^-0.35  - 0.8 * ((0.0093 + 0.01) / 0.33)^(0.33 / (0.33 - 1))*(1 - 0.04) * (w * h + 0.0093 * a)^-0.16, c(0.5, 0.99999), extendInt = "yes")$root)
}

out = mapply(fun1, ce = ce, w = w, a = a) 

I read here that you can use Newton-Raphson algorithm with GPU, but I don't get how to do it. Can someone give me a hint (or a working example) on how to parallelize this?

Thank you in advance!

Note: I call this mapply function lots of time, so the actual time used by it is considerably.

0 Answers
Related