mumax / 3

GPU-accelerated micromagnetic simulator
Other
447 stars 150 forks source link

defregion? #319

Open Chris317 opened 1 year ago

Chris317 commented 1 year ago

The default region can only set 256 different regions. What should I do if I want to set 300 different Msats?

MathieuMoalic commented 1 year ago

It's not possible with the current mumax binaries. You can modify the source code and recompile mumax. It will probably come at a performance cost but it might not be noticeable. Anyway, if you can find a work around, you should

jplauzie commented 1 year ago

Hello,

As Mathieu mentioned, there is a limit of 256. If you need more, you will to modify the source code and recompile. You can see an existing topic on the subject here:

https://github.com/mumax/3/issues/124#issue-255113504

It is not too difficult, basically ones needs to change the regions variable from 8-bit type (bytes in Go, uint8_t in Cuda) to something larger (note this will come with a memory penalty which scales as NREGIONS squared).

Instead, I would also recommend trying to find a workaround. Often you can use less regions with some clever tricks without greatly affecting the result. For example, instead of picking 300 separate Msats, have them randomly pick from a distribution of 30 (or 250) or so. Any regions that happen to have the same value can reuse the same region parameter value.

Best, Josh L.

1eevy commented 1 year ago

Hello,

As Mathieu mentioned, there is a limit of 256. If you need more, you will to modify the source code and recompile. You can see an existing topic on the subject here:

#124 (comment)

It is not too difficult, basically ones needs to change the regions variable from 8-bit type (bytes in Go, uint8_t in Cuda) to something larger (note this will come with a memory penalty which scales as NREGIONS squared).

Instead, I would also recommend trying to find a workaround. Often you can use less regions with some clever tricks without greatly affecting the result. For example, instead of picking 300 separate Msats, have them randomly pick from a distribution of 30 (or 250) or so. Any regions that happen to have the same value can reuse the same region parameter value.

Best, Josh L.

Thanks for this guide! I want to change the limit too. I have tried to chage the 8-bit type (bytes in Go, uint8_t in Cuda) to 16-bit, but it didnot work, maybe I did not change all the regions variable that should be changed. So, can you please help to point out which files should be changed? Thanks again.