Skip to content

Instantly share code, notes, and snippets.

@ygabuev ygabuev/donothing_cuda.cu Secret
Last active May 24, 2019

Embed
What would you like to do?
void donothing_cuda(int alloc_size, int device_index, int deallocate) {
cudaSetDevice((int)device_index);
void *buffer;
cudaMalloc((void**)&buffer, alloc_size);
if (deallocate) {
cudaFree(buffer);
}
}
#include <torch/extension.h>
// CUDA forward declaration
void donothing_cuda(int alloc_size, int device_index, int deallocate);
// C++ interface
void donothing(int alloc_size, int device_index, int deallocate) {
donothing_cuda(alloc_size, device_index, deallocate);
}
// Binding to Python
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
m.def("call", &donothing, "Does exactly nothing (ok, it allocates memory)");
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.