Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Definitions of cuda::memory::managed::allocate(device, num_bytes) #514

Closed
codecircuit opened this issue May 13, 2023 · 1 comment
Closed

Comments

@codecircuit
Copy link
Contributor

I see them in cuda/api/multi_wrapper_impls/memory.hpp but I get undefined references. Steps to reproduce:

  • change content of modified_cuda_samples/vectorAddMapped/vetcorAddMapped.cu to:
#include <algorithm>
#include <cuda/api.hpp>
#include <iostream>
#include <memory>

__global__ void vectorAdd(const float *A, const float *B, float *C,
			  int numElements) {
    int i = blockDim.x * blockIdx.x + threadIdx.x;
    if (i < numElements) {
	C[i] = A[i] + B[i];
    }
}

int main() {
    if (cuda::device::count() == 0) {
	std::cerr << "No CUDA devices on this system"
		  << "\n";
	exit(EXIT_FAILURE);
    }

    int numElements = 50000;
    size_t size = numElements * sizeof(float);
    std::cout << "[Vector addition of " << numElements << " elements]\n";

    auto device = cuda::device::current::get();
    auto buffer_A = cuda::memory::managed::allocate(device, size);
    auto buffer_B = cuda::memory::managed::allocate(device, size);
    auto buffer_C = cuda::memory::managed::allocate(device, size);

    cuda::memory::managed::free(buffer_A);
    cuda::memory::managed::free(buffer_B);
    cuda::memory::managed::free(buffer_C);

    std::cout << "Test PASSED\n";
    std::cout << "SUCCESS\n";
    return 0;
}

compile the samples with CMake build and get the error:

[  2%] Built target vectorAdd
[  3%] Building CUDA object examples/CMakeFiles/vectorAddMapped.dir/modified_cuda_samples/vectorAddMapped/vectorAddMapped.cu.o
[  4%] Linking CUDA executable bin/vectorAddMapped
/usr/bin/ld: CMakeFiles/vectorAddMapped.dir/modified_cuda_samples/vectorAddMapped/vectorAddMapped.cu.o: in function `main':
tmpxft_00008304_00000000-6_vectorAddMapped.cudafe1.cpp:(.text.startup+0x160): undefined reference to `cuda::memory::managed::allocate(cuda::device_t, unsigned long, cuda::memory::managed::initial_visibility_t)'
/usr/bin/ld: tmpxft_00008304_00000000-6_vectorAddMapped.cudafe1.cpp:(.text.startup+0x18f): undefined reference to `cuda::memory::managed::allocate(cuda::device_t, unsigned long, cuda::memory::managed::initial_visibility_t)'
/usr/bin/ld: tmpxft_00008304_00000000-6_vectorAddMapped.cudafe1.cpp:(.text.startup+0x1be): undefined reference to `cuda::memory::managed::allocate(cuda::device_t, unsigned long, cuda::memory::managed::initial_visibility_t)'
collect2: error: ld returned 1 exit status
make[2]: *** [examples/CMakeFiles/vectorAddMapped.dir/build.make:102: examples/bin/vectorAddMapped] Error 1
make[1]: *** [CMakeFiles/Makefile2:200: examples/CMakeFiles/vectorAddMapped.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
  • nvcc version 12.1.105
  • Does not happen with cuda::memory::device::allocate
eyalroz added a commit that referenced this issue May 13, 2023
…ition of `cuda::memory::managed::allocate()`.
@eyalroz eyalroz self-assigned this May 13, 2023
@eyalroz
Copy link
Owner

eyalroz commented May 13, 2023

I guess I'll need to release a 0.6.3.1 soon...

eyalroz added a commit that referenced this issue May 13, 2023
…ition of `cuda::memory::managed::allocate()`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants