libocca / occa

Portable and vendor neutral framework for parallel programming on heterogeneous platforms.
https://libocca.org
MIT License
386 stars 82 forks source link

build fails when setting ENABLE_METAL=OFF on macOS #668

Open BenWibking opened 1 year ago

BenWibking commented 1 year ago

When I set ENABLE_METAL=OFF in ./configure-cmake.sh, I get a linker error:

[ 63%] Linking CXX shared library lib/libocca.dylib
Undefined symbols for architecture arm64:
  "occa::api::metal::function_t::run(occa::api::metal::commandQueue_t&, occa::dim, occa::dim, std::__1::vector<occa::kernelArgData, std::__1::allocator<occa::kernelArgData> > const&)", referenced from:
      occa::metal::kernel::deviceRun() const in kernel.cpp.o
  "occa::api::metal::function_t::free()", referenced from:
      occa::metal::kernel::~kernel() in kernel.cpp.o
      occa::metal::kernel::~kernel() in kernel.cpp.o
      occa::metal::kernel::~kernel() in kernel.cpp.o
  "occa::api::metal::function_t::function_t(occa::api::metal::function_t const&)", referenced from:
      occa::metal::device::buildOKLKernelFromBinary(occa::hash_t, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, occa::lang::sourceMetadata_t&, occa::lang::sourceMetadata_t&, occa::json const&) in device.cpp.o
      occa::metal::kernel::kernel(occa::modeDevice_t*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, occa::api::metal::device_t, occa::api::metal::function_t, occa::json const&) in kernel.cpp.o
      occa::metal::kernel::kernel(occa::modeDevice_t*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, occa::api::metal::device_t, occa::api::metal::function_t, occa::json const&) in kernel.cpp.o
  "occa::api::metal::function_t::function_t()", referenced from:
      occa::metal::kernel::kernel(occa::modeDevice_t*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, occa::json const&) in kernel.cpp.o
      occa::metal::kernel::kernel(occa::modeDevice_t*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, occa::json const&) in kernel.cpp.o
  "occa::api::metal::commandQueue_t::free()", referenced from:
      occa::metal::stream::~stream() in stream.cpp.o
      occa::metal::stream::~stream() in stream.cpp.o
      occa::metal::stream::~stream() in stream.cpp.o
  "occa::api::metal::commandQueue_t::finish()", referenced from:
      occa::metal::stream::finish() in stream.cpp.o
  "occa::api::metal::commandQueue_t::memcpy(void*, occa::api::metal::buffer_t const&, unsigned long long, unsigned long long, bool)", referenced from:
      occa::metal::memory::copyTo(void*, unsigned long long, unsigned long long, occa::json const&) const in memory.cpp.o
  "occa::api::metal::commandQueue_t::memcpy(occa::api::metal::buffer_t&, unsigned long long, void const*, unsigned long long, bool)", referenced from:
      occa::metal::memory::copyFrom(void const*, unsigned long long, unsigned long long, occa::json const&) in memory.cpp.o
  "occa::api::metal::commandQueue_t::memcpy(occa::api::metal::buffer_t&, unsigned long long, occa::api::metal::buffer_t const&, unsigned long long, unsigned long long, bool)", referenced from:
      occa::metal::memory::copyFrom(occa::modeMemory_t const*, unsigned long long, unsigned long long, unsigned long long, occa::json const&) in memory.cpp.o
      occa::metal::memoryPool::memcpy(occa::modeBuffer_t*, long long, occa::modeBuffer_t*, long long, unsigned long long) in memoryPool.cpp.o
  "occa::api::metal::commandQueue_t::commandQueue_t(occa::api::metal::commandQueue_t const&)", referenced from:
      occa::metal::device::createStream(occa::json const&) in device.cpp.o
      occa::metal::device::wrapStream(void*, occa::json const&) in device.cpp.o
      occa::metal::stream::stream(occa::modeDevice_t*, occa::json const&, occa::api::metal::commandQueue_t, bool) in stream.cpp.o
      occa::metal::stream::stream(occa::modeDevice_t*, occa::json const&, occa::api::metal::commandQueue_t, bool) in stream.cpp.o
  "occa::api::metal::commandQueue_t::commandQueue_t()", referenced from:
      occa::metal::device::device(occa::json const&) in device.cpp.o
  "occa::api::metal::commandQueue_t::operator=(occa::api::metal::commandQueue_t const&)", referenced from:
      occa::metal::device::device(occa::json const&) in device.cpp.o
  "occa::api::metal::getDeviceCount()", referenced from:
      occa::metal::metalMode::init() in registration.cpp.o
      occa::metal::metalMode::getDescription() in registration.cpp.o
      occa::metal::metalMode::getDeviceCount(occa::json const&) in registration.cpp.o
  "occa::api::metal::event_t::waitUntilCompleted()", referenced from:
      occa::metal::device::waitFor(occa::streamTag) in device.cpp.o
  "occa::api::metal::event_t::free()", referenced from:
      occa::metal::streamTag::~streamTag() in streamTag.cpp.o
      occa::metal::streamTag::~streamTag() in streamTag.cpp.o
      occa::metal::streamTag::~streamTag() in streamTag.cpp.o
  "occa::api::metal::event_t::event_t(occa::api::metal::event_t const&)", referenced from:
      occa::metal::streamTag::streamTag(occa::modeDevice_t*, occa::api::metal::event_t) in streamTag.cpp.o
      occa::metal::streamTag::streamTag(occa::modeDevice_t*, occa::api::metal::event_t) in streamTag.cpp.o
  "occa::api::metal::buffer_t::free()", referenced from:
      occa::metal::buffer::~buffer() in buffer.cpp.o
      occa::metal::buffer::~buffer() in buffer.cpp.o
      occa::metal::buffer::~buffer() in buffer.cpp.o
  "occa::api::metal::buffer_t::buffer_t(void*)", referenced from:
      occa::metal::buffer::buffer(occa::modeDevice_t*, unsigned long long, occa::json const&) in buffer.cpp.o
      occa::metal::buffer::buffer(occa::modeDevice_t*, unsigned long long, occa::json const&) in buffer.cpp.o
      occa::metal::buffer::wrapMemory(void const*, unsigned long long) in buffer.cpp.o
      occa::metal::memory::~memory() in memory.cpp.o
      occa::metal::memory::~memory() in memory.cpp.o
      occa::metal::memory::memory(occa::metal::buffer*, unsigned long long, long long) in memory.cpp.o
      occa::metal::memory::memory(occa::metal::buffer*, unsigned long long, long long) in memory.cpp.o
      ...
  "occa::api::metal::buffer_t::operator=(occa::api::metal::buffer_t const&)", referenced from:
      occa::metal::buffer::malloc(unsigned long long) in buffer.cpp.o
      occa::metal::buffer::wrapMemory(void const*, unsigned long long) in buffer.cpp.o
      occa::metal::memory::~memory() in memory.cpp.o
      occa::metal::memory::~memory() in memory.cpp.o
      occa::metal::memory::memory(occa::metal::buffer*, unsigned long long, long long) in memory.cpp.o
      occa::metal::memory::memory(occa::metal::buffer*, unsigned long long, long long) in memory.cpp.o
      occa::metal::memory::memory(occa::metal::memoryPool*, unsigned long long, long long) in memory.cpp.o
      ...
  "occa::api::metal::device_t::free()", referenced from:
      occa::metal::device::~device() in device.cpp.o
  "occa::api::metal::device_t::device_t(void*)", referenced from:
      occa::metal::device::device(occa::json const&) in device.cpp.o
      occa::metal::kernel::kernel(occa::modeDevice_t*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, occa::json const&) in kernel.cpp.o
      occa::metal::kernel::kernel(occa::modeDevice_t*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, occa::json const&) in kernel.cpp.o
  "occa::api::metal::device_t::device_t(occa::api::metal::device_t const&)", referenced from:
      occa::metal::device::buildOKLKernelFromBinary(occa::hash_t, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, occa::lang::sourceMetadata_t&, occa::lang::sourceMetadata_t&, occa::json const&) in device.cpp.o
      occa::metal::kernel::kernel(occa::modeDevice_t*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, occa::api::metal::device_t, occa::api::metal::function_t, occa::json const&) in kernel.cpp.o
      occa::metal::kernel::kernel(occa::modeDevice_t*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, occa::api::metal::device_t, occa::api::metal::function_t, occa::json const&) in kernel.cpp.o
  "occa::api::metal::device_t::operator=(occa::api::metal::device_t const&)", referenced from:
      occa::metal::device::device(occa::json const&) in device.cpp.o
  "occa::api::metal::getDevice(int)", referenced from:
      occa::metal::device::device(occa::json const&) in device.cpp.o
      occa::metal::metalMode::getDescription() in registration.cpp.o
  "occa::api::metal::commandQueue_t::createEvent() const", referenced from:
      occa::metal::device::tagStream() in device.cpp.o
  "occa::api::metal::event_t::getTime() const", referenced from:
      occa::metal::streamTag::getTime() in streamTag.cpp.o
  "occa::api::metal::buffer_t::getPtr() const", referenced from:
      occa::metal::memory::memory(occa::metal::buffer*, unsigned long long, long long) in memory.cpp.o
      occa::metal::memory::memory(occa::metal::buffer*, unsigned long long, long long) in memory.cpp.o
      occa::metal::memory::memory(occa::metal::memoryPool*, unsigned long long, long long) in memory.cpp.o
      occa::metal::memoryPool::setPtr(occa::modeMemory_t*, occa::modeBuffer_t*, long long) in memoryPool.cpp.o
  "occa::api::metal::device_t::buildKernel(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const", referenced from:
      occa::metal::device::buildOKLKernelFromBinary(occa::hash_t, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, occa::lang::sourceMetadata_t&, occa::lang::sourceMetadata_t&, occa::json const&) in device.cpp.o
  "occa::api::metal::device_t::getMemorySize() const", referenced from:
      occa::metal::device::memorySize() const in device.cpp.o
      occa::metal::metalMode::getDescription() in registration.cpp.o
  "occa::api::metal::device_t::getMaxInnerDims() const", referenced from:
      occa::metal::kernel::maxInnerDims() const in kernel.cpp.o
  "occa::api::metal::device_t::getMaxOuterDims() const", referenced from:
      occa::metal::kernel::maxOuterDims() const in kernel.cpp.o
  "occa::api::metal::device_t::createCommandQueue() const", referenced from:
      occa::metal::device::device(occa::json const&) in device.cpp.o
  "occa::api::metal::device_t::malloc(unsigned long long, void const*) const", referenced from:
      occa::metal::buffer::malloc(unsigned long long) in buffer.cpp.o
  "occa::api::metal::device_t::getName() const", referenced from:
      occa::metal::metalMode::getDescription() in registration.cpp.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [lib/libocca.dylib] Error 1
make[1]: *** [CMakeFiles/libocca.dir/all] Error 2
make: *** [all] Error 2
kris-rowe commented 1 month ago

@BenWibking Does #751 resolve this or are we missing some definitions in polyfill.hpp for the metal backend?