diff options
author | Vishwanath Venkatesan <vish@hdfgroup.org> | 2013-07-11 01:05:36 (GMT) |
---|---|---|
committer | Vishwanath Venkatesan <vish@hdfgroup.org> | 2013-07-11 01:05:36 (GMT) |
commit | 731e241967d0732b1f2d425f1ba450418163a9f7 (patch) | |
tree | e2d11cb939db75fbd6044948c00c09c851443802 | |
parent | 1ad02ed0fcd3877a572690e042acc00af4816fca (diff) | |
download | hdf5-731e241967d0732b1f2d425f1ba450418163a9f7.zip hdf5-731e241967d0732b1f2d425f1ba450418163a9f7.tar.gz hdf5-731e241967d0732b1f2d425f1ba450418163a9f7.tar.bz2 |
[svn-r23886] Mutliple things happened in this commit.
1. Merged yesterday with hdf5_ff branch.
2. Fixed a couple of memory corruption, error handling issues.
3. Stable version of requests going through compactor, with new queue maninpulation routines
4. Tested and fixed bugs in compaction process.
Now compaction happens succesfully for mutliple dataspaces of the same
dataset. Memory descriptor gets constructed accordingly.
TODO:
-- Have to call the write operations with merged requests from the request
list.
-rw-r--r-- | src/H5EQpublic.h | 15 | ||||
-rw-r--r-- | src/H5Shyper.c | 76 | ||||
-rw-r--r-- | src/H5Spublic.h | 9 | ||||
-rw-r--r-- | src/H5VLiod_attr.c | 12 | ||||
-rw-r--r-- | src/H5VLiod_common.h | 2 | ||||
-rw-r--r-- | src/H5VLiod_compactor.c | 764 | ||||
-rw-r--r-- | src/H5VLiod_compactor.h | 12 | ||||
-rw-r--r-- | src/H5VLiod_compactor_queue.c | 56 | ||||
-rw-r--r-- | src/H5VLiod_compactor_queue.h | 1 | ||||
-rw-r--r-- | src/H5VLiod_dset.c | 278 | ||||
-rw-r--r-- | src/H5VLiod_dtype.c | 18 | ||||
-rw-r--r-- | src/H5VLiod_encdec.c | 12 | ||||
-rw-r--r-- | src/H5VLiod_group.c | 17 | ||||
-rw-r--r-- | src/H5VLiod_link.c | 5 | ||||
-rw-r--r-- | src/H5VLiod_server.c | 234 | ||||
-rw-r--r-- | src/H5VLiod_server.h | 9 |
16 files changed, 1085 insertions, 435 deletions
diff --git a/src/H5EQpublic.h b/src/H5EQpublic.h index 2992d4e..12b4328 100644 --- a/src/H5EQpublic.h +++ b/src/H5EQpublic.h @@ -22,15 +22,13 @@ /* System headers needed by this file */ /* Public headers needed by this file */ +#include "H5public.h" +#include "H5Ipublic.h" /*****************/ /* Public Macros */ /*****************/ -#ifdef __cplusplus -extern "C" { -#endif - /*******************/ /* Public Typedefs */ /*******************/ @@ -43,7 +41,7 @@ typedef void * H5_request_t; /********************/ /* Asynchronous operation status */ -typedef enum { +typedef enum H5_status_t{ H5AO_PENDING, /* Operation has not yet completed */ H5AO_SUCCEEDED, /* Operation has completed, successfully */ H5AO_FAILED, /* Operation has completed, but failed */ @@ -53,12 +51,16 @@ typedef enum { #define H5_REQUEST_NULL NULL #define H5_EVENT_QUEUE_NULL -1 +#ifdef __cplusplus +extern "C" { +#endif + /*********************/ /* Public Prototypes */ /*********************/ /* API wrappers */ -H5_DLL hid_t H5EQcreate(hid_t fapl_id); +H5_DLL hid_t H5EQcreate(hid_t fapl_id); H5_DLL herr_t H5EQinsert(hid_t event_q, H5_request_t req); H5_DLL herr_t H5EQpop(hid_t event_q, H5_request_t *req); H5_DLL herr_t H5EQwait(hid_t event_q, int *num_requests, H5_status_t **status); @@ -73,5 +75,4 @@ H5_DLL herr_t H5AOwait(H5_request_t req, H5_status_t *status); #ifdef __cplusplus } #endif - #endif /* _H5EQpublic_H */ diff --git a/src/H5Shyper.c b/src/H5Shyper.c index d88ac35..4029d9e 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -8853,3 +8853,79 @@ H5S_hyper_get_seq_list(const H5S_t *space, unsigned UNUSED flags, H5S_sel_iter_t FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_get_seq_list() */ + +/*-------------------------------------------------------------------------- + NAME + H5Sselect_is_regular + PURPOSE + Check if hyperslab selection is a regular selection + RETURNS + TRUE/FALSE/FAIL +--------------------------------------------------------------------------*/ +htri_t +H5Sselect_is_regular(hid_t space_id) +{ + H5S_t *space; /* dataspace to modify */ + htri_t ret_value; + + FUNC_ENTER_API(FAIL) + H5TRACE1("t", "i", space_id); + + /* Check args and all the boring stuff. */ + if ((space = (H5S_t *)H5I_object_verify(space_id,H5I_DATASPACE)) == NULL) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a dataspace") + + if(H5S_GET_SELECT_TYPE(space) != H5S_SEL_HYPERSLABS) + HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "not a hyperslab selection") + + if(space->select.sel_info.hslab->diminfo_valid) + ret_value = TRUE; + else + ret_value = FALSE; + +done: + FUNC_LEAVE_API(ret_value) +} + + +/*-------------------------------------------------------------------------- + NAME + H5Sget_reg_hyperslab_params + PURPOSE + retrieve the start, stride, count, block arrays of a regular + hyperslab selection + RETURNS + TRUE/FALSE/FAIL +--------------------------------------------------------------------------*/ +herr_t +H5Sget_reg_hyperslab_params(hid_t space_id, hsize_t start[], hsize_t stride[], + hsize_t count[], hsize_t block[]) +{ + H5S_t *space = NULL; /* Dataspace to get selection of */ + const H5S_hyper_dim_t *diminfo; /* Alias for dataspace's diminfo information */ + unsigned ndims; /* Rank of the dataspace */ + unsigned u; + herr_t ret_value=SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "i*h*h*h*h", space_id, start, stride, count, block); + + /* Check args */ + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") + if(!space->select.sel_info.hslab->diminfo_valid) + HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "not a regular hyperslab selection") + + diminfo = space->select.sel_info.hslab->opt_diminfo; + ndims = space->extent.rank; + + for(u=0 ; u<ndims; u++) { + start[u] = diminfo[u].start; + stride[u] = diminfo[u].stride; + count[u] = diminfo[u].count; + block[u] = diminfo[u].block; + } + +done: + FUNC_LEAVE_API(ret_value) +} diff --git a/src/H5Spublic.h b/src/H5Spublic.h index 645ff1b..96953d8 100644 --- a/src/H5Spublic.h +++ b/src/H5Spublic.h @@ -113,7 +113,16 @@ H5_DLL herr_t H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hsize_t _stride[], const hsize_t count[], const hsize_t _block[]); + #define NEW_HYPERSLAB_API + +H5_DLL htri_t H5Sselect_is_regular(hid_t space_id); +H5_DLL herr_t H5Sget_reg_hyperslab_params(hid_t space_id, + hsize_t start[], + hsize_t stride[], + hsize_t count[], + hsize_t block[]); + /* Note that these haven't been working for a while and were never * publicly released - QAK */ #ifdef NEW_HYPERSLAB_API diff --git a/src/H5VLiod_attr.c b/src/H5VLiod_attr.c index d7863dd..dda7b6a 100644 --- a/src/H5VLiod_attr.c +++ b/src/H5VLiod_attr.c @@ -286,9 +286,12 @@ H5VL_iod_server_attr_open_cb(AXE_engine_t UNUSED axe_engine, if(iod_obj_get_scratch(cur_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't get scratch pad for object"); + /* MSC - Dont do this check until we have a real IOD */ +#if 0 /* if attribute KV does not exist, return error*/ if(IOD_ID_UNDEFINED == sp.attr_id) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "Object has no attributes"); +#endif /* open the attribute KV in scratch pad */ if (iod_obj_open_write(coh, sp.attr_id, NULL /*hints*/, &attr_kv_oh, NULL) < 0) @@ -656,11 +659,14 @@ H5VL_iod_server_attr_exists_cb(AXE_engine_t UNUSED axe_engine, iod_obj_close(cur_oh, NULL, NULL); } + /* MSC - Dont do this check until we have a real IOD */ +#if 0 /* if attribute KV does not exist, return false*/ if(IOD_ID_UNDEFINED == sp.attr_id) { ret = FALSE; HGOTO_DONE(SUCCEED); } +#endif /* open the attribute KV in scratch pad */ if (iod_obj_open_write(coh, sp.attr_id, NULL /*hints*/, &attr_kv_oh, NULL) < 0) @@ -757,9 +763,12 @@ H5VL_iod_server_attr_rename_cb(AXE_engine_t UNUSED axe_engine, iod_obj_close(cur_oh, NULL, NULL); } + /* MSC - Dont do this check until we have a real IOD */ +#if 0 /* if attribute KV does not exist, return error*/ if(IOD_ID_UNDEFINED == sp.attr_id) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "Object has no attributes"); +#endif /* open the attribute KV in scratch pad */ if (iod_obj_open_write(coh, sp.attr_id, NULL /*hints*/, &attr_kv_oh, NULL) < 0) @@ -865,9 +874,12 @@ H5VL_iod_server_attr_remove_cb(AXE_engine_t UNUSED axe_engine, iod_obj_close(cur_oh, NULL, NULL); } + /* MSC - Dont do this check until we have a real IOD */ +#if 0 /* if attribute KV does not exist, return error*/ if(IOD_ID_UNDEFINED == sp.attr_id) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "Object has no attributes"); +#endif /* open the attribute KV in scratch pad */ if (iod_obj_open_write(coh, sp.attr_id, NULL /*hints*/, &attr_kv_oh, NULL) < 0) diff --git a/src/H5VLiod_common.h b/src/H5VLiod_common.h index ef226aa..e58ab39 100644 --- a/src/H5VLiod_common.h +++ b/src/H5VLiod_common.h @@ -19,7 +19,7 @@ #ifndef _H5VLiod_common_H #define _H5VLiod_common_H -#include "H5Pprivate.h" /* Property lists */ +#include "H5public.h" #include "H5VLpublic.h" #include "H5VLiod.h" /* Iod VOL plugin */ diff --git a/src/H5VLiod_compactor.c b/src/H5VLiod_compactor.c index 8ffeca0..9ec9f51 100644 --- a/src/H5VLiod_compactor.c +++ b/src/H5VLiod_compactor.c @@ -72,6 +72,12 @@ static int H5VL_iod_sort_block_container (block_container_t *io_array, size_t num_entries, int *sorted); +static int H5VL_iod_construct_merged_request (request_list_t *list, + size_t m_element_size, + request_list_t *merged_req, + int *lselected, int num_selected, + int *request_list, int num_requests); + /*---------------------------------------------------------------------*/ @@ -130,15 +136,10 @@ int H5VL_iod_extract_dims_info (hid_t dataspace, *------------------------------------------------------------------------- */ -#ifdef DEBUG_COMPACTOR -int H5VL_iod_create_request_list (compactor *queue, request_list_t **list, - int *numentries, dataset_container_t **u_datasets, - int *numdatasets, int request_type, FILE *fp_new) -#else int H5VL_iod_create_request_list (compactor *queue, request_list_t **list, int *numentries, dataset_container_t **u_datasets, int *numdatasets, int request_type) -#endif + { @@ -147,6 +148,7 @@ int H5VL_iod_create_request_list (compactor *queue, request_list_t **list, op_data_t *op_data; dset_io_in_t *input; iod_obj_id_t iod_id; + int dataset_id; hg_bulk_t bulk_handle; hg_bulk_request_t bulk_request; hg_bulk_block_t bulk_block_handle; @@ -163,8 +165,9 @@ int H5VL_iod_create_request_list (compactor *queue, request_list_t **list, size_t size, buf_size, src_size, dst_size; size_t *len, num_entries, chk_size; int ret_value = CP_SUCCESS,num_requests = 0, num_datasets = 0; - int j = 0, request_id = 0, i, current_dset_id = 0, lreq = 0; + int j = 0, request_id = 0, i, current_dset_id = 0, lreq = 0, flag = 0; size_t ii; + FUNC_ENTER_NOAPI(NULL) @@ -176,12 +179,12 @@ int H5VL_iod_create_request_list (compactor *queue, request_list_t **list, num_requests = H5VL_iod_get_number_of_requests (queue); #if DEBUG_COMPACTOR - fprintf(fp_new,"in %s:(%d), Number of requests :%d\n", + fprintf(stderr,"in %s:(%d), Number of requests :%d\n", __FILE__,__LINE__, num_requests); #endif - /*Create a local request list*/ - newlist = (request_list_t *) malloc ( num_requests * sizeof(request_list_t)); + /*Create a local request list -- Allocate more to avoid realloc and memory corruptions*/ + newlist = (request_list_t *) malloc ( 2 * num_requests * sizeof(request_list_t)); if ( NULL == newlist){ HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, CP_FAIL,"Memory allocation error for request list"); } @@ -197,7 +200,6 @@ int H5VL_iod_create_request_list (compactor *queue, request_list_t **list, unique_datasets[j].requests = (int *) malloc (num_requests * sizeof(int)); if (NULL == unique_datasets[j].requests) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, CP_FAIL,"Memory allocation error for dataset-req list"); - } @@ -211,11 +213,12 @@ int H5VL_iod_create_request_list (compactor *queue, request_list_t **list, HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, CP_FAIL, "Memory allocation error for request list"); } t_entry->request_id = -1; - H5VL_iod_get_request_at_front (queue, t_entry); - /* H5VL_iod_remove_request_from_compactor(queue, t_entry);*/ + + H5VL_iod_get_request_at (queue, t_entry, j); + if ( -1 == t_entry->request_id){ #if DEBUG_COMPACTOR - fprintf(fp_new,"in %s:%d Compactor failure case entered \n", + fprintf(stderr,"in %s:%d Compactor failure case entered \n", __FILE__,__LINE__); #endif HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCOPY, CP_FAIL, "Compactor queue is empty"); @@ -225,10 +228,11 @@ int H5VL_iod_create_request_list (compactor *queue, request_list_t **list, t_entry = NULL; continue; } + else{ #if DEBUG_COMPACTOR - fprintf(fp_new,"in %s:%d Enters CASE -- means we have requests! \n", + fprintf(stderr,"in %s:%d Enters -- means we have requests! \n", __FILE__,__LINE__); #endif @@ -237,6 +241,7 @@ int H5VL_iod_create_request_list (compactor *queue, request_list_t **list, input = (dset_io_in_t *)op_data->input; source = HG_Handler_get_addr(op_data->hg_handle); iod_id = input->iod_id; + dataset_id = input->iod_oh.cookie; space_id = input->space_id; src_id = input->mem_type_id; dst_id = input->dset_type_id; @@ -245,20 +250,20 @@ int H5VL_iod_create_request_list (compactor *queue, request_list_t **list, bulk_handle = input->bulk_handle; size = HG_Bulk_handle_get_size(bulk_handle); - nelmts = (size_t)H5Sget_simple_extent_npoints(space_id); + nelmts = (size_t)H5Sget_select_npoints(space_id); src_size = H5Tget_size(src_id); /*element size of memorytype */ dst_size = H5Tget_size(dst_id); /*element size of filetype*/ #if DEBUG_COMPACTOR - fprintf(fp_new,"in %s(%d) op_data: %p, space: %d, src_id: %d, dst_id: %d, size: %zd\n", - __FILE__,__LINE__, (void *)op_data, space_id, src_id, dst_id, size); + fprintf(stderr,"in %s(%d) op_data: %p, iod_id: %llu, dataset_id: %d space: %d, size: %zd\n", + __FILE__,__LINE__, (void *)op_data, iod_id, dataset_id, space_id, size); #endif if (request_id == 0){ - - unique_datasets[num_datasets].dataset = iod_id; + unique_datasets[num_datasets].dataset = dataset_id; #if DEBUG_COMPACTOR - fprintf(fp_new, "dataset: %d has the request %d at %d \n", + fprintf(stderr, "in %s:%d dataset: %d has the request %d at %d \n", + __FILE__, __LINE__, unique_datasets[num_datasets].dataset, request_id, unique_datasets[num_datasets].num_requests); @@ -268,15 +273,17 @@ int H5VL_iod_create_request_list (compactor *queue, request_list_t **list, lreq = unique_datasets[num_datasets].num_requests; unique_datasets[num_datasets].requests[lreq]= request_id; unique_datasets[num_datasets].num_requests += 1; - current_dset = iod_id; + current_dset = dataset_id; current_dset_id = num_datasets; num_datasets++; - + } - else{ - if (current_dset == (hid_t)iod_id){ + /*from the second id!*/else{ + + if (current_dset == (hid_t)dataset_id){ #if DEBUG_COMPACTOR - fprintf(fp_new, " current dataset: %d has the request %d at %d \n", + fprintf(stderr, "in %s:%d current dataset: %d has the request %d at %d \n", + __FILE__, __LINE__, unique_datasets[current_dset_id].dataset, request_id, unique_datasets[current_dset_id].num_requests); @@ -287,46 +294,50 @@ int H5VL_iod_create_request_list (compactor *queue, request_list_t **list, } else{ + + flag = 0; for (i = 0; i < num_datasets; i++){ - if ((hid_t)iod_id == unique_datasets[i].dataset){ + if ((hid_t)dataset_id == unique_datasets[i].dataset){ lreq = unique_datasets[i].num_requests; unique_datasets[i].requests[lreq] = request_id; #if DEBUG_COMPACTOR - fprintf(fp_new, "old dataset: %d has the request %d at %d \n", + fprintf(stderr, "in %s:%d old dataset: %d has the request %d at %d \n", + __FILE__, __LINE__, unique_datasets[i].dataset, request_id, unique_datasets[i].num_requests); #endif unique_datasets[i].num_requests++; - current_dset = iod_id; + current_dset = dataset_id; current_dset_id = i; + flag = 1; } - else{ /*the iod_id is new and not present in the list*/ - lreq = unique_datasets[num_datasets].num_requests; - unique_datasets[num_datasets].requests[lreq] = request_id; + } + if (!flag){ + /*the iod_id is new and not present in the list*/ + + lreq = unique_datasets[num_datasets].num_requests; + unique_datasets[num_datasets].requests[lreq] = request_id; #if DEBUG_COMPACTOR - fprintf(fp_new, "new dataset: %d has the request %d at %d \n", - unique_datasets[i].dataset, - request_id, - unique_datasets[i].num_requests); + fprintf(stderr, "in %s: %d new dataset: %d has the request %d at %d \n", + __FILE__, __LINE__, + unique_datasets[i].dataset, + request_id, + unique_datasets[i].num_requests); #endif - unique_datasets[num_datasets].num_requests++; - current_dset = iod_id; - current_dset_id = num_datasets; - num_datasets++; - - - } - } - } - } - + unique_datasets[num_datasets].num_requests++; + current_dset = dataset_id; + current_dset_id = num_datasets; + num_datasets++; + } + } + } selection_type = H5Sget_select_type(space_id); if (selection_type == H5S_SEL_NONE || selection_type == H5S_SEL_ALL){ #if DEBUG_COMPACTOR - fprintf(fp_new,"%s(%d) There is no selection in the dataspace\n", + fprintf(stderr,"%s(%d) There is no selection in the dataspace\n", __FILE__,__LINE__); #endif HGOTO_ERROR(H5E_DATASPACE, H5E_BADSELECT, CP_FAIL,"There is no selection in the dataspace"); @@ -340,77 +351,42 @@ int H5VL_iod_create_request_list (compactor *queue, request_list_t **list, buf_size = src_size * nelmts; assert(buf_size == size); } -#if DEBUG_COMPACTOR - fprintf(fp_new,"in %s:%d buf_size : %zd\n", - __FILE__,__LINE__, buf_size); -#endif + /*Allocation buffer and retrieving the buffer associated with the selection through the function shipper*/ if(NULL == (buf = malloc(buf_size))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, CP_FAIL, "can't allocate read buffer"); -#if DEBUG_COMPACTOR - fprintf(fp_new,"in %s:%d Before creating handle\n", - __FILE__,__LINE__); -#endif HG_Bulk_block_handle_create(buf, size, HG_BULK_READWRITE, &bulk_block_handle); -#if DEBUG_COMPACTOR - fprintf(fp_new,"in %s:%d After creating handle\n", - __FILE__,__LINE__); -#endif - /* Write bulk data here and wait for the data to be there */ if(HG_SUCCESS != HG_Bulk_read_all(source, bulk_handle, bulk_block_handle, &bulk_request)) HGOTO_ERROR(H5E_SYM, H5E_WRITEERROR, CP_FAIL, "can't get data from function shipper"); - -#if DEBUG_COMPACTOR - fprintf(fp_new,"in %s:%d After reading from handle\n", - __FILE__,__LINE__); -#endif /* wait for it to complete */ if(HG_SUCCESS != HG_Bulk_wait(bulk_request, HG_BULK_MAX_IDLE_TIME, HG_BULK_STATUS_IGNORE)) HGOTO_ERROR(H5E_SYM, H5E_WRITEERROR, CP_FAIL, "can't get data from function shipper"); -#if DEBUG_COMPACTOR - fprintf(fp_new,"in %s:%d After HG wait\n", - __FILE__,__LINE__); -#endif - /* free the bds block handle */ if(HG_SUCCESS != HG_Bulk_block_handle_free(bulk_block_handle)) HGOTO_ERROR(H5E_SYM, H5E_WRITEERROR, CP_FAIL, "can't free bds block handle"); -#if DEBUG_COMPACTOR - fprintf(fp_new,"in %s:%d After freeing block handle, data now in buf : %u\n", - __FILE__,__LINE__, (uintptr_t)buf); -#endif - /***********************************************************************************/ /* extract offsets and lengths for this dataspace selection*/ -#if DEBUG_COMPACTOR - fprintf(fp_new,"in %s:%d Before get offsets\n", - __FILE__,__LINE__); -#endif - ret_value = H5Sget_offsets(space_id, dst_size, &offsets, &len, &num_entries); - #if DEBUG_COMPACTOR - fprintf(fp_new,"in %s:%d for request_id: %d ret_value %d, num_entries %d from get_offsets\n", + fprintf(stderr,"in %s:%d for request_id: %d ret_value %d, num_entries %d from get_offsets\n", __FILE__,__LINE__, request_id, ret_value, num_entries); for (ii = 0; ii < num_entries; ii++){ - fprintf (fp_new,"offsets[%zd]: %lli, size[%zd]: %zd\n", + fprintf (stderr,"offsets[%zd]: %lli, size[%zd]: %zd\n", ii, offsets[ii], ii, len[ii]); } #endif - - newlist[request_id].fblocks = (block_container_t *) malloc (num_entries * sizeof(block_container_t)); if (NULL == newlist[request_id].fblocks){ @@ -429,8 +405,8 @@ int H5VL_iod_create_request_list (compactor *queue, request_list_t **list, newlist[request_id].num_mblocks = num_entries; newlist[request_id].elementsize = dst_size; - newlist[request_id].dataset_id = iod_id; - newlist[request_id].selection_id = H5Scopy(space_id); + newlist[request_id].dataset_id = dataset_id; + newlist[request_id].selection_id = space_id; /*Incase its not merged, to call the I/O operation directly with selection and memory descriptor*/ newlist[request_id].mem_buffer = (char *)buf; @@ -452,14 +428,14 @@ int H5VL_iod_create_request_list (compactor *queue, request_list_t **list, chk_size = chk_size + len[ii]; } else{ - #if DEBUG_COMPACTOR - fprintf(fp_new, "%s(%d) Buffer does not match the selection offsets\n", +#if DEBUG_COMPACTOR + fprintf(stderr, "%s(%d) Buffer does not match the selection offsets\n", __FILE__,__LINE__); - #endif +#endif HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL,"Buffer does not match the selection offsets"); } #if DEBUG_COMPACTOR - fprintf(fp_new, + fprintf(stderr, "\n %zd: foffsets %lli, flen: %zd, moffset: %lli, mlen : %zd\n", ii,offsets[ii],len[ii],local_mcont_ptr[ii].offset, len[ii]); #endif @@ -484,26 +460,29 @@ int H5VL_iod_create_request_list (compactor *queue, request_list_t **list, } #if DEBUG_COMPACTOR - fprintf(fp_new,"nentires : %d############################################\n", - request_id); - fprintf(fp_new,"Compactor Request List \n"); - fprintf(fp_new,"id -- dataset -- dataspace -- fileblocks -- memblocks\n"); + fprintf(stderr,"%s:%d N-entires : %d\n", + __FILE__,__LINE__, request_id); + fprintf(stderr,"%s:%d Compactor Request List \n",__FILE__,__LINE__); + fprintf(stderr,"Compactor-TUPLE: id -- dataset -- dataspace -- fileblocks -- memblocks\n"); for ( i = 0; i < request_id; i++){ - fprintf(fp_new, "%d -- %d -- %d -- %zd -- %zd\n", + fprintf(stderr, "Compactor-Entry: %d -- %d -- %d -- %zd -- %zd\n", newlist[i].request_id, newlist[i].dataset_id, newlist[i].selection_id, newlist[i].num_fblocks, newlist[i].num_mblocks); } - fprintf(fp_new,"#############################################\n"); + + for ( i = 0; i < num_datasets; i++){ - fprintf(fp_new, "dataset: %d has %d requests \n ", unique_datasets[i].dataset, + fprintf(stderr, "%s:%d dataset: %d has %d requests \n", + __FILE__, __LINE__, + unique_datasets[i].dataset, unique_datasets[i].num_requests); for (j = 0; j < unique_datasets[i].num_requests; j++){ - fprintf (fp_new, "%d ", unique_datasets[i].requests[j]); + fprintf (stderr, "Compactor request %d\n", unique_datasets[i].requests[j]); } - fprintf(fp_new,"\n"); + fprintf(stderr,"\n"); } #endif @@ -540,48 +519,124 @@ int H5VL_iod_select_overlap (hid_t dataspace_1, hid_t dataspace_3; hsize_t overlap, np; hid_t ret_value; + +#if DEBUG_COMPACTOR + hsize_t *bound_start; + hsize_t *bound_end; +#endif + const H5S_t *space = NULL, *space_1 = NULL; FUNC_ENTER_NOAPI(NULL) - + /*Check validity of dataspaces before getting intersection!*/ + + if(NULL == (space = (const H5S_t *)H5I_object_verify(dataspace_1, H5I_DATASPACE))){ - if(NULL == (space = (const H5S_t *)H5I_object_verify(dataspace_1, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataspace1 not a dataspace") +#if DEBUG_COMPACTOR + fprintf (stderr,"dataspace: %d is not a dataspace\n",dataspace_1); +#endif + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataspace1 not a dataspace"); + + } + if(H5S_SELECT_VALID(space) != TRUE){ - /* if(space && H5S_close(space) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") - else*/ - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "Not a valid dataspace") + +#if DEBUG_COMPACTOR + fprintf (stderr,"dataspace: %d is not a valid dataspace\n",dataspace_1); +#endif + + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "Not a valid dataspace") + } - if(NULL == (space_1 = (const H5S_t *)H5I_object_verify(dataspace_2, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataspace2 not a dataspace") + if(NULL == (space_1 = (const H5S_t *)H5I_object_verify(dataspace_2, H5I_DATASPACE))){ + +#if DEBUG_COMPACTOR + fprintf (stderr,"dataspace: %d is not a dataspace\n",dataspace_2); +#endif + + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataspace2 not a dataspace"); + } if(H5S_SELECT_VALID(space_1) != TRUE){ - /* if(space_1 && H5S_close(space_1) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") - else*/ - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "Not a valid dataspace") + +#if DEBUG_COMPACTOR + fprintf (stderr,"dataspace: %d is not a valid dataspace\n",dataspace_2); +#endif + + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "Not a valid dataspace"); } - + + +#if DEBUG_COMPACTOR + bound_start = (hsize_t *) malloc (2 * sizeof(hsize_t)); + bound_end = (hsize_t *) malloc (2 * sizeof(hsize_t)); + + H5Sget_select_bounds(dataspace_1, + bound_start, + bound_end); + fprintf(stderr, "in %s:%d Selection 1 : Start {%lli, %lli}, End {%lli, %lli}\n", + __FILE__,__LINE__, + bound_start[0], bound_start[1], bound_end[0], bound_end[1]); + + H5Sget_select_bounds(dataspace_2, bound_start, bound_end) ; + fprintf(stderr, "in %s:%d Selection 2 : Start {%lli, %lli}, End {%lli, %lli}\n", + __FILE__, __LINE__, + bound_start[0], bound_start[1], bound_end[0], bound_end[1]); +#endif + /*Get the intersection*/ + dataspace_3 = H5Scombine_select(dataspace_1, H5S_SELECT_AND, dataspace_2); overlap = H5Sget_select_npoints(dataspace_3); ret_value = (int) overlap; + +#if DEBUG_COMPACTOR + fprintf(stderr,"in %s:%d OVERLAP VALUE is %lli\n", + __FILE__, __LINE__, + overlap); +#endif + if ( 0 == (int) overlap){ /*There is no overlap, lets merge the selections*/ *res_dataspace = H5Scombine_select(dataspace_1, H5S_SELECT_OR, dataspace_2); } else{ /*The requests overlap*/ - np = H5S_GET_SELECT_NPOINTS(space); - if (np < (hsize_t)H5S_GET_SELECT_NPOINTS(space_1) ) + np = H5Sget_select_npoints(dataspace_1); + if (np < (hsize_t)H5Sget_select_npoints(dataspace_2) ){ *res_dataspace = dataspace_1; - else + +#if DEBUG_COMPACTOR + fprintf(stderr,"in %s:%d DATASPACE 1 is bigger\n", + __FILE__, __LINE__); +#endif + + } + else{ *res_dataspace = dataspace_2; + +#if DEBUG_COMPACTOR + fprintf(stderr,"in %s:%d DATASPACE 2 is bigger\n", + __FILE__, __LINE__); +#endif + + } } +#if DEBUG_COMPACTOR + fprintf (stderr,"in %s:%d Res dataspace : %d\n", + __FILE__, __LINE__, *res_dataspace); + H5Sget_select_bounds(*res_dataspace, + bound_start, + bound_end); + fprintf(stderr, "in %s:%d Result : Start {%lli, %lli}, End {%lli, %lli}\n", + __FILE__,__LINE__, + bound_start[0], bound_start[1], bound_end[0], bound_end[1]); +#endif + + done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5VL_iod_select_overlap */ @@ -603,32 +658,50 @@ o * Programmer: Vishwanth Venkatesan *------------------------------------------------------------------------- */ -int H5VL_iod_compact_requests (request_list_t **req_list, int *total_requests, +int H5VL_iod_compact_requests (request_list_t *list, int *total_requests, int num_requests, int *request_list) { - request_list_t *list = *req_list; - hid_t res_dataspace, current_space; + hid_t res_dataspace, current_space, last_merged; int ret_value = CP_SUCCESS; int *lselected_req = NULL; int num_selected = 0; - request_list_t *merged_request = NULL; - hsize_t *goffsets = NULL, *moffsets = NULL; - block_container_t *sf_block = NULL, *sm_block = NULL; - size_t *glens = NULL, blck_cnt = 0, *mlen = NULL; - size_t m_elmnt_size = 0, g_entries = 0, j, m_entries = 0; - size_t fblks = 0, mblks = 0; - int i, *sorted = NULL; + size_t m_elmnt_size = 0; + int i, merge_flag = 0; + int original_requests = *total_requests; FUNC_ENTER_NOAPI(NULL) - - lselected_req = (int *) malloc ( num_requests * sizeof(int)); + +#if DEBUG_COMPACTOR + fprintf(stderr,"%s:%d Entering compact requests with %d requests\n\n", + __FILE__, __LINE__, num_requests); +#endif + + /* if there is only 1 request no point compacting. So we quit*/ + if (num_requests <= 1 || *total_requests <= 1){ + ret_value = CP_FAIL; + goto done; + } + + lselected_req = (int *) malloc (num_requests * + sizeof(int)); if ( NULL == lselected_req){ HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, CP_FAIL,"Memory allocation error for selected requests") } +#if DEBUG_COMPACTOR + fprintf(stderr,"%s:%d requests: %d and %d have to be checked for merging\n", + __FILE__,__LINE__, + request_list[0], request_list[1]); current_space = list[request_list[0]].selection_id; - + + fprintf (stderr,"%s:%d Current Space ID : %d\n", + __FILE__,__LINE__, current_space); + fprintf (stderr,"%s:%d Merged with : %d\n", __FILE__, __LINE__, + list[request_list[1]].selection_id); +#endif + merge_flag = 0; + m_elmnt_size = list[request_list[0]].elementsize; if ( 0 == H5VL_iod_select_overlap ( current_space, list[request_list[1]].selection_id, &res_dataspace)){ @@ -636,25 +709,32 @@ int H5VL_iod_compact_requests (request_list_t **req_list, int *total_requests, lselected_req[1] = 1; list[request_list[0]].merged = 1; list[request_list[1]].merged = 1; - m_elmnt_size = list[request_list[0]].elementsize; num_selected += 2; + if (!merge_flag){ + merge_flag = 1; + } + last_merged = res_dataspace; /*update the last merged!*/ } else{ if (current_space == res_dataspace){ lselected_req[0] = 0; list[request_list[0]].merged = 1; - m_elmnt_size = list[request_list[0]].elementsize; } else{ lselected_req[0] = 1; list[request_list[1]].merged = 1; - m_elmnt_size = list[request_list[1]].elementsize; } num_selected += 1; } - + +#if DEBUG_COMPACTOR + fprintf(stderr, "%s:%d Num Selected : %d\n",__FILE__, __LINE__, + num_selected); +#endif + current_space = res_dataspace; - + last_merged = res_dataspace; + for (i = 2; i < num_requests; i++){ if ( 0 == H5VL_iod_select_overlap ( current_space, list[request_list[i]].selection_id, @@ -662,167 +742,308 @@ int H5VL_iod_compact_requests (request_list_t **req_list, int *total_requests, /*The dataspaces do not overlap*/ lselected_req[num_selected] = i ; num_selected++; + if (!merge_flag){ + merge_flag = 1; + } + last_merged = res_dataspace; /*update the last merged!*/ } else{ if (current_space != res_dataspace){ lselected_req[num_selected] = i; + if (merge_flag){ + merge_flag = 0; + /* We need to create a request list entry for the merged selection */ + list[original_requests].request_id = list[original_requests - 1].request_id + 1; + list[original_requests].merged = 2; + list[original_requests].selection_id = last_merged; + original_requests++; + if (CP_SUCCESS != H5VL_iod_construct_merged_request(list, + m_elmnt_size, + &list[original_requests - 1], + lselected_req, + num_selected, request_list, + num_requests)){ +#if DEBUG_COMPACTOR + fprintf(stderr, "in %s:%d Error while constructing merged request", + __FILE__,__LINE__); + +#endif + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, CP_FAIL, "cannot construct merged request"); + } + num_selected = 0; + if (lselected_req != NULL){ + free(lselected_req); + lselected_req = NULL; + lselected_req = (int *) malloc (num_requests * + sizeof(int)); + if ( NULL == lselected_req){ + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, CP_FAIL,"Memory allocation error for selected requests"); + } + } + } } } + /* update the current_space to the merged space or the largest space*/ current_space = res_dataspace; } - list = (request_list_t *) realloc (list, ((*total_requests) + 1) - * sizeof(request_list_t)); + + +#if DEBUG_COMPACTOR + fprintf(stderr, "%s:%d num_selected : %d, current_dataspace : %d, res_dataspace: %d\n", + __FILE__, __LINE__, + num_selected, + current_space, + res_dataspace); +#endif + + /*All merging done + Are there any left if so just allocate one request item for that*/ + if(merge_flag){ + list[original_requests].request_id = list[original_requests - 1].request_id + 1; + list[original_requests].dataset_id = list[request_list[0]].dataset_id; + list[original_requests].merged = 2; + list[original_requests].selection_id = last_merged; + original_requests++; + if (CP_SUCCESS != H5VL_iod_construct_merged_request(list, + m_elmnt_size, + &list[original_requests- 1], + lselected_req, + num_selected, + request_list, + num_requests)){ +#if DEBUG_COMPACTOR + fprintf(stderr, "in %s:%d Error while constructing merged request", + __FILE__,__LINE__); + +#endif + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, CP_FAIL, "cannot construct merged request"); + } + } + +#if DEBUG_COMPACTOR + fprintf (stderr, "in %s:%d Earlier %d requests now %d requests \n", + __FILE__, + __LINE__, + *total_requests, + original_requests); + + +#endif - if (NULL != list) { - merged_request = list; + if(NULL != lselected_req){ + free(lselected_req); + lselected_req = NULL; } - - /* Now we have merged the requests, we have a merged selection */ - /* We need to create a request list entry for the merged selection */ - list[*total_requests].request_id = list[*total_requests - 1].request_id + 1; - list[*total_requests].merged = 2; - /* - Add all the selections that were added/and manually merge them - Make sure the memory_descriptor is updated accoringly for the - merging */ - - fblks = H5VL_iod_get_selected_fblocks_count(lselected_req, - num_selected, - list); - sf_block = (block_container_t *) malloc ( fblks * sizeof(block_container_t)); - if (NULL == sf_block) - HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, CP_FAIL,"Allocation error for sf_block") - - mblks = H5VL_iod_get_selected_mblocks_count(lselected_req, - num_selected, - list); + *total_requests = original_requests; + done: + FUNC_LEAVE_NOAPI(ret_value); + +}/*end H5VL_iod_compact_requests*/ + +static +int H5VL_iod_construct_merged_request (request_list_t *list, + size_t m_elmnt_size, + request_list_t *merged_request, + int *lselected_req, int num_selected, + int *request_list, int num_requests) +{ + + hsize_t *goffsets = NULL, *moffsets = NULL; + int i, *sorted = NULL; + size_t fblks = 0, mblks = 0; + size_t g_entries = 0, j, m_entries = 0; + size_t *glens = NULL, blck_cnt = 0, *mlen = NULL; + block_container_t *sf_block = NULL, *sm_block = NULL; + int ret_value = CP_SUCCESS; + + FUNC_ENTER_NOAPI(NULL) + + if (num_selected > 1){ + +#if DEBUG_COMPACTOR + for (i = 0; i < num_selected; i++){ + fprintf (stderr, "in %s:%d lselected[%d]: %d\n", + __FILE__, + __LINE__, + i, + lselected_req[i]); + } +#endif + + fblks = H5VL_iod_get_selected_fblocks_count(lselected_req, + num_selected, + list); - sm_block = (block_container_t *) malloc (mblks * sizeof(block_container_t)); - if (NULL == sm_block) - HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, CP_FAIL,"Allocation error for sm_block") - - assert (fblks == mblks); - - blck_cnt = 0; - for ( i = 0; i < num_requests; i++){ - if (CP_SUCCESS == - H5VL_iod_request_exist(i, lselected_req, num_selected)){ - - /* At this point the mblocks and fblocks will be different only - for the merged selection, and we will have to handle that - scenario if we for some reason do two-passes for merging - So skipping here the case for num_fblocks != num_mblocks*/ - - for (j = blck_cnt; j < list[request_list[i]].num_fblocks; j++){ - sf_block[j].offset = list[request_list[i]].fblocks[j - blck_cnt].offset; - sf_block[j].len = list[request_list[i]].fblocks[j - blck_cnt].len; - sm_block[j].offset = list[request_list[i]].mblocks[j - blck_cnt].offset; - sm_block[j].len = list[request_list[i]].mblocks[j - blck_cnt].len; + sf_block = (block_container_t *) malloc ( fblks * sizeof(block_container_t)); + if (NULL == sf_block) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, CP_FAIL,"Allocation error for sf_block"); + + mblks = H5VL_iod_get_selected_mblocks_count(lselected_req, + num_selected, + list); + sm_block = (block_container_t *) malloc (mblks * sizeof(block_container_t)); + if (NULL == sm_block) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, CP_FAIL,"Allocation error for sm_block"); + + assert (fblks == mblks); + blck_cnt = 0; + + /* + Add all the selections that were added/and manually merge them + Make sure the memory_descriptor is updated accoringly for the + merging */ + + + for ( i = 0; i < num_requests; i++){ + if (CP_SUCCESS == + H5VL_iod_request_exist(request_list[i], lselected_req, num_selected)){ + + for (j = 0; j < list[request_list[i]].num_fblocks; j++){ + sf_block[blck_cnt].offset = list[request_list[i]].fblocks[j].offset; + sf_block[blck_cnt].len = list[request_list[i]].fblocks[j].len; + sm_block[blck_cnt].offset = list[request_list[i]].mblocks[j].offset; + sm_block[blck_cnt].len = list[request_list[i]].mblocks[j].len; +#if DEBUG_COMPACTOR + fprintf(stderr, "in %s:%d foffset: %lli len: %zd, moffset: %lli, len: %zd\n", + __FILE__, __LINE__, + sf_block[blck_cnt].offset, sf_block[blck_cnt].len, sm_block[blck_cnt].offset, + sm_block[blck_cnt].len); +#endif + blck_cnt++; } - blck_cnt = j; + } } - } - - /*--------------------------------------------------------------------- - Sort the file-offsets and check for contiguity. - The contiguity check is needed to compare with the merged - offsets from the combine-select function. These should be - same. - Once sorted use the sorted indices to get the arrangement of - memory offests. - The contiguity does not affect the arrangement - of memory offsets as the file offsets can even shrink to one - entry, but the order of memory offsets will remain constant + + /*--------------------------------------------------------------------- + Sort the file-offsets and check for contiguity. + The contiguity check is needed to compare with the merged + offsets from the combine-select function. These should be + same. + Once sorted use the sorted indices to get the arrangement of + memory offests. + The contiguity does not affect the arrangement + of memory offsets as the file offsets can even shrink to one + entry, but the order of memory offsets will remain constant --------------------------------------------------------------------*/ + assert(blck_cnt == fblks); + sorted = (int *) malloc (blck_cnt * sizeof(int)); + if ( NULL == sorted ){ + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, CP_FAIL,"Allocation error for sorted array"); + } + H5VL_iod_sort_block_container (sf_block, blck_cnt, sorted); - assert(blck_cnt == fblks); - - sorted = (int *) malloc (blck_cnt * sizeof(int)); - if ( NULL == sorted ){ - HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, CP_FAIL,"Allocation error for sorted array") - } - H5VL_iod_sort_block_container (sf_block, - blck_cnt, - sorted); - - moffsets = (hsize_t *) malloc (blck_cnt * sizeof(hsize_t)); - if ( NULL == moffsets){ - HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, CP_FAIL,"Allocation error for moffsets array") - } - - mlen = (size_t *) malloc (blck_cnt * sizeof(size_t)); - if ( NULL == moffsets){ - HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, CP_FAIL,"Allocation error for mlen array") - } - - /*moffsets and mlen for the merged offsets... manually merging from individual off-len - pairs*/ - moffsets[0] = sf_block[0].offset; - mlen[0] = sf_block[0].len; - - for ( j = 1; j < blck_cnt; j++){ - if (moffsets[m_entries] + mlen[m_entries] == - sf_block[j].offset){ - mlen[m_entries] += sf_block[j].len; +#if DEBUG_COMPACTOR + for ( j = 0; j < blck_cnt; j++){ + fprintf(stderr, "in %s:%d foffset: %lli len: %zd, moffset: %lli, len: %zd\n", + __FILE__, __LINE__, + sf_block[sorted[j]].offset, sf_block[sorted[j]].len, sm_block[sorted[j]].offset, + sm_block[sorted[j]].len); } - else{ - m_entries++; - moffsets[m_entries] = sf_block[j].offset; - mlen[m_entries] = sf_block[j].len; +#endif + + moffsets = (hsize_t *) malloc (blck_cnt * sizeof(hsize_t)); + if ( NULL == moffsets){ + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, CP_FAIL,"Allocation error for moffsets array"); + } + + mlen = (size_t *) malloc (blck_cnt * sizeof(size_t)); + if ( NULL == moffsets){ + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, CP_FAIL,"Allocation error for mlen array"); } - } - /* Make merged offset and len arrays for the merged selection */ - ret_value = H5Sget_offsets(current_space, m_elmnt_size, - &goffsets, &glens, &g_entries); - merged_request->fblocks = (block_container_t *) malloc (m_entries * - sizeof(block_container_t)); - if (NULL == merged_request->fblocks) - HGOTO_ERROR(H5E_SYM, H5E_CANTALLOC, CP_FAIL,"Allocation error for block container") + /*moffsets and mlen for the selected requests + ... manually merging from individual off-len + pairs*/ + moffsets[0] = sf_block[sorted[0]].offset; + mlen[0] = sf_block[sorted[0]].len; + m_entries = 1; + for ( j = 1; j < blck_cnt; j++){ - for ( j = 0; j<m_entries; j++){ - merged_request->fblocks[j].offset = goffsets[j]; - merged_request->fblocks[j].len = glens[j]; - } - /* + if (moffsets[m_entries - 1] + mlen[m_entries - 1] == + sf_block[sorted[j]].offset){ + mlen[m_entries - 1] += sf_block[sorted[j]].len; + } + else{ + moffsets[m_entries] = sf_block[sorted[j]].offset; + mlen[m_entries] = sf_block[sorted[j]].len; + m_entries++; + } + } + +#if DEBUG_COMPACTOR + fprintf(stderr, "in %s:%d After merging manually\n", __FILE__, __LINE__); + for ( j = 0; j < m_entries; j++){ + fprintf(stderr, "in %s:%d foffset: %lli len: %zd\n", + __FILE__, __LINE__, moffsets[j], mlen[j]); + } + +#endif + /* Make merged offset and len arrays for the merged selection */ + ret_value = H5Sget_offsets(merged_request->selection_id, m_elmnt_size, + &goffsets, &glens, &g_entries); + +#if DEBUG_COMPACTOR + for (j = 0; j < g_entries; j ++){ + + fprintf(stderr,"in %s:%d merged_offset[%d]: %lli, merged_len[%d]: %zd\n", + __FILE__, + __LINE__, + j,goffsets[j], j,glens[j]); + } +#endif + merged_request->fblocks = (block_container_t *) malloc (m_entries * + sizeof(block_container_t)); + if (NULL == merged_request->fblocks) + HGOTO_ERROR(H5E_SYM, H5E_CANTALLOC, CP_FAIL,"Allocation error for block container"); + + for ( j = 0; j<m_entries; j++){ + merged_request->fblocks[j].offset = goffsets[j]; + merged_request->fblocks[j].len = glens[j]; + } + /* Then compare that with automatically generated offsets (the offsets have to match) */ - ret_value = H5VL_iod_compare_offsets (goffsets,g_entries,moffsets,m_entries); - assert (ret_value == CP_SUCCESS); - - /*At this point all consistency checks have been completed. - We can comfortable create the memory descriptor for the - merged selection*/ - merged_request->mblocks = (block_container_t *) malloc (mblks * - sizeof(block_container_t)); - if (NULL == merged_request->mblocks) - HGOTO_ERROR(H5E_SYM, H5E_CANTALLOC, CP_FAIL,"Allocation error for block container") - - for ( j = 0; j< mblks; j++){ - merged_request->mblocks[j].offset = sm_block[j].offset; - merged_request->mblocks[j].len = sm_block[j].len; + ret_value = H5VL_iod_compare_offsets (goffsets,g_entries,moffsets,m_entries); + assert (ret_value == CP_SUCCESS); + /*At this point all consistency checks have been completed. + We can comfortable create the memory descriptor for the + merged selection*/ + merged_request->mblocks = (block_container_t *) malloc (mblks * + sizeof(block_container_t)); + if (NULL == merged_request->mblocks) + HGOTO_ERROR(H5E_SYM, H5E_CANTALLOC, CP_FAIL,"Allocation error for block container"); + + for ( j = 0; j< mblks; j++){ + merged_request->mblocks[j].offset = sm_block[sorted[j]].offset; + merged_request->mblocks[j].len = sm_block[sorted[j]].len; +#if DEBUG_COMPACTOR + fprintf (stderr, "in %s:%d -- %zd: MOFFSET: %lli, MLEN: %zd\n", + __FILE__, __LINE__, j, + merged_request->mblocks[j].offset, + merged_request->mblocks[j].len); +#endif + } + } /*if num_selected > 1*/ + else{ +#if DEBUG_COMPACTOR + fprintf(stderr,"in %s:%d Should not be here with num_selected :%d \n", + __FILE__, + __LINE__, + num_selected); +#endif + ret_value = CP_FAIL; + goto done; } - - /* We have the merged selection with its memory description. - append this merged_request towards the end. Proactively - more memory created than required for requests during - generation of dataset-specific requests. - We can use the merged_flag to skip requests or identify merged - request*/ - - *total_requests++; - *request_list = list; + done: FUNC_LEAVE_NOAPI(ret_value); - -}/*end H5VL_iod_compact_requests*/ - - + + }/*end H5VL_iod_construct_merged_request*/ /*------------------------------------------------------------------------- * Function: H5VL_iod_request_exist * @@ -878,15 +1099,16 @@ static int H5VL_iod_compare_offsets (hsize_t *offsets1, int ret_value = CP_SUCCESS; size_t i; - + fprintf (stderr, "OFFSET 1 : %zd, OFFSET 2: %zd\n", + offset1_cnt, offset2_cnt); if (offset1_cnt != offset2_cnt){ - ret_value = -1; + ret_value = CP_FAIL; goto done; } for (i = 0; i < offset1_cnt; i++){ if (offsets1[i] != offsets2[i]){ - ret_value = -1; + ret_value = CP_FAIL; goto done; } diff --git a/src/H5VLiod_compactor.h b/src/H5VLiod_compactor.h index 1f3bf1a..8b511ab 100644 --- a/src/H5VLiod_compactor.h +++ b/src/H5VLiod_compactor.h @@ -67,24 +67,20 @@ typedef struct { /*----------------------------------------------------------------------------------- */ -#ifdef DEBUG_COMPACTOR -H5_DLL int H5VL_iod_create_request_list (compactor *queue, request_list_t **list, - int *numentries, dataset_container_t **unique_datasets, - int *num_datasets, int request_type, FILE *fp); -#else + H5_DLL int H5VL_iod_create_request_list (compactor *queue, request_list_t **list, int *numentries, dataset_container_t **unique_datasets, int *num_datasets, int request_type); -#endif - H5_DLL int H5VL_iod_sort_request_list (request_list_t **list, int num_entires, int *sorted); H5_DLL int H5VL_iod_extract_dims_info (hid_t dataspace, int *dims, hsize_t **dims_out); H5_DLL int H5VL_iod_dataset_specific_requests (request_list_t *list, request_list_t ***dataset_list, int *num_datasets); -H5_DLL int H5VL_iod_compact_requests (request_list_t **req_list, int *total_requests, + +H5_DLL int H5VL_iod_compact_requests (request_list_t *req_list, int *total_requests, int num_requests, int *request_list); + H5_DLL int H5VL_iod_select_overlap (hid_t dataspace1 , hid_t dataspace2, hid_t *res_dataspace); H5_DLL int H5VL_iod_get_unique_dataset_request_sets ( request_list_t *list, diff --git a/src/H5VLiod_compactor_queue.c b/src/H5VLiod_compactor_queue.c index 971a760..6c9625e 100644 --- a/src/H5VLiod_compactor_queue.c +++ b/src/H5VLiod_compactor_queue.c @@ -290,6 +290,52 @@ int H5VL_iod_remove_element_from_queue(compactor* s, node* d){ /*------------------------------------------------------------------------- + * Function: H5VL_iod_get_request_at + * + * Purpose: Function get the requests at position + * + * ret_value : Success: Request + * Failure: Negative + * + * Programmer: Vishwanth Venkatesan + * June, 2013 + * + *------------------------------------------------------------------------- + */ + +int H5VL_iod_get_request_at (compactor *s, compactor_entry *entry, int j){ + + int ret_value = CP_SUCCESS; + int i = 0; + FUNC_ENTER_NOAPI_NOINIT + + if(NULL == s){ + HGOTO_ERROR(H5E_ARGS, H5E_NOSPACE, CP_FAIL, "Compactor queue does not exists"); + } + else if(NULL == s->head && NULL == s->tail){ + /*Nothing to remove*/ + ret_value = CP_FAIL; + } + else{ + node *p = s->head; + while (p){ + if ( i == j){ + *entry = p->request; + break; + } + else{ + p = p->next; + i++; + } + } + } + done: + FUNC_LEAVE_NOAPI(ret_value); +} + + + +/*------------------------------------------------------------------------- * Function: H5VL_iod_get_number_of_requests * * Purpose: Function get the number of requests @@ -312,13 +358,13 @@ int H5VL_iod_get_number_of_requests (compactor *s){ FUNC_ENTER_NOAPI(NULL) if(NULL == s){ - HGOTO_ERROR(H5E_ARGS, H5E_NOSPACE, CP_FAIL, "Compactor queue does not exists") + ret_value = CP_FAIL; } else if(NULL == s->head && NULL == s->tail){ - HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, CP_FAIL, "List's Head and Tail cannot be null"); + ret_value = CP_FAIL; } else if(NULL == s->head || NULL == s->tail){ - HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, CP_FAIL, "List's head/tail is null"); + ret_value = CP_FAIL; } else{ node* p = s->head; @@ -334,11 +380,11 @@ int H5VL_iod_get_number_of_requests (compactor *s){ /*------------------------------------------------------------------------- - * Function: H5VL_iod_remove_request_from_compactor + * Function: H5VL_iod_display_compactor_requests * * Purpose: Function to display the current set of requests * - * Ret_Valueurn: Success: CP_SUCCESS + * ret_value: Success: CP_SUCCESS * Failure: Negative * * Programmer: Vishwanth Venkatesan diff --git a/src/H5VLiod_compactor_queue.h b/src/H5VLiod_compactor_queue.h index 0f3fb01..5a87055 100644 --- a/src/H5VLiod_compactor_queue.h +++ b/src/H5VLiod_compactor_queue.h @@ -53,6 +53,7 @@ typedef struct cqlist compactor; H5_DLL int H5VL_iod_add_requests_to_compactor(compactor*, compactor_entry request); H5_DLL int H5VL_iod_remove_request_from_compactor(compactor*, compactor_entry *); H5_DLL int H5VL_iod_get_request_at_front (compactor *, compactor_entry *); +H5_DLL int H5VL_iod_get_request_at (compactor *, compactor_entry *, int j); H5_DLL int H5VL_iod_display_compactor_requests(compactor*); H5_DLL int H5VL_iod_remove_element_from_queue(compactor* s, node* d); H5_DLL int H5VL_iod_get_number_of_requests (compactor *s); diff --git a/src/H5VLiod_dset.c b/src/H5VLiod_dset.c index f2f6421..67f239a 100644 --- a/src/H5VLiod_dset.c +++ b/src/H5VLiod_dset.c @@ -117,14 +117,6 @@ H5VL_iod_server_dset_create_cb(AXE_engine_t UNUSED axe_engine, /* for the process that succeeded in creating the dataset, update the parent KV, create scratch pad */ if(0 == ret) { - kv.key = HDstrdup(last_comp); - kv.value = &dset_id; - kv.value_len = sizeof(iod_obj_id_t); - /* insert new dataset in kv store of current group */ - if (iod_kv_set(cur_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); - HDfree(kv.key); - /* create the metadata KV object for the dataset */ if(iod_obj_create(coh, IOD_TID_UNKNOWN, NULL, IOD_OBJ_KV, NULL, NULL, &mdkv_id, NULL) < 0) @@ -199,6 +191,14 @@ H5VL_iod_server_dset_create_cb(AXE_engine_t UNUSED axe_engine, /* close the Metadata KV object */ if(iod_obj_close(mdkv_oh, NULL, NULL)) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + + kv.key = HDstrdup(last_comp); + kv.value = &dset_id; + kv.value_len = sizeof(iod_obj_id_t); + /* insert new dataset in kv store of current group */ + if (iod_kv_set(cur_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); + HDfree(kv.key); } /* close parent group if it is not the location we started the @@ -449,8 +449,12 @@ H5VL_iod_server_dset_read_cb(AXE_engine_t UNUSED axe_engine, hg_bulk_request_t bulk_request; iod_mem_desc_t mem_desc; iod_array_iodesc_t file_desc; + iod_hyperslab_t *hslabs = NULL; size_t size, buf_size, src_size, dst_size; void *buf; + uint8_t *buf_ptr; + hssize_t num_descriptors = 0, n; + int ndims, i; uint32_t cs = 0; size_t nelmts; na_addr_t dest = HG_Handler_get_addr(op_data->hg_handle); @@ -468,7 +472,8 @@ H5VL_iod_server_dset_read_cb(AXE_engine_t UNUSED axe_engine, size = HG_Bulk_handle_get_size(bulk_handle); - nelmts = (size_t)H5Sget_simple_extent_npoints(space_id); + nelmts = (size_t)H5Sget_select_npoints(space_id); + src_size = H5Tget_size(src_id); dst_size = H5Tget_size(dst_id); @@ -488,28 +493,77 @@ H5VL_iod_server_dset_read_cb(AXE_engine_t UNUSED axe_engine, if(NULL == (buf = malloc(buf_size))) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate read buffer"); + /* get the rank of the dataspace */ + if((ndims = H5Sget_simple_extent_ndims(space_id)) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get dataspace dimesnsion"); + + /* get the number of decriptors required, i.e. the numbers of iod + I/O operations needed */ + if(H5VL_iod_get_file_desc(space_id, &num_descriptors, NULL) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to generate IOD file descriptor from dataspace selection"); + + /* allocate the IOD hyperslab descriptors needed */ + if(NULL == (hslabs = (iod_hyperslab_t *)malloc + (sizeof(iod_hyperslab_t) * (size_t)num_descriptors))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate iod array descriptors"); + + for(n=0 ; n<num_descriptors ; n++) { + hslabs[n].start = (iod_size_t *)malloc(sizeof(iod_size_t) * ndims); + hslabs[n].stride = (iod_size_t *)malloc(sizeof(iod_size_t) * ndims); + hslabs[n].block = (iod_size_t *)malloc(sizeof(iod_size_t) * ndims); + hslabs[n].count = (iod_size_t *)malloc(sizeof(iod_size_t) * ndims); + } + + /* generate the descriptors after allocating the array */ + if(H5VL_iod_get_file_desc(space_id, &num_descriptors, hslabs) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to generate IOD file descriptor from dataspace selection"); + + buf_ptr = (uint8_t *)buf; + + /* read each descriptore from the IOD container */ + for(n=0 ; n<num_descriptors ; n++) { + hsize_t num_bytes = 0; + hsize_t num_elems = 0; + + /* determine how many bytes the current descriptor holds */ + for(i=0 ; i<ndims ; i++) + num_elems *= (hslabs[n].count[i] * hslabs[n].block[i]); + num_bytes = num_elems * src_size; + #if 0 - mem_desc.nfrag = 1; - mem_desc.frag->addr = buf; - mem_desc.frag->len = (iod_size_t)buf_size; + /* set the memory descriptor */ + mem_desc.nfrag = 1; + mem_desc.frag->addr = (void *)buf_ptr; + mem_desc.frag->len = (iod_size_t)num_bytes; +#endif - /* MSC TODO - populate file location hyperslab */ + buf_ptr += num_bytes; + + /* set the file descriptor */ + file_desc = hslabs[n]; + +#if H5VL_IOD_DEBUG + for(i=0 ; i<ndims ; i++) { + fprintf(stderr, "Dim %d: start %zu stride %zu block %zu count %zu\n", + i, (size_t)file_desc.start[i], (size_t)file_desc.stride[i], + (size_t)file_desc.block[i], (size_t)file_desc.count[i]); + } #endif - /* read from array object */ - if(iod_array_read(iod_oh, IOD_TID_UNKNOWN, NULL, &mem_desc, &file_desc, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_READERROR, FAIL, "can't read from array object"); + /* read from array object */ + if(iod_array_read(iod_oh, IOD_TID_UNKNOWN, NULL, &mem_desc, &file_desc, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_READERROR, FAIL, "can't read from array object"); + } { - int i; hbool_t flag = FALSE; - int *buf_ptr = (int *)buf; + int *ptr = (int *)buf; #if H5_DO_NATIVE ret_value = H5Dread(iod_oh.cookie, src_id, H5S_ALL, space_id, dxpl_id, buf); #else /* fake data */ for(i=0;i<60;++i) - buf_ptr[i] = i; + ptr[i] = i; #endif if(H5Tconvert(src_id, dst_id, nelmts, buf, NULL, dxpl_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "data type conversion failed"); @@ -522,7 +576,7 @@ H5VL_iod_server_dset_read_cb(AXE_engine_t UNUSED axe_engine, HGOTO_ERROR(H5E_SYM, H5E_READERROR, FAIL, "can't read property list"); if(flag) { fprintf(stderr, "Injecting a bad data value to cause corruption \n"); - buf_ptr[0] = 10; + ptr[0] = 10; } } @@ -554,6 +608,16 @@ done: op_data = (op_data_t *)H5MM_xfree(op_data); free(buf); + /* free allocated descriptors */ + for(n=0 ; n<num_descriptors ; n++) { + free(hslabs[n].start); + free(hslabs[n].stride); + free(hslabs[n].block); + free(hslabs[n].count); + } + if(hslabs) + free(hslabs); + /* close the dataset if we opened it in this routine */ if(opened_locally) { if(iod_obj_close(iod_oh, NULL, NULL)) @@ -594,10 +658,10 @@ H5VL_iod_server_dset_compactor_cb (AXE_engine_t UNUSED axe_engine, FUNC_ENTER_NOAPI_NOINIT #if DEBUG_COMPACTOR - fprintf(fp, "Enters Call BACK!\n"); - fprintf (fp, "Number of requests : %d from call back in queue : %p\n", - H5VL_iod_get_number_of_requests(cqueue), cqueue); - fflush(fp); + fprintf(stderr, "Enters Call BACK!\n"); + fprintf (stderr, "Number of requests : %d from call back in queue : %p\n", + H5VL_iod_get_number_of_requests(cqueue), (void *)cqueue); + fflush(stderr); #endif pthread_mutex_lock(&lock); @@ -605,83 +669,83 @@ H5VL_iod_server_dset_compactor_cb (AXE_engine_t UNUSED axe_engine, curr_queue = NULL; pthread_mutex_unlock(&lock); -#ifdef DEBUG_COMPACTOR - ret_value = H5VL_iod_create_request_list (cqueue, - &wlist, - &nentries, - &dlist, - &ndatasets, - WRITE, - fp); -#else + + ret_value = H5VL_iod_create_request_list (cqueue, &wlist, &nentries, &dlist, &ndatasets, WRITE); -#endif + #if DEBUG_COMPACTOR if (ret_value != CP_SUCCESS){ - fprintf(fp,"ERROR !! Compactor create request list failed with error %d \n", + fprintf(stderr,"ERROR !! Compactor create request list failed with error %d \n", ret_value); } #endif - + #if DEBUG_COMPACTOR - fprintf(fp,"nentires : %d############################################\n", nentries); - fprintf(fp,"Compactor Request List \n"); - fprintf(fp,"id -- dataset -- dataspace -- fileblocks -- memblocks\n"); + fprintf(stderr, "=========================================================================\n"); + fprintf(stderr,"nentires : %d############################################\n", nentries); + fprintf(stderr,"Compactor Request List \n"); + fprintf(stderr,"id -- dataset -- dataspace -- fileblocks -- memblocks\n"); for ( i = 0; i < nentries; i++){ - fprintf(fp, "%d -- %d -- %d -- %zd -- %zd\n", + fprintf(stderr, "%d -- %d -- %d -- %zd -- %zd\n", wlist[i].request_id, wlist[i].dataset_id, wlist[i].selection_id, wlist[i].num_fblocks, wlist[i].num_mblocks); } - fprintf(fp,"#############################################\n"); + fprintf(stderr, "=========================================================================\n"); #endif -#if 0 +#if 1 for ( i = 0; i < ndatasets; i ++){ - - H5VL_iod_compact_requests (&wlist, &nentries,dlist[i].num_requests, + H5VL_iod_compact_requests (wlist, &nentries,dlist[i].num_requests, dlist[i].requests); + } -#endif - +#endif n_requests = H5VL_iod_get_number_of_requests(cqueue); - - - - while ( n_requests > 0){ + i = 0; + while ( i < n_requests){ compactor_entry t_entry; - H5VL_iod_remove_request_from_compactor (cqueue, &t_entry); + /* H5VL_iod_remove_request_from_compactor (cqueue, &t_entry);*/ + H5VL_iod_get_request_at (cqueue, &t_entry, i); if ( t_entry.type_request == WRITE){ #if DEBUG_COMPACTOR - fprintf (fp, "Request: %d is a WRITE request\n ", t_entry.request_id); - fprintf (fp, "With op_data : %p\n ", - t_entry.input_structure, - t_entry.request_id); - fflush(fp); + fprintf (stderr, "Request: %d is a WRITE request\n ", t_entry.request_id); + fprintf (stderr, "With op_data : %p\n ", + (void *)t_entry.input_structure); + fflush(stderr); #endif op_data = NULL; op_data = t_entry.input_structure; H5VL_iod_server_dset_write_cb (NULL,NULL,NULL,NULL,NULL,op_data); } else{ - fprintf (fp, "Request: %d is a READ request\n ", t_entry.request_id); + fprintf (stderr, "Request: %d is a READ request\n ", t_entry.request_id); /* Have to do the same for READ requests!*/ } - n_requests--; + i++; + } + + if (NULL != wlist){ + free(wlist); + wlist = NULL; + } + if (NULL != dlist){ + free(dlist); + dlist = NULL; } - if (CP_SUCCESS != H5VL_iod_destroy_compactor_queue(cqueue)){ HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, CP_FAIL, "Cannot free NULL queue\n"); } + done: FUNC_LEAVE_NOAPI_VOID } /*end H5VL_iod_server_dset_compactor_cb */ @@ -718,15 +782,19 @@ H5VL_iod_server_dset_write_cb(AXE_engine_t UNUSED axe_engine, hid_t space_id = input->space_id; hid_t dxpl_id = input->dxpl_id; uint32_t cs = input->checksum; - uint32_t data_cs = 0; hid_t src_id = input->mem_type_id; hid_t dst_id = input->dset_type_id; + uint32_t data_cs = 0; hg_bulk_block_t bulk_block_handle; hg_bulk_request_t bulk_request; iod_mem_desc_t mem_desc; iod_array_iodesc_t file_desc; + iod_hyperslab_t *hslabs = NULL; size_t size, buf_size, src_size, dst_size; + hssize_t num_descriptors = 0, n; + int ndims, i; void *buf; + uint8_t *buf_ptr; size_t nelmts; hbool_t flag = FALSE; na_addr_t source = HG_Handler_get_addr(op_data->hg_handle); @@ -736,7 +804,8 @@ H5VL_iod_server_dset_write_cb(AXE_engine_t UNUSED axe_engine, FUNC_ENTER_NOAPI_NOINIT #if H5VL_IOD_DEBUG - fprintf(stderr, "Dataset Write with AXE ID %llu\n",input->axe_id); + fprintf(stderr, "Dataset Write with AXE ID %llu, %d, %llu, %d\n", + input->axe_id, space_id, iod_id, iod_oh.cookie); #endif /* open the dataset if we don't have the handle yet */ if(iod_oh.cookie == IOD_OH_UNDEFINED) { @@ -747,8 +816,9 @@ H5VL_iod_server_dset_write_cb(AXE_engine_t UNUSED axe_engine, /* Read bulk data here and wait for the data to be here */ size = HG_Bulk_handle_get_size(bulk_handle); + fprintf(stderr, "Size: %zd\n" ,size); + nelmts = (size_t)H5Sget_select_npoints(space_id); - nelmts = (size_t)H5Sget_simple_extent_npoints(space_id); src_size = H5Tget_size(src_id); dst_size = H5Tget_size(dst_id); @@ -762,7 +832,8 @@ H5VL_iod_server_dset_write_cb(AXE_engine_t UNUSED axe_engine, } else { buf_size = src_size * nelmts; - assert(buf_size == size); + fprintf (stderr, "size: %zd, buf_size: %zd\n", size, buf_size); + assert(buf_size == size); } if(NULL == (buf = malloc(buf_size))) @@ -805,27 +876,76 @@ H5VL_iod_server_dset_write_cb(AXE_engine_t UNUSED axe_engine, #if H5VL_IOD_DEBUG { - int i; - int *buf_ptr = (int *)buf; + int *ptr = (int *)buf; fprintf(stderr, "DWRITE Received a buffer of size %d with values: ", size); - for(i=0;i<60;++i) - fprintf(stderr, "%d ", buf_ptr[i]); + for(i=0;i<size/4;++i) + fprintf(stderr, "%d ", ptr[i]); fprintf(stderr, "\n"); } #endif + /* get the rank of the dataspace */ + if((ndims = H5Sget_simple_extent_ndims(space_id)) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get dataspace dimesnsion"); + + /* get the number of decriptors required, i.e. the numbers of iod + I/O operations needed */ + if(H5VL_iod_get_file_desc(space_id, &num_descriptors, NULL) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to generate IOD file descriptor from dataspace selection"); + + /* allocate the IOD hyperslab descriptors needed */ + if(NULL == (hslabs = (iod_hyperslab_t *)malloc + (sizeof(iod_hyperslab_t) * (size_t)num_descriptors))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate iod array descriptors"); + + for(n=0 ; n<num_descriptors ; n++) { + hslabs[n].start = (iod_size_t *)malloc(sizeof(iod_size_t) * ndims); + hslabs[n].stride = (iod_size_t *)malloc(sizeof(iod_size_t) * ndims); + hslabs[n].block = (iod_size_t *)malloc(sizeof(iod_size_t) * ndims); + hslabs[n].count = (iod_size_t *)malloc(sizeof(iod_size_t) * ndims); + } + + /* generate the descriptors after allocating the array */ + if(H5VL_iod_get_file_desc(space_id, &num_descriptors, hslabs) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to generate IOD file descriptor from dataspace selection"); + + buf_ptr = (uint8_t *)buf; + + /* write each descriptore to the IOD container */ + for(n=0 ; n<num_descriptors ; n++) { + hsize_t num_bytes = 0; + hsize_t num_elems = 0; + + /* determine how many bytes the current descriptor holds */ + for(i=0 ; i<ndims ; i++) + num_elems *= (hslabs[n].count[i] * hslabs[n].block[i]); + num_bytes = num_elems * dst_size; + #if 0 - mem_desc.nfrag = 1; - mem_desc.frag->addr = buf; - mem_desc.frag->len = (iod_size_t)buf_size; + /* set the memory descriptor */ + mem_desc.nfrag = 1; + mem_desc.frag->addr = (void *)buf_ptr; + mem_desc.frag->len = (iod_size_t)num_bytes; +#endif + + buf_ptr += num_bytes; - /* MSC TODO - populate file location hyperslab */ + /* set the file descriptor */ + file_desc = hslabs[n]; + +#if H5VL_IOD_DEBUG + for(i=0 ; i<ndims ; i++) { + fprintf(stderr, "Dim %d: start %zu stride %zu block %zu count %zu\n", + i, (size_t)file_desc.start[i], (size_t)file_desc.stride[i], + (size_t)file_desc.block[i], (size_t)file_desc.count[i]); + } #endif - /* write from array object */ - if(iod_array_write(iod_oh, IOD_TID_UNKNOWN, NULL, &mem_desc, &file_desc, &cs, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_WRITEERROR, FAIL, "can't write to array object"); + /* write from array object */ + if(iod_array_write(iod_oh, IOD_TID_UNKNOWN, NULL, &mem_desc, &file_desc, &cs, NULL) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write to array object"); + } #if H5_DO_NATIVE ret_value = H5Dwrite(iod_oh.cookie, H5T_NATIVE_INT, H5S_ALL, space_id, dxpl_id, buf); @@ -848,6 +968,16 @@ done: op_data = (op_data_t *)H5MM_xfree(op_data); free(buf); + /* free allocated descriptors */ + for(n=0 ; n<num_descriptors ; n++) { + free(hslabs[n].start); + free(hslabs[n].stride); + free(hslabs[n].block); + free(hslabs[n].count); + } + if(hslabs) + free(hslabs); + /* close the dataset if we opened it in this routine */ if(opened_locally) { if(iod_obj_close(iod_oh, NULL, NULL)) diff --git a/src/H5VLiod_dtype.c b/src/H5VLiod_dtype.c index 4be26ec..06585e8 100644 --- a/src/H5VLiod_dtype.c +++ b/src/H5VLiod_dtype.c @@ -93,14 +93,6 @@ H5VL_iod_server_dtype_commit_cb(AXE_engine_t UNUSED axe_engine, /* for the process that succeeded in creating the datatype, update the parent KV, create scratch pad */ if(0 == ret) { - kv.key = HDstrdup(last_comp); - kv.value = &dtype_id; - kv.value_len = sizeof(iod_obj_id_t); - /* insert new datatype in kv store of current group */ - if (iod_kv_set(cur_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); - HDfree(kv.key); - /* create the metadata KV object for the datatype */ if(iod_obj_create(coh, IOD_TID_UNKNOWN, NULL, IOD_OBJ_KV, NULL, NULL, &mdkv_id, NULL) < 0) @@ -142,7 +134,7 @@ H5VL_iod_server_dtype_commit_cb(AXE_engine_t UNUSED axe_engine, #endif /* write the serialized type value to the BLOB object */ - if(iod_blob_write(cur_oh, IOD_TID_UNKNOWN, NULL, &mem_desc, &file_desc, NULL, NULL) < 0) + if(iod_blob_write(dtype_oh, IOD_TID_UNKNOWN, NULL, &mem_desc, &file_desc, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to write BLOB object"); /* MSC - TODO store things */ @@ -181,6 +173,14 @@ H5VL_iod_server_dtype_commit_cb(AXE_engine_t UNUSED axe_engine, /* close the Metadata KV object */ if(iod_obj_close(mdkv_oh, NULL, NULL)) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + + kv.key = HDstrdup(last_comp); + kv.value = &dtype_id; + kv.value_len = sizeof(iod_obj_id_t); + /* insert new datatype in kv store of current group */ + if (iod_kv_set(cur_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); + HDfree(kv.key); } #if H5_DO_NATIVE cur_oh.cookie = H5Tcopy(input->type_id); diff --git a/src/H5VLiod_encdec.c b/src/H5VLiod_encdec.c index 5652716..c342984 100644 --- a/src/H5VLiod_encdec.c +++ b/src/H5VLiod_encdec.c @@ -19,6 +19,8 @@ */ #include "H5MMprivate.h" /* Memory management */ +#include "H5Ppublic.h" +#include "H5Spublic.h" #include "H5VLiod_common.h" /* IOD Common Header */ #ifdef H5_HAVE_EFF @@ -176,7 +178,7 @@ int hg_proc_dims_t(hg_proc_t proc, void *data) break; case HG_DECODE: if(struct_data->rank) - struct_data->size = malloc (sizeof(hsize_t) * struct_data->rank); + struct_data->size = (hsize_t *)malloc (sizeof(hsize_t) * struct_data->rank); for(i=0 ; i<struct_data->rank ; i++) { ret = hg_proc_uint64_t(proc, &struct_data->size[i]); @@ -204,7 +206,8 @@ int hg_proc_name_t(hg_proc_t proc, void *data) size_t size; name_t *struct_data = (name_t *) data; - ret = hg_proc_int64_t(proc, struct_data->value_size); + ret = hg_proc_memcpy(proc, struct_data->value_size, sizeof(ssize_t)); + //ret = hg_proc_int64_t(proc, struct_data->value_size); if (ret != HG_SUCCESS) { HG_ERROR_DEFAULT("Proc error"); ret = HG_FAIL; @@ -212,7 +215,8 @@ int hg_proc_name_t(hg_proc_t proc, void *data) } size = (size_t)(*struct_data->value_size); - ret = hg_proc_uint64_t(proc, &struct_data->size); + ret = hg_proc_memcpy(proc, &struct_data->size, sizeof(size_t)); + //ret = hg_proc_uint64_t(proc, &struct_data->size); if (ret != HG_SUCCESS) { HG_ERROR_DEFAULT("Proc error"); ret = HG_FAIL; @@ -221,7 +225,7 @@ int hg_proc_name_t(hg_proc_t proc, void *data) if(NULL != struct_data->value && struct_data->size != 0) { ret = hg_proc_raw(proc, struct_data->value, - MIN(size+1, struct_data->size)); + MIN(size, struct_data->size)); if (ret != HG_SUCCESS) { HG_ERROR_DEFAULT("Proc error"); ret = HG_FAIL; diff --git a/src/H5VLiod_group.c b/src/H5VLiod_group.c index 33a8fad..c50e902 100644 --- a/src/H5VLiod_group.c +++ b/src/H5VLiod_group.c @@ -91,14 +91,6 @@ H5VL_iod_server_group_create_cb(AXE_engine_t UNUSED axe_engine, /* for the process that succeeded in creating the group, create the scratch pad for it too */ if(0 == ret) { - /* insert new group in kv store of parent object */ - kv.key = HDstrdup(last_comp); - kv.value = &grp_id; - kv.value_len = sizeof(iod_obj_id_t); - if (iod_kv_set(cur_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); - HDfree(kv.key); - /* create the metadata KV object for the group */ if(iod_obj_create(coh, IOD_TID_UNKNOWN, NULL, IOD_OBJ_KV, NULL, NULL, &mdkv_id, NULL) < 0) @@ -122,6 +114,14 @@ H5VL_iod_server_group_create_cb(AXE_engine_t UNUSED axe_engine, if(iod_obj_close(mdkv_oh, NULL, NULL)) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + + /* insert new group in kv store of parent object */ + kv.key = HDstrdup(last_comp); + kv.value = &grp_id; + kv.value_len = sizeof(iod_obj_id_t); + if (iod_kv_set(cur_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); + HDfree(kv.key); } /* end if */ /* close parent group if it is not the location we started the @@ -129,6 +129,7 @@ H5VL_iod_server_group_create_cb(AXE_engine_t UNUSED axe_engine, if(loc_handle.cookie != cur_oh.cookie) { iod_obj_close(cur_oh, NULL, NULL); } + #if H5_DO_NATIVE grp_oh.cookie = H5Gcreate2(loc_handle.cookie, name, input->lcpl_id, input->gcpl_id, input->gapl_id); diff --git a/src/H5VLiod_link.c b/src/H5VLiod_link.c index bf24949..bab9663 100644 --- a/src/H5VLiod_link.c +++ b/src/H5VLiod_link.c @@ -135,10 +135,7 @@ H5VL_iod_server_link_create_cb(AXE_engine_t UNUSED axe_engine, HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); HDfree(kv.key); - /* close the source group */ - if(src_oh.cookie != input->loc_oh.cookie) { - iod_obj_close(src_oh, NULL, NULL); - } + iod_obj_close(src_oh, NULL, NULL); /* open the target object */ if (iod_obj_open_write(coh, target_id, NULL, &target_oh, NULL) < 0) diff --git a/src/H5VLiod_server.c b/src/H5VLiod_server.c index fa07805..3ce68c7 100644 --- a/src/H5VLiod_server.c +++ b/src/H5VLiod_server.c @@ -14,22 +14,11 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #define H5G_PACKAGE /*suppress error about including H5Gpkg */ -#define H5D_PACKAGE /*suppress error about including H5Dpkg */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Apublic.h" /* Attributes */ -#include "H5Dpkg.h" /* Dataset functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5Sprivate.h" /* Dataspaces */ -#include "H5Tprivate.h" /* Datatypes */ -#include "H5VLprivate.h" /* VOL plugins */ + +#include "H5Gpkg.h" /* Groups */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5WBprivate.h" /* Wrapped Buffers */ #include "H5VLiod_server.h" -#include "H5WBprivate.h" /* Wrapped Buffers */ #include "H5VLiod_compactor_queue.h" #include "H5VLiod_compactor.h" /* Compactor Routine */ @@ -69,9 +58,6 @@ H5VLiod_start_handler(MPI_Comm comm, MPI_Info UNUSED info) MPI_Comm_size(comm, &num_procs); - #if DEBUG_COMPACTOR - fp = fopen("compactor.out", "w+"); - #endif iod_comm = comm; /* initialize the netwrok class */ @@ -277,6 +263,8 @@ H5VL_iod_server_eff_finalize(hg_handle_t handle) shutdown = TRUE; } + + done: HG_Handler_start_output(handle, &ret_value); FUNC_LEAVE_NOAPI(ret_value) @@ -367,6 +355,7 @@ H5VL_iod_server_file_create(hg_handle_t handle) op_data->hg_handle = handle; op_data->input = (void *)input; + if (AXE_SUCCEED != AXEcreate_task(engine, input->axe_id, 0, NULL, 0, NULL, H5VL_iod_server_file_create_cb, op_data, NULL)) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, HG_FAIL, "can't insert task into async engine"); @@ -1353,7 +1342,6 @@ H5VL_iod_server_dset_write(hg_handle_t handle) } #endif - fprintf(fp, "Write with task ID : %d\n", input->axe_id); #if 1 if(CP_SUCCESS != H5VL_iod_server_dset_compactor(op_data, WRITE)){ @@ -1392,18 +1380,18 @@ int H5VL_iod_server_dset_compactor(op_data_t *op_data, int request_type) FUNC_ENTER_NOAPI_NOINIT #if DEBUG_COMPACTOR - fprintf (fp, "id: %d, Enters the the dset_compactor, compactor_flag :%d\n", + fprintf (stderr, "id: %d, Enters the the dset_compactor, compactor_flag :%d\n", request_id, compactor_queue_flag); - fflush(fp); + fflush(stderr); if (NULL == curr_queue) - fprintf(fp,"Compactor Not present\n"); + fprintf(stderr,"Compactor Not present\n"); else - fprintf(fp,"Queue exists with compactor_flag : %d, and %d reqs\n", + fprintf(stderr,"Queue exists with compactor_flag : %d, and %d reqs\n", compactor_queue_flag, H5VL_iod_get_number_of_requests(curr_queue)); - fflush(fp); + fflush(stderr); #endif @@ -1415,8 +1403,8 @@ int H5VL_iod_server_dset_compactor(op_data_t *op_data, int request_type) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, CP_FAIL, "Queue initialization error"); } - fprintf (fp, "Completed creating a queue : %p\n", (void *)curr_queue); - fflush(fp); + fprintf (stderr, "Completed creating a queue : %p\n", (void *)curr_queue); + fflush(stderr); } @@ -1427,10 +1415,10 @@ int H5VL_iod_server_dset_compactor(op_data_t *op_data, int request_type) #if DEBUG_COMPACTOR - fprintf (fp,"op_data : %p, input_struct : %p\n", + fprintf (stderr,"op_data : %p, input_struct : %p\n", entry.input_structure, op_data); - fflush(fp); + fflush(stderr); #endif if (CP_SUCCESS != @@ -1440,16 +1428,16 @@ int H5VL_iod_server_dset_compactor(op_data_t *op_data, int request_type) } if (!compactor_queue_flag){ #if DEBUG_COMPACTOR - fprintf (fp, "Adding a barrier task!\n "); - fflush(fp); + fprintf (stderr, "Adding a barrier task!\n "); + fflush(stderr); #endif if (AXE_SUCCEED != AXEcreate_barrier_task(engine, input->axe_id, H5VL_iod_server_dset_compactor_cb, curr_queue, NULL)) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, HG_FAIL, "can't insert task into async engine"); #if DEBUG_COMPACTOR - fprintf (fp, "Completed Adding a barrier task\n"); - fflush(fp); + fprintf (stderr, "Completed Adding a barrier task\n"); + fflush(stderr); #endif pthread_mutex_lock(&lock); @@ -1458,8 +1446,8 @@ int H5VL_iod_server_dset_compactor(op_data_t *op_data, int request_type) } #if DEBUG_COMPACTOR - fprintf(fp, "Exiting the compactor function \n"); - fflush(fp); + fprintf(stderr, "Exiting the compactor function \n"); + fflush(stderr); #endif request_id++; @@ -1492,6 +1480,7 @@ H5VL_iod_server_dset_set_extent(hg_handle_t handle) axe_ids_t *newParents = NULL; size_t ii; AXE_status_t status; + int reconstruct = 0; FUNC_ENTER_NOAPI_NOINIT @@ -1512,14 +1501,23 @@ H5VL_iod_server_dset_set_extent(hg_handle_t handle) op_data->input = (void *)input; for (ii = 0; ii < input->parent_axe_ids.count; ii++){ + if (AXE_SUCCEED != AXEbegin_try()){ + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, HG_FAIL, "can't begin trying in AXE"); + } if ( AXE_SUCCEED != AXEget_status(engine, input->parent_axe_ids.ids[ii], &status)){ - fprintf (fp, "Task %ld does not exist\n", input->parent_axe_ids.ids[ii]); + fprintf (stderr, "Task %ld does not exist\n", input->parent_axe_ids.ids[ii]); if (SUCCEED != H5VL_iod_reconstruct_parents (engine, &input->parent_axe_ids, &newParents)){ - fprintf (fp, "Error while reconstructing parents\n"); + fprintf (stderr, "Error while reconstructing parents\n"); } - break; /*There is atleast one task that does not exist lets reconstruct*/ + reconstruct = 1; + } + if (AXE_SUCCEED != AXEend_try()){ + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, HG_FAIL, "can't end trying in AXE"); + } + if (reconstruct){ + break; /*If reconstructed already no need to check other requests!*/ } } @@ -1588,10 +1586,16 @@ H5VL_iod_reconstruct_parents (AXE_engine_t axe_engine, } for (i = 0; i < old_parents->count; i++){ + if (AXE_SUCCEED != AXEbegin_try()){ + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't begin trying in AXE"); + } if ( AXE_SUCCEED == AXEget_status(engine, old_parents->ids[i], &status)){ newParents->ids[newParents->count] = old_parents->ids[i]; newParents->count++; } + if (AXE_SUCCEED != AXEend_try()){ + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't end trying in AXE"); + } } assert(newParents->count != old_parents->count); *new_parents = newParents; @@ -1625,6 +1629,7 @@ H5VL_iod_server_dset_close(hg_handle_t handle) AXE_status_t status; axe_ids_t *newParents = NULL; size_t ii; + int reconstruct = 0; FUNC_ENTER_NOAPI_NOINIT @@ -1645,14 +1650,24 @@ H5VL_iod_server_dset_close(hg_handle_t handle) op_data->input = (void *)input; for (ii = 0; ii < input->parent_axe_ids.count; ii++){ + if (AXE_SUCCEED != AXEbegin_try()){ + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, HG_FAIL, "can't begin trying in AXE"); + } + if ( AXE_SUCCEED != AXEget_status(engine, input->parent_axe_ids.ids[ii], &status)){ - fprintf (fp, "Task %ld does not exist\n", input->parent_axe_ids.ids[ii]); + fprintf (stderr, "Task %ld does not exist\n", input->parent_axe_ids.ids[ii]); if (SUCCEED != H5VL_iod_reconstruct_parents (engine, &input->parent_axe_ids, &newParents)){ - fprintf (fp, "Error while reconstructing parents\n"); + fprintf (stderr, "Error while reconstructing parents\n"); } - break; /*There is atleast one task that does not exist lets reconstruct*/ + reconstruct = 1; + } + if (AXE_SUCCEED != AXEend_try()){ + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, HG_FAIL, "can't end trying in AXE"); + } + if (reconstruct){ + break; } } @@ -1668,6 +1683,18 @@ H5VL_iod_server_dset_close(hg_handle_t handle) } else{ if(input->parent_axe_ids.count) { +#if 0 + int i; + AXE_status_t status; + for(i=0 ; i<input->parent_axe_ids.count ; i++) { + if(AXEget_status(engine, input->parent_axe_ids.ids[i], &status) < 0) { + fprintf(stderr, "GET STATUS FAILED\n"); + exit(1); + } + fprintf(stderr, "%d: AXE ID %llu status %d\n", + i, input->parent_axe_ids.ids[i], status); + } +#endif if (AXE_SUCCEED != AXEcreate_task(engine, input->axe_id, input->parent_axe_ids.count, input->parent_axe_ids.ids, 0, NULL, @@ -2562,6 +2589,133 @@ done: FUNC_LEAVE_NOAPI(ret_value) } +herr_t +H5VL_iod_get_file_desc(hid_t space_id, hssize_t *count, iod_hyperslab_t *hslabs) +{ + hssize_t num_descriptors = 0, n; + int ndims = 0, i; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + /* get the rank of this dataspace */ + if((ndims = H5Sget_simple_extent_ndims(space_id)) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get dataspace dimesnsion"); + + switch(H5Sget_select_type(space_id)) { + case H5S_SEL_NONE: + /* nothing selected */ + num_descriptors = 0; + HGOTO_DONE(SUCCEED); + case H5S_SEL_ALL: + /* The entire dataspace is selected, 1 large iod hyperslab is needed */ + num_descriptors = 1; + + if(NULL != hslabs) { + hsize_t dims[H5S_MAX_RANK]; + + /* get the dimensions sizes of the dataspace */ + if(H5Sget_simple_extent_dims(space_id, dims, NULL) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get dataspace dimesnsion sizes"); + /* populate the hyperslab */ + for(i=0 ; i<ndims ; i++) { + hslabs[0].start[i] = 0; + hslabs[0].stride[i] = 1; + hslabs[0].block[i] = dims[i]; + hslabs[0].count[i] = 1; + } + } + break; + case H5S_SEL_POINTS: + { + /* we need a hyperslab element for each point */ + if((num_descriptors = H5Sget_select_elem_npoints(space_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "invalid point selection"); + + if(NULL != hslabs) { + hsize_t *points = NULL; + + if(NULL == (points = (hsize_t *)malloc(sizeof(hsize_t) * ndims * + (hsize_t)num_descriptors))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate array for points coords"); + + if(H5Sget_select_elem_pointlist(space_id, (hsize_t)0, + (hsize_t)num_descriptors, points) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "Failed to retrieve point coordinates"); + + /* populate the hyperslab */ + for(n=0 ; n<num_descriptors ; n++) { + for(i=0 ; i<ndims ; i++) { + hslabs[n].start[i] = *points++; + hslabs[n].stride[i] = 1; + hslabs[n].block[i] = 1; + hslabs[n].count[i] = 1; + } + } + free(points); + } + break; + } + case H5S_SEL_HYPERSLABS: + { + /* if the selection is a regular hyperslab + selection, only 1 iod hyperslab object is + needed */ + if(H5Sselect_is_regular(space_id)) { + num_descriptors = 1; + + if(NULL != hslabs) { + if(H5Sget_reg_hyperslab_params(space_id, + hslabs[0].start, + hslabs[0].stride, + hslabs[0].count, + hslabs[0].block) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "Failed to retrieve hyperslab selection"); + } + } + /* Otherwise populate the hslabs by gettinge very block */ + else { + if((num_descriptors = H5Sget_select_hyper_nblocks(space_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "invalid hyperslab selection"); + + if(NULL != hslabs) { + hsize_t *blocks; + + if(NULL == (blocks = (hsize_t *)malloc(sizeof(hsize_t) * 2 * + ndims * num_descriptors))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate array for points coords"); + + if(H5Sget_select_hyper_blocklist(space_id, (hsize_t)0, + (hsize_t)num_descriptors, blocks) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "Failed to retrieve point coordinates"); + + /* populate the hyperslab */ + for(n=0 ; n<num_descriptors ; n++) { + for(i=0 ; i<ndims ; i++) { + hslabs[n].start[i] = *blocks++; + hslabs[n].stride[i] = 1; + hslabs[n].block[i] = 1; + hslabs[n].count[i] = *blocks++; + } + } + + free(blocks); + } + } + break; + } + case H5S_SEL_ERROR: + case H5S_SEL_N: + default: + HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "Invalid Selection type"); + } + + *count = num_descriptors; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} + #if 0 /*------------------------------------------------------------------------- diff --git a/src/H5VLiod_server.h b/src/H5VLiod_server.h index bde1247..50340d1 100644 --- a/src/H5VLiod_server.h +++ b/src/H5VLiod_server.h @@ -19,6 +19,10 @@ #ifndef _H5VLiod_server_H #define _H5VLiod_server_H +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Ppublic.h" +#include "H5Spublic.h" #include "H5VLiod_common.h" @@ -43,10 +47,6 @@ typedef struct scratch_pad_t { } scratch_pad_t; -#if DEBUG_COMPACTOR -FILE *fp; -#endif - int compactor_queue_flag; pthread_mutex_t lock; @@ -239,6 +239,7 @@ H5_DLL void H5VL_iod_server_object_get_comment_cb(AXE_engine_t UNUSED axe_engine H5_DLL herr_t H5VL_iod_server_traverse(iod_handle_t coh, iod_obj_id_t loc_id, iod_handle_t loc_handle, const char *path, hbool_t create_interm_grps, char **last_comp, iod_obj_id_t *iod_id, iod_handle_t *iod_oh); +H5_DLL herr_t H5VL_iod_get_file_desc(hid_t space_id, hssize_t *count, iod_hyperslab_t *hslabs); #endif /* H5_HAVE_EFF */ #endif /* _H5VLiod_server_H */ |