Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8683995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:11:06+00:00 2026-06-12T22:11:06+00:00

Let A be a properly aligned array of 32-bit integers in shared memory. If

  • 0

Let A be a properly aligned array of 32-bit integers in shared memory.

If a single warp tries to fetch elements of A at random, what is the expected number of bank conflicts?

In other words:

__shared__ int A[N];          //N is some big constant integer
...
int v = A[ random(0..N-1) ];  // <-- expected number of bank conflicts here?

Please assume Tesla or Fermi architecture. I don’t want to dwell into 32-bit vs 64-bit bank configurations of Kepler. Also, for simplicity, let us assume that all the random numbers are different (thus no broadcast mechanism).

My gut feeling suggests a number somewhere between 4 and 6, but I would like to find some mathematical evaluation of it.


I believe the problem can be abstracted out from CUDA and presented as a math problem. I searched it as an extension to Birthday Paradox, but I found really scary formulas there and didn’t find a final formula. I hope there is a simpler way…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T22:11:07+00:00Added an answer on June 12, 2026 at 10:11 pm

    I assume fermi 32-bank shared memory where each 4 consequent bytes are stored in consequent banks. Using following code:

    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>
    #define NBANK 32
    #define N 7823
    #define WARPSIZE 32
    
    
    #define NSAMPLE 10000
    
    int main(){
        srand ( time(NULL) );
    
        int i=0,j=0;
        int *conflictCheck=NULL;
        int *randomNumber=NULL;
        int *statisticCheck=NULL;
    
        conflictCheck=(int*)malloc(sizeof(int)*NBANK);
        randomNumber=(int*)malloc(sizeof(int)*WARPSIZE);
        statisticCheck=(int*)malloc(sizeof(int)*(NBANK+1));
        while(i<NSAMPLE){
            // generate a sample warp shared memory access
            for(j=0; j<WARPSIZE; j++){
                randomNumber[j]=rand()%NBANK;
            }
            // check the bank conflict
            memset(conflictCheck, 0, sizeof(int)*NBANK);
            int max_bank_conflict=0;
            for(j=0; j<WARPSIZE; j++){
                conflictCheck[randomNumber[j]]++;
                max_bank_conflict = max_bank_conflict<conflictCheck[randomNumber[j]]? conflictCheck[randomNumber[j]]: max_bank_conflict;
            }
            // store statistic
            statisticCheck[max_bank_conflict]++;
    
            // next iter
            i++;
        }
        // report statistic
        printf("Over %d random shared memory access, there found following precentages of bank conflicts\n");
        for(i=0; i<NBANK+1; i++){
            //
            printf("%d -> %6.4f\n",i,statisticCheck[i]/(float)NSAMPLE);
        }
        return 0;
    }
    

    I got following output:

    Over 0 random shared memory access, there found following precentages of bank conflicts
    0 -> 0.0000
    1 -> 0.0000
    2 -> 0.0281
    3 -> 0.5205
    4 -> 0.3605
    5 -> 0.0780
    6 -> 0.0106
    7 -> 0.0022
    8 -> 0.0001
    9 -> 0.0000
    10 -> 0.0000
    11 -> 0.0000
    12 -> 0.0000
    13 -> 0.0000
    14 -> 0.0000
    15 -> 0.0000
    16 -> 0.0000
    17 -> 0.0000
    18 -> 0.0000
    19 -> 0.0000
    20 -> 0.0000
    21 -> 0.0000
    22 -> 0.0000
    23 -> 0.0000
    24 -> 0.0000
    25 -> 0.0000
    26 -> 0.0000
    27 -> 0.0000
    28 -> 0.0000
    29 -> 0.0000
    30 -> 0.0000
    31 -> 0.0000
    32 -> 0.0000
    

    We can come to conclude that 3 to 4 way conflict is the most likely with random access. You can tune the run with different N (number of elements in array), NBANK (number of banks in shared memory), WARPSIZE (warp size of machine), and NSAMPLE (number of random shared memory accesses generated to evaluate the model).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My array isn't being sorted properly. Can someone let me know what I am
Let's say that some function returns object reference. How one should properly spell: this
Can someone provide a simple example of how to properly use Html.RadioButtonFor? Let's say
Let's see if I can describe this properly... I have an abstract class that
Let's assume I have a c++ class that have properly implemented a copy constructor
I want to find people around X miles let me explain it properly. I
I'm having trouble getting the let hand side tabs here to show up properly
Let's see if I can explain this properly. I am (unfortunately) using Access. I
I may not have framed the query properly. So let me explain the problem
Is there any way to let JAXB properly prints xmlns:xsi and xsi:nill on nillable

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.