开发者

Can CUDA texture memory be used for 32 Bytes elements?

开发者 https://www.devze.com 2023-03-31 17:32 出处:网络
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.

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 advic开发者_运维知识库e?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号