Cuda register array resolution, cuda register

Source: Internet
Author: User

Cuda register array resolution, cuda register

About cuda register array

 

When performing Parallel Optimization on some algorithms based on cuda, in order to improve the running speed of the algorithm as much as possible, sometimes we want to use register arrays to make the algorithm fly fast, but the effect is always unsatisfactory. It's faster than useless. Why?

 

Haha, let's focus on it. We can define register arrays in the following two ways:

 

1 Inta [8];

At this time, is the defined array really the register array we want? In this definition, the compiler places the defined "register array" in the local memory, and the local memory is a space opened up in the video memory. How can the speed be faster?

 

2 int a [8] = {0, 0, 0, 0, 0, 0 };

Initialize at definition time. Do we want the register array? Not necessarily, it can only be said that there is a certain probability that we want the register array. The compiler determines whether to put the register array into local memory based on the size of the defined array. However, the size of the specific array is the register array we want!

 

Is there any way to force the register array we define to be saved in the register? I did not find it.

It seems that only multiple variables are defined.

For example, replace int a [8] with the following format:

Int a0;

Int a1;

Int a2;

Int a3;

Int a4;

Int a5;

Int a6;

Int a7;

This is just a way to define the program's versatility.

 

After talking for a long time, it seems that Jing is nonsense. Of course this is okay. Now, let me stress that if you know how to define the register array we want in cuda (instead of opening the register array in local memory), please contact me, thank you.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.