How to set shared memory size to a specific value?

Hi, I found that the shared memory size can be set to 0, 8, 16, 32, 64 or 100 KB for devices of compute capabilities 8.6 and 8.9 in https://docs.nvidia.com/cuda/cuda-c-programming-guide/#shared-memory-8-x, but there are just 3 choices: cudaSharedmemCarveoutDefault , cudaSharedmemCarveoutMaxL1 , or cudaSharedmemCarveoutMaxShared, so what can I do to set shared memory to just like 8KB?
Could anyone help to solve this problem?

Those are just three pre-defined symbolic names for particular percentages, but programmers can specify any desired percentage for the carveout, as noted in the first part of the relevant sentence (my bolding):

The API can specify the carveout either as an integer percentage of the maximum supported shared memory capacity of 164 KB for devices of compute capability 8.0 and 8.7 and 100 KB for devices of compute capabilities 8.6 and 8.9 respectively, or as one of the following values: {cudaSharedmemCarveoutDefault, cudaSharedmemCarveoutMaxL1, or cudaSharedmemCarveoutMaxShared.

Thanks for your reply!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.