about the function of cudamalloc

Hi guys:
Does anyone know the difference between functions
1/device NV_WEAK cudaError_t cudamalloc() (in cuda_device_runtime_api.h) and 2/extern host cudart_builtin cudaError_t CUDARTAPI cudaMalloc() (in cuda_runtime_api.h).

how can I to decide which one to use and I want to use 2.but the nsight located to 1. Is there any decleration need to make ?



That function prototype doesn’t exist in the cuda_device_runtime_api.h file. It should be cudaMalloc (note the capital M). (Did you actually type this in?)

The one decorated with device is usable in device code only. That’s why it is in the device runtime api. The one decorated with host is usable in host code only.

The one decorated with device is a thin wrapper around in-kernel malloc:



Thanks for you reply fistly.
I agree with you. My environment is Nsight and I write cudaMalloc() in a host function but when I seclect cudaMalloc and clicked declearation, the location of fucntion defination is in cuda_device_runtime_api.h.

So I want to make some change to use the cudaMalloc in cuda_runtime_api.h
But I do not know how to modify.

Best regards

Do you have any include statements in your file? If so, what are they?

Yes. I write like this

#include “JSphGpu_ker.h”
#include “JBlockSizeAuto.h”
#include “JLog2.h”
#include <math_constants.h>
#include “cuda_runtime_api.h”

but it is useless.

This is something associated with the syntax parsing in the GUI and is not something that will affect proper code generation. However, you could file a bug if you wish. The instructions are linked at the top of this forum in a sticky post.