FLAMEGPU / FLAMEGPU2

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

MsgBucket, Optional output before buffer allocated exception. #1054

Closed Robadob closed 1 year ago

Robadob commented 1 year ago

Exception thrown here, because getReadPtr() reported the buffer hadn't been allocated yet.

https://github.com/FLAMEGPU/FLAMEGPU2/blob/c5007d284da9d8efbf0e937bb02034f571a7b0ef/src/flamegpu/runtime/messaging/MessageBucket.cu#L112

This fixes the error, but will need to write a proper test both for valid PBM after zero message and zero message first output.

    if (!MESSAGE_COUNT) {
        gpuErrchk(cudaMemsetAsync(hd_data.PBM, 0x00000000, (bucketCount + 1) * sizeof(unsigned int), stream));
        gpuErrchk(cudaStreamSynchronize(stream));
        return;
    }

I expect this may affect spatial messages too as they have similar code.