Jorge Gabriel Siqueira
Jorge Gabriel Siqueira

Reputation: 309

Alternatives to malloc for dynamic memory allocations in CUDA kernel functions

I'm trying to compile my CUDA C code for a GPU with sm_10 architecture which does not support invoking malloc from __global__ functions.

I need to keep a tree for which the nodes are created dynamically in the GPU memory. Unfortunately, without malloc apparently I can't do that.

Is there is a way to copy an entire tree using cudaMalloc? I think that such an approach will just copy the root of my tree.

Upvotes: 0

Views: 843

Answers (1)

Vitality
Vitality

Reputation: 21455

Quoting the CUDA C Programming Guide

Dynamic global memory allocation and operations are only supported by devices of compute capability 2.x and higher.

For compute capability earlier than 2.0, the only possibilities are:

  1. Use cudaMalloc from host side to allocate as much global memory as you need in your __global__ function;
  2. Use static allocation if you know the required memory size at compile time;

Upvotes: 3

Related Questions