Alpaka: BlockSharedMemStMember: Reuse of share variables not working

Created on 26 Mar 2021  路  7Comments  路  Source: alpaka-group/alpaka

https://github.com/alpaka-group/alpaka/blob/8eea24392234dc5a913f125b531ea6545c161558/include/alpaka/block/shared/st/BlockSharedMemStMember.hpp#L62-L65

The BlockSharedMemStMember static shared memory block is not cleared, so that the already allocated variables can be reused in the next block if the instance lives outside of the grid loop, like in TaskKernelCpuSerial

https://github.com/alpaka-group/alpaka/blob/8eea24392234dc5a913f125b531ea6545c161558/include/alpaka/kernel/TaskKernelCpuSerial.hpp#L101

For each call location of the shared alloc, a unique ID should be generated and identify the variable, so it can be returned later for a call from the same location.

@psychocoderHPC Some part of this does not work: TaskKernelCpuSerial keeps allocating new variables in each iteration of the grid loop, eventually overflowing the underlying memory and overriding other parts of the accelerator instance, including the pointer m_mem in BlockSharedMemStMember.

Bug

Most helpful comment

Although my fix is a bit different: Move the return into the loop instead of the break.

All 7 comments

I can actually not reproduce this issue in the alpaka testblockSharedSt. It occurs in picongpu+pmacc, where this allocation receives new memory in each grid iteration in the SPEC example.

The BlockSharedMemStMember static shared memory block is not cleared, so that the already allocated variables can be reused in the next block if the instance lives outside of the grid loop, like in TaskKernelCpuSerial

That the shared memory is not cleared is the correct behavior. There is no need to clear it because all blocks of the same kernel will have the same static shared memory allocations, therefore we can and should reuse already allocated memory.

Note: PIConGPU/cupla is currently using alpaka 0.6.0 where the shared memory fix #1258 is not included.

@jkelling Do you patched the alpaka version used by cupla by hand?

Note: PIConGPU/cupla is currently using alpaka 0.6.0 where the shared memory fix #1258 is not included.

@jkelling Do you patched the alpaka version used by cupla by hand?

Yes. I used alpake 0.6.1 (branch, the).

The issue is, that getVarPtr() ignored the last declared var.

Note: PIConGPU/cupla is currently using alpaka 0.6.0 where the shared memory fix #1258 is not included.
@jkelling Do you patched the alpaka version used by cupla by hand?

Yes. I used alpake 0.6.1.

The issue is, that getVarPtr() ignored the last declared var.

This is a good hint. I think I found the issue. I need to write next week first a reproducer and will fix it.

Already done (test and fix) in #1280

Although my fix is a bit different: Move the return into the loop instead of the break.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tdd11235813 picture tdd11235813  路  4Comments

ax3l picture ax3l  路  5Comments

BenjaminW3 picture BenjaminW3  路  6Comments

BenjaminW3 picture BenjaminW3  路  5Comments

mxmlnkn picture mxmlnkn  路  5Comments