简体   繁体   中英

Can CUDA texture memory be used for 32 Bytes elements?

I wonder whether texture memory can be used for 32 bytes struct?

Some friends told me that the largest element is uint4, which is 16 bytes.

Could you give me some advice?

See section 3.2.10.1.1 of the CUDA C Programming Guide :

DataType specifies the type of data that is returned when fetching the texture; Type is restricted to the basic integer and single-precision floating-point types and any of the 1-, 2-, and 4-component vector types defined in Section B.3.1;

In other words: no , you cannot use it for 32 bytes since the largest of the vector types defined is 16 bytes. Also note that you cannot use arbitrary structs, textures only work with a limited set of types.

In the latest version of the CUDA C Programming guide , section 3.2.11.1 says:

The type of a texel, which is restricted to the basic integer and single-precision floating-point types and any of the 1-, 2-, and 4-component vector types defined in char, short, int, long, longlong, float, double that are derived from the basic integer and single-precision floating-point types.

And then links to section B.3.1, which describes explicitly structures such as long4, which in my platform (x86_64) is 4*8 bytes, so maybe you could use it after all if you're willing to perform unsafe conversions from your struct to these structs. However, why do you want to do this?

Update: Just realized that the question is over two years old, shame on me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM