I have to use shared memory that is 64 elements in size, twice the number of banks and threads in a warp. How should I address them to yield a bank-conflict-free access?
Bank-Conflict-Free Access in shared memory
812 Views Asked by Behzad Baghapour At
2
There are 2 best solutions below
0
P O'Conbhui
On
Let's assume you're using compute capability 1.x, so your shared memory has 16 banks, and each thread has to access 2 elements in shared memory.
What you want is for a thread to access the same memory bank for both elements, so if you organize it such that the required elements are 16 away from each other, you should avoid bank conflicts.
__shared__ int shared[32];
int data = shared[base + stride * tid];
int data = shared[base + stride * tid + 16];
I used this pattern for storing complex floats, but I had an array of complex floats, so it looked like
#define TILE_WIDTH 16
__shared__ float shared[TILE_WIDTH][2*TILE_WIDTH + 1];
float real = shared[base + stride * tid];
float imag = shared[base + stride * tid + TILE_WIDTH];
Where the +1 is to avoid serialization in transposed access patterns.
Related Questions in CUDA
- direct global memory access using cuda
- Threads syncronization in CUDA
- Merge sort using CUDA: efficient implementation for small input arrays
- why cuda kernel function costs cpu?
- How to detect NVIDIA CUDA Architecture
- What is the optimal way to use additional data fields in functors in Thrust?
- cuda-memcheck fails to detect memory leak in an R package
- Understanding Dynamic Parallelism in CUDA
- C/CUDA: Only every fourth element in CudaArray can be indexed
- NVCC Cuda 5.0 on Ubuntu 12.04 /usr/lib/libudt.so file format not recognized
- Reduce by key on device array
- Does CUDA include a real c++ library?
- cuMemcpyDtoH yields CUDA_ERROR_INVALID_VALUE
- Different Kernels sharing SMx
- How many parallel threads i can run on my nvidia graphic card in cuda programming?
Related Questions in GPU
- Get GPU temperature in Android
- Can I use Julia to program my GPU & CPU?
- C: Usage of any GPU for parallel calculations
- Can I run Cuda or OpenCl on Intel processor graphics I7 (3rd or 4rd generation)
- How to get fragment coordinate in fragment shader in Metal?
- Is prefix scan CUDA sample code in gpugems3 correct?
- How many threads/work-items are used?
- When do we need two dimension threads in CUDA?
- What does a GPU kernel overhead consist of?
- Efficiently Generate a Heat Map Style Histogram using GLSL
- installing gputools on windows
- Make a dependent loop independent
- Is it possible to execute multiple instances of a CUDA program on a multi-GPU machine?
- CUDA cuBlasGetmatrix / cublasSetMatrix fails | Explanation of arguments
- Missing functions vload and vstore: OpenCL on Android
Related Questions in GPU-SHARED-MEMORY
- Use shared memory for neighboring array elements?
- CUDA Where To Declare Constant For Shared Memory Allocation
- Shared memory accessing garbage values in CUDA
- Pointless use of CUDA shared memory
- Square brackets after float4 vector type
- Shared memory and streams when launching kernel
- CUDA shared memory understanding troubles
- cuda shared memory - inconsistent results
- Copy global to shared memory
- Getting CUDA error "declaration is incompatible with previous "variable_name"
- What happens to a GPU multiprocessor's shared memory between kernel block executions?
- GPU shared memory size is very small - what can I do about it?
- Creating a shared vector with block size?
- CUDA shared memory
- Sharing highly irregular job among CUDA threads
Related Questions in MEMORY-ACCESS
- CUDA: Cuda memory accessing different than OpenCL? What is causing this illegal memory access?
- Effective Access Time
- Is LEA the only instruction in x86 with a memory operand that doesn't access memory?
- How to optimize memory access pattern / cache misses for this array decimate/downsample program?
- In CUDA, what is memory coalescing, and how is it achieved?
- OpenMP C parallelisation algorithm
- Access Violation - dereferenced ostringstream
- Non-Constant Generator Single-Pass Initialization during Construction
- Solving collisions - try to coalesce gmem access, using smem, but banks conflicts
- How to know WHAT or WHO accesses a variable in VS Debugger for C#?
- Do modern processors typically access memory faster in increasing order than decreasing order?
- Equivalent pointer probe from MSVC to GCC in a library
- How to find number of bits used in address aliasing by the cpu?
- Cuda GPUassert: an illegal memory access was encountered
- How to detect instructions that access the same memory location from assembly/objdump?
Related Questions in BANK-CONFLICT
- OpenCL bank conflict - dropping memory / corrupting data?
- Shared memory bank conflict in CUDA Fortran when loading 2D data from global memory
- Reading Shared/Local Memory Store/Load bank conflicts hardware counters for OpenCL executable under Nvidia
- Expected number of bank conflicts in shared memory at random access
- Can using kernel parameters cause bank conflicts?
- shared memory bank conflict with char array
- CUDA: overloading of shared memory to implement reduction approach with multiple arrays
- CUDA shared memory bank conflict unexpected timing
- Coalescence vs Bank conflicts (Cuda)
- purposely causing bank conflicts for shared memory on CUDA device
- CUDA memory bank conflict
- Will the same thread accessing the same memory bank twice cause conflicts?
- Do bank conflicts occur on non-GPU hardware?
- Bank-Conflict-Free Access in shared memory
- CUDA: bank conflicts between different warps?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
In case of 32-bit memory access you can use default memory access pattern.
there
strideis odd.If you have 64-bit access you can use some trick like this: