Skip to content

Commit

Permalink
Update ub for dspaces_aget when data bounds constrict the result.
Browse files Browse the repository at this point in the history
  • Loading branch information
philip-davis committed Nov 13, 2023
1 parent 820e3a9 commit 90ba4cc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 4 additions & 1 deletion bindings/python/dspaces_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ PyObject *wrapper_dspaces_get(PyObject *clientppy, const char *name,
lb[i] = PyLong_AsLong(item);
item = PyTuple_GetItem(ubt, i);
ub[i] = PyLong_AsLong(item);
dims[i] = (ub[i] - lb[i]) + 1;
}

dspaces_aget(*clientp, name, version, ndim, lb, ub, &data, &tag, timeout);
Expand All @@ -188,6 +187,10 @@ PyObject *wrapper_dspaces_get(PyObject *clientppy, const char *name,
descr = PyArray_DescrNew((PyArray_Descr *)dtype);
}

for(i = 0; i < ndim; i++) {
dims[i] = ((ub[i] - lb[i]) + 1);
}

arr = PyArray_NewFromDescr(&PyArray_Type, descr, ndim, dims, NULL, data, 0,
NULL);

Expand Down
6 changes: 3 additions & 3 deletions include/dspaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,10 @@ int dspaces_get(dspaces_client_t client, const char *var_name, unsigned int ver,
* array.
* @param[in] ndim: the number of dimensions for the local bounding
* box.
* @param[in] lb: coordinates for the lower corner of the local
* bounding box.
* @param[in] ub: coordinates for the upper corner of the local
* @param[in, out] lb: coordinates for the lower corner of the local
* bounding box.
* @param[in, out] ub: coordinates for the upper corner of the local
* bounding box. Updated if truncated by data bounds.
* @param[in] data: Pointer to user data buffer.
* @param[out] tag: Pointer to an int buffer to store tag value. Not stored if tag is NULL.
* @param[in] timeout: Timeout value: -1 is never, 0 is immediate.
Expand Down
5 changes: 4 additions & 1 deletion src/dspaces-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1613,7 +1613,7 @@ int dspaces_aget(dspaces_client_t client, const char *var_name,
int num_odscs;
int elem_size;
int num_elem = 1;
int i;
int i,j;
int ret = dspaces_SUCCESS;

fill_odsc(client, var_name, ver, 0, ndim, lb, ub, &odsc);
Expand All @@ -1627,6 +1627,9 @@ int dspaces_aget(dspaces_client_t client, const char *var_name,
if(odsc_tab[i].flags && DS_OBJ_RESIZE) {
DEBUG_OUT("the result is cropped.\n");
memcpy(&odsc.bb, &odsc_tab[i].bb, sizeof(odsc_tab[i].bb));
for(j = 0; j < odsc.bb.num_dims; j++) {
ub[j] = odsc.bb.ub.c[j];
}
}
DEBUG_OUT("%s\n", obj_desc_sprint(&odsc_tab[i]));
}
Expand Down

0 comments on commit 90ba4cc

Please sign in to comment.