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 7686807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:33:48+00:00 2026-05-31T19:33:48+00:00

Im looking at this implementation of DCT using cuda: http://www.cse.nd.edu/courses/cse60881/www/source_code/dct8x8/dct8x8_kernel1.cu The part in question

  • 0

Im looking at this implementation of DCT using cuda: http://www.cse.nd.edu/courses/cse60881/www/source_code/dct8x8/dct8x8_kernel1.cu
The part in question is here:

__shared__ float CurBlockLocal1[BLOCK_SIZE2];

__global__ void CUDAkernel1DCT(float *Dst, int ImgWidth, int OffsetXBlocks, int OffsetYBlocks)
{
    // Block index
    const int bx = blockIdx.x + OffsetXBlocks;
    const int by = blockIdx.y + OffsetYBlocks;

    // Thread index (current coefficient)
    const int tx = threadIdx.x;
    const int ty = threadIdx.y;

    // Texture coordinates
    const float tex_x = (float)( (bx << BLOCK_SIZE_LOG2) + tx ) + 0.5f;
    const float tex_y = (float)( (by << BLOCK_SIZE_LOG2) + ty ) + 0.5f;

    //copy current image pixel to the first block
    CurBlockLocal1[ (ty << BLOCK_SIZE_LOG2) + tx ] = tex2D(TexSrc, tex_x, tex_y);

    //synchronize threads to make sure the block is copied
    __syncthreads();

where block size is 8 so block_size_log2 is 3.

Why is the texture coordinates defined as it is? Why do we need to use texture coordinates? What is the “<<” in Cuda?

  • 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-05-31T19:33:50+00:00Added an answer on May 31, 2026 at 7:33 pm

    To answer your questions in reverse order:

    1. As in standard C or C++, the << operator is the bitwise left shift operator. This implies that a << b is equivalent to a * 2^b where a and b are both positive integers. So code you are asking about is basically shorthand for integer power of two multiplication.
    2. As discussed in the Appendices of the Cuda programming guide, textures are indexed using floating point coordinates which are voxel centred, which is why the read arguments in the code you posted are offset by 0.5 in each direction
    3. The code you are asking about looks to have been written for an early generation of CUDA hardware which had considerably slower integer arithmetic performance than floating point. The use of bit shifting in place of power of two multiplication is mostly likely a performance optimization, and may be of no use on newer generations of CUDA hardware.

    The code you have asked about could probably been written as

    __shared__ float CurBlockLocal1[BLOCK_SIZE2];
    
    __global__ void CUDAkernel1DCT(float *Dst, int ImgWidth, int OffsetXBlocks, int OffsetYBlocks)
    {
        // Block index
        const int bx = blockIdx.x + OffsetXBlocks;
        const int by = blockIdx.y + OffsetYBlocks;
    
        // Thread index (current coefficient)
        const int tx = threadIdx.x;
        const int ty = threadIdx.y;
    
        // Texture coordinates
        const float tex_x = (float)( (bx * BLOCK_SIZE) + tx ) + 0.5f;
        const float tex_y = (float)( (by * BLOCK_SIZE) + ty ) + 0.5f;
    
        //copy current image pixel to the first block
        CurBlockLocal1[ (ty * BLOCK_SIZE) + tx ] = tex2D(TexSrc, tex_x, tex_y);
    
        ......
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Looking at this article: http://www.galloway.me.uk/tutorials/singleton-classes/ I have implemented a singleton, my question is the
More specifically, does NDK have a complete STL implementation. We're looking at this for
looking at this example of the jquery ui slider http://jqueryui.com/demos/slider/#steps i want to be
I am learning the PHP MVC pattern for my backend implementation. Looking at this
Looking at this example of named pipes using Overlapped I/O from MSDN, I am
Folks, I was looking at the implementation of string.IsNullOrWhiteSpace in: http://typedescriptor.net/browse/types/9331-System.String Here is the
I tried looking this up on here but couldnt find a proper answer. I
Looking at this jQuery example, how can I modify the code so that it
Looking in this StackOverflow question it uses the following to send emails: System.Net.Mail.SmtpClient Is
I was looking at this code of a sieve of eratosthenes but i still

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.