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

  • SEARCH
  • Home
  • 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 9111669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:33:40+00:00 2026-06-17T03:33:40+00:00

What parallel algorithms could I use to generate random permutations from a given set?

  • 0

What parallel algorithms could I use to generate random permutations from a given set?
Especially proposals or links to papers suitable for CUDA would be helpful.

A sequential version of this would be the Fisher-Yates shuffle.

Example:

Let S={1, 2, …, 7} be the set of source indices.
The goal is to generate n random permutations in parallel.
Each of the n permutations contains each of the source indices exactly once,
e.g. {7, 6, …, 1}.

  • 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-17T03:33:41+00:00Added an answer on June 17, 2026 at 3:33 am

    Fisher-Yates shuffle could be parallelized. For example, 4 concurrent workers need only 3 iterations to shuffle vector of 8 elements. On first iteration they swap 0<->1, 2<->3, 4<->5, 6<->7; on second iteration 0<->2, 1<->3, 4<->5, 6<->7; and on last iteration 0<->4, 1<->5, 2<->6, 3<->7.

    ParallelFisherYates

    This could be easily implemented as CUDA __device__ code (inspired by standard min/max reduction):

    const int id  = threadIdx.x;
    __shared__ int perm_shared[2 * BLOCK_SIZE];
    perm_shared[2 * id]     = 2 * id;
    perm_shared[2 * id + 1] = 2 * id + 1;
    __syncthreads();
    
    unsigned int shift = 1;
    unsigned int pos = id * 2;  
    while(shift <= BLOCK_SIZE)
    {
        if (curand(&curand_state) & 1) swap(perm_shared, pos, pos + shift);
        shift = shift << 1;
        pos = (pos & ~shift) | ((pos & shift) >> 1);
        __syncthreads();
    }
    

    Here the curand initialization code is omitted, and method swap(int *p, int i, int j) exchanges values p[i] and p[j].

    Note that the code above has the following assumptions:

    1. The length of permutation is 2 * BLOCK_SIZE, where BLOCK_SIZE is a power of 2.
    2. 2 * BLOCK_SIZE integers fit into __shared__ memory of CUDA device
    3. BLOCK_SIZE is a valid size of CUDA block (usually something between 32 and 512)

    To generate more than one permutation I would suggest to utilize different CUDA blocks. If the goal is to make permutation of 7 elements (as it was mentioned in the original question) then I believe it will be faster to do it in single thread.

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

Sidebar

Related Questions

I recenty asked a question about parallel programming algorithms which was closed quite fast
I'm getting into parallel programming and I'm studying mapreduce and other distributed algorithms. Is
Can any of STL algorithms/container operations like std::fill , std::transform be executed in parallel
Over at http://scicomp.stackexchange.com I asked this question about parallel matrix algorithms in IDL. The
I am currently developing a Scala framework for multi-process, parallel algorithms using MPJ-Express (i.e.
I was wondering: would there be any merit in attempting to create parallel algorithms
I am comparing difference in time execution of two breadth first search algorithms. Parallel
I've been working with time measuring (benchmarking) in parallel algorithms, more specific, matrix multiplication.
I am studying the Ford-Fulkerson algorithm from Cormen's Introduction to algorithms 2nd Edition. It
I am running a parallel algorithm using light threads and I am wondering how

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.