Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ distribute*tar.gz
pygpu/*.c
pygpu/*.h
pygpu/version.py
src/gpuarray/abi_version.h
src/private_config.h
Makefile.conf
1 change: 1 addition & 0 deletions pygpu/gpuarray.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ cdef extern from "Python.h":

cdef extern from "gpuarray/config.h":
int GPUARRAY_API_VERSION
int GPUARRAY_ABI_VERSION

cdef extern from "gpuarray/types.h":
ctypedef struct gpuarray_type:
Expand Down
5 changes: 5 additions & 0 deletions pygpu/gpuarray.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ def api_version():
# (library version, module version)
return (GPUARRAY_API_VERSION, 0)

def abi_version():
major_version = GPUARRAY_ABI_VERSION / 1000
minor_version = GPUARRAY_ABI_VERSION % 1000
return (major_version, minor_version)

np.import_array()

# to export the numeric value
Expand Down
14 changes: 14 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,27 @@ add_library(gpuarray-static STATIC ${GPUARRAY_SRC})
target_link_libraries(gpuarray ${CMAKE_DL_LIBS})
target_link_libraries(gpuarray-static ${CMAKE_DL_LIBS})

# Generate gpuarray/abi_version.h that contains the ABI version number.
get_target_property(GPUARRAY_ABI_VERSION gpuarray VERSION)
string(REPLACE "." ";" GPUARRAY_ABI_VERSION_NUMBERS ${GPUARRAY_ABI_VERSION})
list(GET GPUARRAY_ABI_VERSION_NUMBERS 0 GPUARRAY_ABI_VERSION_MAJOR)
list(GET GPUARRAY_ABI_VERSION_NUMBERS 1 GPUARRAY_ABI_VERSION_MINOR)
math(EXPR GPUARRAY_ABI_NUMBER "1000*${GPUARRAY_ABI_VERSION_MAJOR} + ${GPUARRAY_ABI_VERSION_MINOR}")
FILE(WRITE gpuarray/abi_version.h
"\#ifndef GPUARRAY_ABI_VERSION\n\#define GPUARRAY_ABI_VERSION ${GPUARRAY_ABI_NUMBER}\n\#endif\n"
)

# set SOVERSION and ensure it is the first part of VERSION.
set_property(TARGET gpuarray PROPERTY SOVERSION ${GPUARRAY_ABI_VERSION_MAJOR})

set(headers
gpuarray/array.h
gpuarray/blas.h
gpuarray/collectives.h
gpuarray/buffer.h
gpuarray/buffer_blas.h
gpuarray/buffer_collectives.h
gpuarray/abi_version.h
gpuarray/config.h
gpuarray/elemwise.h
gpuarray/error.h
Expand Down
2 changes: 2 additions & 0 deletions src/gpuarray/config.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef GPUARRAY_CONFIG
#define GPUARRAY_CONFIG

/* The following included file should have been generated by CMake. */
#include <gpuarray/abi_version.h>
#define GPUARRAY_API_VERSION 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove this line, as it should be in the included file. Otherwise, it is an error and not having it with a wrong value should help with that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The included file contains GPUARRAY_ABI_VERSION only, not API version !


#ifdef GPUARRAY_SHARED
Expand Down