jorisvandenbossche commented on code in PR #40385: URL: https://github.com/apache/arrow/pull/40385#discussion_r1530337665
########## python/pyarrow/includes/libarrow_memory.pxd: ########## @@ -0,0 +1,34 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# distutils: language = c++ + +from pyarrow.includes.libarrow cimport * + + +cdef extern from *: + """ + #ifdef ARROW_CUDA + #include "arrow/gpu/cuda_api.h" + #define CDefaultDeviceMemoryMapper(device_type, device_id) arrow::cuda::DefaultMemoryMapper(device_typem device_id) + #else + #include "arrow/c/bridge.h" + #define CDefaultDeviceMemoryMapper(device_type, device_id) arrow::DefaultDeviceMapper(device_type, device_id) + #endif + """ + CResult[shared_ptr[CMemoryManager]] CDefaultDeviceMemoryMapper" CDefaultDeviceMemoryMapper"( + ArrowDeviceType device_type, int64_t device_id) nogil Review Comment: This was my initial attempt to follow cython recommendations on how to handle conditional compilation, but I don't get that working. With the `#define` I get an error about *'CDefaultDeviceMemoryMapper' was not declared in this scope*. Before that I also tried with C++ `using` but that cannot be used to alias a function it seems Now, this way that would also mean that lib.so would depend on libarrow_cuda, an it might be better to keep that only a runtime dependency between the python modules (so that if you install a cuda-enabled package when cuda cannot actually be found, it doesn't error for basic functionality?) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
