mallocPitch: A higher-level interface to cudaMallocPitch

Description Usage Arguments Value Author(s) References See Also Examples

Description

mallocPitch is similar to cudaMallocPitch for allocating memory for 2-dimensionsal structures, i.e. matrices. Unlike cudaMallocPitch, this function takes the name of the element type and determines the number of bytes of each element. More than this, it returns an object that is similar to what cudaMallocPitch returns, but contains more information. This allows us to directly assign an R object directly to the allocated memory without having to explicitly call cudaMemcpy2D.

One has to keep in mind that R matrices are stored in column order but the Pitch mechanism is more focused on rows in CUDA.

Usage

1
mallocPitch(width, height, elType = NA)

Arguments

width

the number of columns in the 2D object

height

the number of rows in the 2D object.

elType

the name of the element type of the array, e.g. int, float, etc.

Value

mallocPitch returns a list with elements

devPtr

a reference to the allocated memory on the GPU

pitch

the actual pitch value between the start of elements in consecutive rows.

elType

the value of elType

elSize

the number of bytes for a single element

dim

the dimension vector of the allocated space, i.e. width and height

This list has S3 class PitchMemory2D.

Author(s)

Duncan Temple Lang

References

CUDA SDK e

See Also

cudaMallocPitch and cudaMemcpy2D

Examples

1
2
3
4
5
6
## Not run: 
  AB = matrix(rnorm(30 * 5), 30, 5)
  mem = mallocPitch( ncol(AB), nrow(AB), "float")
  mem[] = t(AB)

## End(Not run)

duncantl/RCUDA documentation built on May 15, 2019, 5:26 p.m.