-
Notifications
You must be signed in to change notification settings - Fork 51
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
Julia bindings #1025
base: dev
Are you sure you want to change the base?
Julia bindings #1025
Changes from 98 commits
8de441a
b657d95
2de8c93
eee0d35
4d71540
0e6ec91
48d6024
2865845
9c81660
d33895e
492912d
5ab016c
34f11ab
d679474
828222b
4697250
bc3d5f9
2492182
8d444e8
29cd7ff
d4d0db7
b41d41e
b1801e1
e7861d6
91b07e7
5839134
933f01a
1f6559b
d7ebecb
0df99cc
e315fe8
895e060
1fe64f1
46a7b00
bcf29cc
a9955b3
b0c1fd0
2f26607
5c192e3
5c4d14f
7c663d8
d42b4d6
cbb0da4
a288938
dd9aff6
19af703
ffac9cf
f32b68b
3d23f12
88d734a
7daa833
218b67e
1e9e69c
de3d451
896daeb
1228708
d146f5f
d7eefb9
d3c042b
3c9f215
32f4fe6
b9c0bc4
9edac3b
a6a4d55
3f1a23d
84bce33
e6a18e7
46d19af
479b3d7
20cdbe7
e31818f
9c97be2
61fe000
c11fcd0
e602993
e364217
7424187
4be71b1
655febb
13ea8b4
130c167
769adbc
b381ad8
c6f63a1
f7e4424
21cecd4
8dc4076
db180de
8fb74b9
ddf4fbc
2ee34a0
a17a10d
5229a57
100a586
3b1b37c
1918464
c6fe874
d548c90
d427b19
184610f
d59773a
724806e
54a5052
fa2efa5
5d5612d
9eaec53
cac9488
5213e2e
805756f
a0b015e
26b6ca7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -231,7 +231,7 @@ jobs: | |
cmake --build build --parallel 2 | ||
ctest --test-dir build --output-on-failure | ||
|
||
gcc9_py38_pd_nompi_h5_ad2_libcpp: | ||
gcc9_py38_pd_nompi_h5_ad2_libcpp_julia: | ||
runs-on: ubuntu-20.04 | ||
if: github.event.pull_request.draft == false | ||
steps: | ||
|
@@ -240,17 +240,31 @@ jobs: | |
run: | | ||
sudo apt-get update | ||
sudo apt-get install g++ libopenmpi-dev libhdf5-openmpi-dev python3 python3-numpy python3-mpi4py python3-pandas | ||
# TODO ADIOS2 | ||
# TODO ADIOS2 | ||
# Install Julia | ||
# 1.6.7 | ||
wget https://julialang-s3.julialang.org/bin/linux/x64/1.7/julia-1.7.3-linux-x86_64.tar.gz | ||
sudo tar -xz -C /usr/local -f julia-1.7.3-linux-x86_64.tar.gz | ||
rm julia-1.7.3-linux-x86_64.tar.gz | ||
# Install cmake-easyinstall | ||
sudo curl -L -o /usr/local/bin/cmake-easyinstall https://git.io/JvLxY | ||
sudo chmod a+x /usr/local/bin/cmake-easyinstall | ||
export CEI_SUDO="sudo" | ||
# Install libcxxwrap-julia | ||
cmake-easyinstall git+https://github.com/JuliaInterop/[email protected] -DJulia_EXECUTABLE=/usr/local/julia-1.7.3/bin/julia | ||
- name: Build | ||
env: {CXXFLAGS: -Werror, PKG_CONFIG_PATH: /usr/lib/x86_64-linux-gnu/pkgconfig} | ||
run: | | ||
share/openPMD/download_samples.sh build | ||
cmake -S . -B build \ | ||
-DopenPMD_USE_PYTHON=ON \ | ||
-DopenPMD_USE_MPI=ON \ | ||
cmake -S . -B build \ | ||
-DopenPMD_USE_HDF5=ON \ | ||
-DopenPMD_USE_JULIA=ON \ | ||
-DopenPMD_USE_MPI=ON \ | ||
-DopenPMD_USE_PYTHON=ON \ | ||
-DopenPMD_USE_INVASIVE_TESTS=ON | ||
cmake --build build --parallel 2 | ||
# Install the Julia side of CxxWrap | ||
julia --eval 'using Pkg; Pkg.add("CxxWrap")' | ||
ctest --test-dir build --output-on-failure | ||
|
||
musllinux_py10: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,9 +24,15 @@ jobs: | |
brew update | ||
brew install adios2 || true | ||
brew install hdf5-mpi || true | ||
brew install julia || true | ||
brew install python || true | ||
python3 -m pip install -U mpi4py numpy pandas | ||
set -e | ||
# Install cmake-easyinstall | ||
sudo curl -L -o /usr/local/bin/cmake-easyinstall https://git.io/JvLxY | ||
sudo chmod a+x /usr/local/bin/cmake-easyinstall | ||
# Install libcxxwrap-julia | ||
cmake-easyinstall git+https://github.com/JuliaInterop/[email protected] | ||
- name: Build | ||
env: {CXXFLAGS: -Werror, MACOSX_DEPLOYMENT_TARGET: 11.0} | ||
# 10.14+ due to std::visit | ||
|
@@ -36,12 +42,15 @@ jobs: | |
run: | | ||
share/openPMD/download_samples.sh build | ||
cmake -S . -B build \ | ||
-DopenPMD_USE_PYTHON=ON \ | ||
-DopenPMD_USE_MPI=ON \ | ||
-DopenPMD_USE_HDF5=ON \ | ||
-DopenPMD_USE_ADIOS2=ON \ | ||
-DopenPMD_USE_HDF5=ON \ | ||
-DopenPMD_USE_JULIA=ON \ | ||
-DopenPMD_USE_MPI=ON \ | ||
-DopenPMD_USE_PYTHON=ON \ | ||
-DopenPMD_USE_INVASIVE_TESTS=ON | ||
cmake --build build --parallel 3 | ||
# Install the Julia side of CxxWrap | ||
julia --eval 'using Pkg; Pkg.add("CxxWrap")' | ||
ctest --test-dir build --verbose | ||
|
||
appleclang13_py: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,5 @@ build: | |
tools: | ||
python: "3.11" | ||
apt_packages: | ||
- graphviz | ||
- librsvg2-bin |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,6 +123,18 @@ Additional CMake options can be passed via individual environment variables, whi | |
|
||
.. image:: cmake.svg | ||
|
||
Using the Julia Package | ||
----------------------- | ||
|
||
A package for openPMD-api is available via the Julia Package Registry: | ||
|
||
.. code-block:: julia | ||
|
||
# We need Julia 1.7 or newer | ||
using("Pkg") | ||
Pkg.add("openPMD") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My only remaining question before merging this PR is how we should go about documentation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That sounds fine. I would point to |
||
|
||
|
||
From Source with CMake | ||
---------------------- | ||
|
||
|
@@ -147,7 +159,7 @@ Linux & OSX | |
# -DCMAKE_INSTALL_PREFIX=$HOME/somepath | ||
# for options append: | ||
# -DopenPMD_USE_...=... | ||
# e.g. for python support add: | ||
# e.g. for Python support add: | ||
# -DopenPMD_USE_PYTHON=ON -DPython_EXECUTABLE=$(which python3) | ||
cmake ../openPMD-api | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* Bindings for IO/Access | ||
* | ||
* File authors: Erik Schnetter | ||
* License: LGPL-3.0-or-later | ||
*/ | ||
|
||
#include "defs.hpp" | ||
|
||
void define_julia_Access(jlcxx::Module &mod) | ||
{ | ||
mod.add_bits<Access>("Access", jlcxx::julia_type("CppEnum")); | ||
jlcxx::stl::apply_stl<Access>(mod); | ||
|
||
mod.set_const("ACCESS_READ_ONLY", Access::READ_ONLY); | ||
mod.set_const("ACCESS_READ_WRITE", Access::READ_WRITE); | ||
mod.set_const("ACCESS_CREATE", Access::CREATE); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* Bindings for Attributable | ||
* | ||
* File authors: Erik Schnetter | ||
* License: LGPL-3.0-or-later | ||
*/ | ||
|
||
#include "defs.hpp" | ||
|
||
namespace | ||
{ | ||
struct UseType | ||
{ | ||
template <typename T> | ||
static void call(jlcxx::TypeWrapper<Attributable> type) | ||
{ | ||
type.method( | ||
"cxx_set_attribute_" + datatypeToString(determineDatatype<T>()) + | ||
"!", | ||
&Attributable::setAttribute<T>); | ||
} | ||
}; | ||
} // namespace | ||
|
||
void define_julia_Attributable(jlcxx::Module &mod) | ||
{ | ||
auto type = mod.add_type<Attributable>("CXX_Attributable"); | ||
|
||
forallJuliaTypes<UseType>(type); | ||
|
||
type.method("cxx_get_attribute", &Attributable::getAttribute); | ||
type.method("cxx_delete_attribute!", &Attributable::deleteAttribute); | ||
type.method("cxx_attributes", &Attributable::attributes); | ||
type.method("cxx_num_attributes", &Attributable::numAttributes); | ||
type.method("cxx_contains_attribute", &Attributable::containsAttribute); | ||
type.method("cxx_comment", &Attributable::comment); | ||
type.method("cxx_set_comment!", &Attributable::setComment); | ||
type.method( | ||
"cxx_series_flush", [](Attributable &attr) { attr.seriesFlush(); }); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* Bindings for Attribute | ||
* | ||
* File authors: Erik Schnetter | ||
* License: LGPL-3.0-or-later | ||
*/ | ||
|
||
#include "defs.hpp" | ||
|
||
namespace | ||
{ | ||
struct UseType | ||
{ | ||
template <typename T> | ||
static void call(jlcxx::TypeWrapper<Attribute> type) | ||
{ | ||
type.method( | ||
"cxx_get_" + datatypeToString(determineDatatype<T>()), | ||
&Attribute::get<T>); | ||
} | ||
}; | ||
} // namespace | ||
|
||
void define_julia_Attribute(jlcxx::Module &mod) | ||
{ | ||
auto type = mod.add_type<Attribute>("CXX_Attribute"); | ||
|
||
type.method("cxx_dtype", [](const Attribute &attr) { return attr.dtype; }); | ||
|
||
forallJuliaTypes<UseType>(type); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* Bindings for BaseRecordComponent | ||
* | ||
* File authors: Erik Schnetter | ||
* License: LGPL-3.0-or-later | ||
*/ | ||
|
||
#include "defs.hpp" | ||
|
||
// Define supertype relationships | ||
namespace jlcxx | ||
{ | ||
template <> | ||
struct SuperType<BaseRecordComponent> | ||
{ | ||
using type = Attributable; | ||
}; | ||
} // namespace jlcxx | ||
|
||
void define_julia_BaseRecordComponent(jlcxx::Module &mod) | ||
{ | ||
auto type = mod.add_type<BaseRecordComponent>( | ||
"CXX_BaseRecordComponent", jlcxx::julia_base_type<Attributable>()); | ||
|
||
type.method("cxx_unit_SI", &BaseRecordComponent::unitSI); | ||
type.method("cxx_reset_datatype!", &BaseRecordComponent::resetDatatype); | ||
type.method("cxx_get_datatype", &BaseRecordComponent::getDatatype); | ||
type.method("cxx_isconstant", &BaseRecordComponent::constant); | ||
type.method("cxx_available_chunks", &BaseRecordComponent::availableChunks); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's document the new optional dependencies here in docs: