Skip to content
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

Fix MATLAB bindings for MacOS #3950

Merged
merged 2 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion bindings/C/adios2/c/adios2_c_adios.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ adios2_adios *adios2_init_config_mpi(const char *config_file, MPI_Comm comm);

#else
#define adios2_init() adios2_init_serial()
#define adios2_init_config(config_file) adios2_init_config_seria(config_file)
Copy link
Member

Choose a reason for hiding this comment

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

Ouch. We may need to push this into the release branch too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems like no one uses the non-MPI version 🤣

#define adios2_init_config(config_file) adios2_init_config_serial(config_file)
#endif

/**
Expand Down
10 changes: 10 additions & 0 deletions bindings/Matlab/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ MEXLIBS="LDFLAGS=${ADIOS_LIBS}"
ADIOS_INC=-I${ADIOS_DIR}/include
ADIOS_LIBS=`${ADIOS_DIR}/bin/adios2-config --c-libs`

### MacOS - example using homebrew installed ADIOS2 and Xcode 15 clang
### 1) Install homebrew (https://brew.sh/) and Xcode (App Store)
### 2) brew install adios2
### OR
### 2) Compile Adios2 from scratch and update ADIOS_DIR below to match install directory
#ADIOS_DIR=/opt/homebrew/opt/adios2
#ADIOS_INC=-I${ADIOS_DIR}/include
#ADIOS_LIBS=-Wl,-rpath,${ADIOS_DIR}/lib -shared -L${ADIOS_DIR}/lib -ladios2_c -ladios2_core
#MEXLIBS="LDFLAGS=${ADIOS_LIBS}"


MEXOPTS=-largeArrayDims -DDEBUG CFLAGS="-g -std=c99 -fPIC -O0"
default:
Expand Down
4 changes: 4 additions & 0 deletions bindings/Matlab/adiosopenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])

/********************************************************/
/* Open ADIOS file now and get variables and attributes */
#if ADIOS2_USE_MPI
adiosobj = adios2_init(false);
Copy link
Member

Choose a reason for hiding this comment

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

Should this call be passing the MPI communicator into ADIOS?

Copy link
Contributor Author

@tomgade09 tomgade09 Nov 30, 2023

Choose a reason for hiding this comment

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

Honestly, I don't think so, but this is where my knowledge of ADIOS breaks down a bit....

The previous version of this line in adiosopenc.c passed false, so I imagine that it's ok. Even in the event the library uses MPI, passing an MPI communicator would require creating one (which would then require finalizing / destroying after use), which is I assume why the original author just passed false. But the makefile links against the non-MPI version of ADIOS (which is what I used to do my testing), so I'm not sure how this would behave if linked against the MPI version.

Do:

adios2_inquire_all_variables(&adios_vars, &nvars, group);
adios2_inquire_all_attributes(&adios_attrs, &nattrs, group);

or any of the other adios2 functions in adiosreadc.c or adiosclosec.c use MPI for anything? If so, maybe the best bet is to have a preprocessor assert that ADIOS2_USE_MPI is not defined (or just undefine it). It doesn't make sense in the context of MATLAB to use MPI anyway...I know this can be done, but probably isn't common.

Copy link
Contributor

Choose a reason for hiding this comment

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

We never used MPI in Matlab, and apparently false has been a value compilers could live with.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess explicitly calling adios2_adios *adios2_init_serial(void); would be the clean solution

Copy link
Member

Choose a reason for hiding this comment

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

I guess explicitly calling adios2_adios *adios2_init_serial(void); would be the clean solution

Probably so. There's some other stuff in the bindings that could use to be cleaned up (unreferenced mpi_comm_dummy variable, etc.). I was going to try to get Matlab installed for myself so I could at least try things before merging.

Copy link
Contributor Author

@tomgade09 tomgade09 Dec 1, 2023

Choose a reason for hiding this comment

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

I guess explicitly calling adios2_adios *adios2_init_serial(void); would be the clean solution

Done.

#else
adiosobj = adios2_init();
#endif
group = adios2_declare_io(adiosobj, "matlabiogroup"); // name is arbitrary
fp = adios2_open(group, fname, adios2_mode_read);
if (fp == NULL)
Expand Down
Loading