cudaMalloc
#include <iostream>
#include <cuda_runtime.h>
int main() {
// Allocate device memory
int* deviceArray;
cudaMalloc((void)&deviceArray, sizeof(int) * 10);
// Check for allocation success
if (deviceArray == nullptr) {
std::cerr << "cudaMalloc failed." << std::endl;
return -1;
}
// Free device memory
cudaFree(deviceArray);
return 0;
}