|
1 | 1 | # Binsparse Reference Implementation
|
2 | 2 |
|
3 |
| -This is a C++ reference implementation of the [Binsparse Binary Sparse Format Specification](https://github.com/GraphBLAS/binsparse-specification). |
| 3 | +This library is a reference implementation of the [Binsparse Binary Sparse Format Specification](https://github.com/GraphBLAS/binsparse-specification) written using C++. |
| 4 | + |
| 5 | +Binsparse is a cross-platform, embeddable format for storing sparse matrices |
| 6 | +and other sparse data in an efficient binary format. This library currently |
| 7 | +only uses HDF5 as the underlying binary container format. |
| 8 | + |
| 9 | +## C++ Binsparse Interface |
| 10 | + |
| 11 | +This library provides a C++ interface for reading and writing Binsparse matrices. |
| 12 | + |
| 13 | +```cpp |
| 14 | +#include <binsparse/binsparse.hpp> |
| 15 | +int main(int argc, char** argv) { |
| 16 | + /* Read in Binsparse matrix stored in binary COO format. */ |
| 17 | + std::string file_name = "my_matrix.bsp.hdf5"; |
| 18 | + auto mat = binsparse::read_coo_matrix<float, std::size_t>(file_name); |
| 19 | + |
| 20 | + /* Here we're*/ |
| 21 | + |
| 22 | + binsparse::write_coo_matrix(file_name, mat); |
| 23 | + |
| 24 | + return 0; |
| 25 | +} |
| 26 | +``` |
| 27 | +
|
| 28 | +## Binsparse Converter |
| 29 | +
|
| 30 | +There is also a program `convert_binsparse` in the `examples` directory that can |
| 31 | +be used to convert from MatrixMarket format to Binsparse format. |
| 32 | +
|
| 33 | +```bash |
| 34 | +# Convert from MatrixMarket to Binsparse binary format using COO. |
| 35 | +bbrock@mymac:~/matrices$ ./convert_binsparse mat.mtx mat.bsp.hdf5 COO |
| 36 | +``` |
| 37 | + |
| 38 | +## Building |
| 39 | + |
| 40 | +This library uses CMake. It should be able to automatically download and build |
| 41 | +all dependencies except for: |
| 42 | + |
| 43 | +- A recent compiler supporting C++20. |
| 44 | +- libhdf5 |
| 45 | + |
| 46 | +It should be able to automatically detect the HDF5 installation on your system. |
| 47 | + |
| 48 | +```bash |
| 49 | +bbrock@mymac:~/src/binsparse-reference-impl$ cmake -B build |
| 50 | +-- The C compiler identification is AppleClang 15.0.0.15000040 |
| 51 | +-- The CXX compiler identification is AppleClang 15.0.0.15000040 |
| 52 | +-- Detecting C compiler ABI info |
| 53 | +-- Detecting C compiler ABI info - done |
| 54 | +-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped |
| 55 | +-- Detecting C compile features |
| 56 | +-- Detecting C compile features - done |
| 57 | +-- Detecting CXX compiler ABI info |
| 58 | +-- Detecting CXX compiler ABI info - done |
| 59 | +-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped |
| 60 | +-- Detecting CXX compile features |
| 61 | +-- Detecting CXX compile features - done |
| 62 | +CMake Warning (dev) at /opt/homebrew/Cellar/cmake/3.27.7/share/cmake/Modules/FetchContent.cmake:1316 (message): |
| 63 | + The DOWNLOAD_EXTRACT_TIMESTAMP option was not given and policy CMP0135 is |
| 64 | + not set. The policy's OLD behavior will be used. When using a URL |
| 65 | + download, the timestamps of extracted files should preferably be that of |
| 66 | + the time of extraction, otherwise code that depends on the extracted |
| 67 | + contents might not be rebuilt if the URL changes. The OLD behavior |
| 68 | + preserves the timestamps from the archive instead, but this is usually not |
| 69 | + what you want. Update your project to the NEW behavior or specify the |
| 70 | + DOWNLOAD_EXTRACT_TIMESTAMP option with a value of true to avoid this |
| 71 | + robustness issue. |
| 72 | +Call Stack (most recent call first): |
| 73 | + CMakeLists.txt:10 (FetchContent_Declare) |
| 74 | +This warning is for project developers. Use -Wno-dev to suppress it. |
| 75 | +
|
| 76 | +-- Found Python: /opt/homebrew/Frameworks/Python.framework/Versions/3.11/bin/python3.11 (found version "3.11.6") found components: Interpreter |
| 77 | +-- Performing Test CMAKE_HAVE_LIBC_PTHREAD |
| 78 | +-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success |
| 79 | +-- Found Threads: TRUE |
| 80 | +-- Version: 10.1.0 |
| 81 | +-- Build type: |
| 82 | +-- Performing Test HAS_NULLPTR_WARNING |
| 83 | +-- Performing Test HAS_NULLPTR_WARNING - Success |
| 84 | +-- Found HDF5: /opt/homebrew/Cellar/hdf5/1.14.2/lib/libhdf5_cpp.dylib;/opt/homebrew/Cellar/hdf5/1.14.2/lib/libhdf5.dylib;/opt/homebrew/opt/libaec/lib/libsz.dylib;/Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk/usr/lib/libz.tbd;/Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk/usr/lib/libdl.tbd;/Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk/usr/lib/libm.tbd (found version "1.14.2") found components: CXX |
| 85 | +-- Configuring done (6.1s) |
| 86 | +-- Generating done (0.1s) |
| 87 | +-- Build files have been written to: /Users/bbrock/src/binsparse-reference-impl/build |
| 88 | +bbrock@FVFJ21QKQ6LWmac:~/src/binsparse-reference-impl$ cd build/examples/ |
| 89 | +bbrock@FVFJ21QKQ6LWmac:~/src/binsparse-reference-impl/build/examples$ make -j |
| 90 | +[ 11%] Building CXX object _deps/fmt-build/CMakeFiles/fmt.dir/src/format.cc.o |
| 91 | +[ 22%] Building CXX object _deps/fmt-build/CMakeFiles/fmt.dir/src/os.cc.o |
| 92 | +[ 33%] Linking CXX static library libfmt.a |
| 93 | +[ 33%] Built target fmt |
| 94 | +[ 55%] Building CXX object examples/CMakeFiles/test.dir/test.cpp.o |
| 95 | +[ 55%] Building CXX object examples/CMakeFiles/convert_binsparse.dir/convert_binsparse.cpp.o |
| 96 | +[ 66%] Building CXX object examples/CMakeFiles/inspect_binsparse.dir/inspect_binsparse.cpp.o |
| 97 | +[ 77%] Linking CXX executable test |
| 98 | +[ 77%] Built target test |
| 99 | +[ 88%] Linking CXX executable inspect_binsparse |
| 100 | +[ 88%] Built target inspect_binsparse |
| 101 | +[100%] Linking CXX executable convert_binsparse |
| 102 | +[100%] Built target convert_binsparse |
| 103 | +bbrock@mymac:~/src/binsparse-reference-impl/build/examples$ |
| 104 | +``` |
0 commit comments