hightower8083 / synchrad

Synchrotron Radiation calculator via openCL
GNU General Public License v3.0
18 stars 11 forks source link

calculation of energy radiated #29

Closed rl3418 closed 7 months ago

rl3418 commented 8 months ago

Apart from computing the spectrum, is the code capable of calculating the net energy radiated?

hightower8083 commented 8 months ago

hi @rl3418,

Calculated spectrum is the angular-spectral energy distribution and if you resolve all radiation in the proper angular-spectral domain (defined as 'grid' in the input dict) the full integral should provide you the energy. Actually calculator object with data (either calculated or loaded from file) has methods get_full_spectrum, get_energy_spectrum and get_energy which should give you such integral.

Please check the tutorial notebooks for more details on these and other methods of SynchRad object, and let me know if you have more questions.

rl3418 commented 7 months ago

Great, thanks for the clarification.

rl3418 commented 7 months ago

Is there a way to limit the number of CPUs the code uses? I'm running this through the university jupyter resources, so I need to limit the resource usage. The program used up to 256 CPUs. This is the platform I chose and the output messages

image

hightower8083 commented 7 months ago

@rl3418, this may be a bit of a problem..

OpenCL used here is designed for heterogeneous computing, so it targets devices to do the work, and in your case the device is the whole CPU. This is typical for working with GPUs when computation gets access to all card's resources. In in pure openCL, there should exist a way to do the device fission i.e. making a sub-device out of the CPU, but I'm not sure if the pyopencl API used in synchrad gives access to advanced configurations.

On the higher level it is possible that you may configure the platform itself to limit the resources -- I don't have any experience with "Intel Runtime for openCL" that you use (you may need to see the docs), but if you could try POCL platform (available in conda), there is the environment variable POCL_CPU_MAX_CU_COUNT which you could try.

But honestly, using synchrad on CPU is not recommended due to poor performance.. In my experience with synchrad (and other openCL codes), even a gaming GPU with a few Gb of RAM typically outperforms even good CPUs. If you have an access to some GPU, I recommend to try it instead. By the way, according to the print-out your CPU seems to have 64 cores, so I guess 256 is a number of threads seen by OS.

rl3418 commented 7 months ago

Great, thanks for the suggestions. I switched to running on GPUs. For a GPU job, it is running on the whole GPU, so I don't need to deal with limiting the resources.