Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 1 addition & 3 deletions .github/workflows/dependencies-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

set -eu -o pipefail

export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=FALSE

brew install open-mpi automake
brew install open-mpi automake m4 libtool

# libfabric
wget https://github.com/ofiwg/libfabric/archive/refs/tags/v1.15.2.tar.gz
Expand Down
3 changes: 2 additions & 1 deletion docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ PDC object APIs
* pdc: PDC class ID, returned from PDCInit
* Output:
* Local object ID
* Open a PDC ID created previously by name.
* Open a PDC ID created previously by name, if an object is just created or already opened,
return the same obj_id. Each open requires a close.
* For developers: see pdc_obj.c. Need to communicate with servers for metadata of the object.

* perr_t PDCobj_close(pdcid_t obj_id)
Expand Down
20 changes: 20 additions & 0 deletions src/api/pdc_obj/pdc_obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,29 @@ PDCobj_open_common(const char *obj_name, pdcid_t pdc, int is_col)
pdcid_t obj_prop;
size_t i;
uint32_t metadata_server_id;
obj_handle * oh;
struct pdc_obj_info * info;
int is_opened = 0;

FUNC_ENTER(NULL);

// Search if the object has already been opened
oh = PDCobj_iter_start(pdc);
while (!PDCobj_iter_null(oh)) {
info = PDCobj_iter_get_info(oh);
if (strcmp(obj_name, info->name) == 0) {
is_opened = 1;
break;
}
oh = PDCobj_iter_next(oh, pdc);
}

if (is_opened) {
ret_value = info->local_id;
PDC_inc_ref(info->local_id);
goto done;
}

p = (struct _pdc_obj_info *)PDC_malloc(sizeof(struct _pdc_obj_info));
if (!p)
PGOTO_ERROR(0, "PDC object memory allocation failed");
Expand Down
29 changes: 25 additions & 4 deletions src/tests/open_obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ main(int argc, char **argv)
else {
LOG_ERROR("Rank %d Fail to create object!\n", rank);
ret_value = 1;
goto done;
}
// create second object
sprintf(obj_name2, "o2_%d", rank);
Expand All @@ -92,30 +93,39 @@ main(int argc, char **argv)
else {
LOG_ERROR("Rank %d Fail to create object!\n", rank);
ret_value = 1;
goto done;
}

// open first object twice
open11 = PDCobj_open(obj_name1, pdc);
open11 = PDCobj_open(obj_name1, cont);
if (open11 == 0) {
LOG_ERROR("Rank %d Fail to open object o1\n", rank);
ret_value = 1;
goto done;
}
else {
LOG_INFO("Rank %d Open object o1\n", rank);
}
open12 = PDCobj_open(obj_name1, pdc);
open12 = PDCobj_open(obj_name1, cont);
if (open12 == 0) {
LOG_ERROR("Rank %d Fail to open object o1\n", rank);
ret_value = 1;
goto done;
}
else if (open12 != open11) {
LOG_ERROR("Rank %d opened object o1 with different ID %llu / %llu\n", rank, open12, open11);
ret_value = 1;
goto done;
}
else {
LOG_INFO("Rank %d Open object o1\n", rank);
LOG_INFO("Rank %d Re-open object o1\n", rank);
}
// open second object once
open21 = PDCobj_open(obj_name2, pdc);
open21 = PDCobj_open(obj_name2, cont);
if (open21 == 0) {
LOG_ERROR("Rank %d Fail to open object o2\n", rank);
ret_value = 1;
goto done;
}
else {
LOG_INFO("Rank %d Open object o2\n", rank);
Expand All @@ -124,34 +134,39 @@ main(int argc, char **argv)
if (PDCobj_close(obj1) < 0) {
LOG_ERROR("Rank %d Fail to close object o1\n", rank);
ret_value = 1;
goto done;
}
else {
LOG_INFO("Rank %d Successfully closed object o1\n", rank);
}
if (PDCobj_close(open11) < 0) {
LOG_ERROR("Rank %d Fail to close object open11\n", rank);
ret_value = 1;
goto done;
}
else {
LOG_INFO("Rank %d Successfully closed object open11\n", rank);
}
if (PDCobj_close(open12) < 0) {
LOG_ERROR("Rank %d Fail to close object open12\n", rank);
ret_value = 1;
goto done;
}
else {
LOG_INFO("Rank %d Successfully closed object open12\n", rank);
}
if (PDCobj_close(obj2) < 0) {
LOG_ERROR("Rank %d Fail to close object o2\n", rank);
ret_value = 1;
goto done;
}
else {
LOG_INFO("Rank %d Successfully closed object o2\n", rank);
}
if (PDCobj_close(open21) < 0) {
LOG_ERROR("Rank %d Fail to close object open21\n", rank);
ret_value = 1;
goto done;
}
else {
LOG_INFO("Rank %d Successfully closed object open21\n", rank);
Expand All @@ -160,6 +175,7 @@ main(int argc, char **argv)
if (PDCcont_close(cont) < 0) {
LOG_ERROR("Rank %d Fail to close container c1\n", rank);
ret_value = 1;
goto done;
}
else {
LOG_INFO("Rank %d Successfully closed container c1\n", rank);
Expand All @@ -168,6 +184,7 @@ main(int argc, char **argv)
if (PDCprop_close(obj_prop) < 0) {
LOG_ERROR("Rank %d Fail to close property\n", rank);
ret_value = 1;
goto done;
}
else {
LOG_INFO("Rank %d Successfully closed object property\n", rank);
Expand All @@ -176,6 +193,7 @@ main(int argc, char **argv)
if (PDCprop_close(cont_prop) < 0) {
LOG_ERROR("Rank %d Fail to close property\n", rank);
ret_value = 1;
goto done;
}
else {
LOG_INFO("Rank %d Successfully closed container property\n", rank);
Expand All @@ -184,7 +202,10 @@ main(int argc, char **argv)
if (PDCclose(pdc) < 0) {
LOG_ERROR("Rank %d Fail to close PDC\n", rank);
ret_value = 1;
goto done;
}

done:
#ifdef ENABLE_MPI
MPI_Finalize();
#endif
Expand Down
Loading