FLAMEGPU / FLAMEGPU2

FLAME GPU 2 is a GPU accelerated agent based modelling framework for CUDA C++ and Python
https://flamegpu.com
MIT License
99 stars 19 forks source link

Wrapped MsgSpatial interaction radius factor bug #1177

Open ptheywood opened 5 months ago

ptheywood commented 5 months ago

1160 added checks that comm radii are a factor of the environment when using spacial comms with seatbelts enabled.

This seems to be incorrectly triggering in some cases, including the python_native example.

python3 ../examples/python_native/boids_spatial3D_wrapped/boids_spatial3D.py -t  -v
FLAME GPU 2.0.0-rc.2+25a37160
Simulation configuration:
        Random Seed: 1706546446
        Steps: 1
RTC Initialisation Processing time: 26.107000 s
Init Function Processing time: 0.000000 s
Processing Simulation Step 0
Traceback (most recent call last):
  File "/users/pheywood/flamegpu/FLAMEGPU2/build-gh-123/../examples/python_native/boids_spatial3D_wrapped/boids_spatial3D.py", line 430, in <module>
    cudaSimulation.simulate()
  File "/users/pheywood/flamegpu/FLAMEGPU2/build-gh-123/lib/Release/python/venv/lib64/python3.9/site-packages/pyflamegpu/pyflamegpu.py", line 9255, in simulate
    return _pyflamegpu.CUDASimulation_simulate(self, *args)
pyflamegpu.pyflamegpu.FLAMEGPURuntimeException: (DeviceError) Device function 'inputdata' reported 40000 errors.
First error:
flamegpu/runtime/messaging/MessageSpatial3D/MessageSpatial3DDevice.cuh(545)[52,0,0][0,0,0]:
Spatial messaging radius (0.05) is not a factor of environment dimensions (1, 1, 1), this is unsupported for the wrapped iterator, MessageSpatial3D::In::wrap().

Probably due to inexact floating point stuff.

This needs fixing, and the test suite(s) expanding to cover a broader range of cases / edge cases.

Additionally, this check is currenrlty doing expensive ops per thread on device (when seatbelts enabled) which could instead be done once on the host, then a single bool / bit being set on device and read when the iterator is requested.