Cuda Array Assignment

Source: Internet
Author: User

Original Ask Link

Overview: Array allocations can be done through Cudamallocarray () and Cudamalloc3darray ()

1, Cudamallocarray ()

cudaerror_t cudamallocarray    (    struct Cudaarray * *     array,    const struct CUDACHANNELFORMATDESC *     Desc,    size_t     width,    size_t     height = 0,    unsigned int     flags = 0     )    

Example: 2DArray allocation

1 Cudaarray *d_volumearray;2 Cudachannelformatdesc desc = cudacreatechanneldesc (+, 0, 0, 0, cudachannelformatkindfloat) ; 3 Cudamallocarray (&d_volumearray, &desc, 4 cudamemcpytoarray (d_volumearray, 0, 0, H_volume, sizeof ( float) *128*128, cudamemcpydevicetodevice);

2, Cudamalloc3darray ()

1 cudaerror_t cudamalloc3darray    (    2     struct Cudaarray *     * array,3     const struct Cudachannelformatdesc *     desc,4     struct cudaextent     extent,5     unsigned int     flags = 0     6)    

Cases:

1 Cudachannelformatdesc channeldesc = cudacreatechanneldesc<uchar> (); 2 Cudaarray *d_volumeArray;3 Cudamalloc3darray (&d_volumearray, &channeldesc, volumsize);

Cuda Array Assignment

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.