Closed golovart closed 3 years ago
You're right - it looks like HoloPy was never set up to run adda on GPUs. It's great that you identified the change that needs to be made. If you can get this working, we would welcome a pull request to add this functionality!
I tried adding a parameter like self.use_gpu
and self.gpu_id
and therefore
if self.use_gpu == True:
cmd = ['adda_ocl']
if not (self.gpu_id is None): cmd.extend(['-gpu '+str(self.gpu_id)])
elif self.n_cpu == 1:
cmd = ['adda']
elif self.n_cpu > 1:
cmd = ['mpiexec', '-n', str(self.n_cpu), 'adda_mpi']
It indeed runs adda_ocl
and nvidia-smi shows GPU usage. However, timing tests (with large refraction index) show no difference between GPU runs and 1 CPU runs, while for pure ADDA it is significant
Thanks for doing some digging on this. What ADDA calculations did you test through HoloPy? There's a fair bit of overhead to actually dispatch the scattering calculations to ADDA so the gpu (or parallel processing) advantage might only come through for longer calculations with a larger scatterer and/or many pixels to calculate.
Fixed by #370
Parameters in the init suggest only 1 or multiple cpus, and later in code, while forming 'cmd' only 2 options are considered:
If I understand correctly, the GPU run should start with
adda_ocl