From 9f97c65328a8f765a75d87032ae55106e80be2d4 Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Thu, 19 Jun 2014 20:01:01 -0500 Subject: [svn-r25336] revert Jerome's changes to analysis changes. --- examples/h5ff_client_adv_analysis.c | 2 +- src/H5VLiod_analysis.c | 78 +++++++++++++++++-------------------- 2 files changed, 37 insertions(+), 43 deletions(-) diff --git a/examples/h5ff_client_adv_analysis.c b/examples/h5ff_client_adv_analysis.c index 0e3886d..784d928 100644 --- a/examples/h5ff_client_adv_analysis.c +++ b/examples/h5ff_client_adv_analysis.c @@ -11,7 +11,7 @@ #include /* define filename for this app, and max size after username prepended */ -#define FILENAME_APP "eff_analysis.h5" +#define FILENAME_APP "eff_adv_analysis.h5" #define NAME_SIZE 64 /* macros related to error reporting */ diff --git a/src/H5VLiod_analysis.c b/src/H5VLiod_analysis.c index b230950..2117b4f 100644 --- a/src/H5VLiod_analysis.c +++ b/src/H5VLiod_analysis.c @@ -37,7 +37,7 @@ typedef struct { #ifdef H5_HAVE_PYTHON -static pthread_mutex_t h5python_mutex = PTHREAD_MUTEX_INITIALIZER; +pthread_mutex_t h5python_mutex; static hbool_t numpy_initialized = FALSE; static void H5VL__iod_numpy_init(void); @@ -299,7 +299,7 @@ H5VL__iod_numpy_init(void) * If, however, the extension module involves multiple files where the C-API * is needed then some additional steps must be taken. */ import_array(); - + numpy_initialized = TRUE; } /* end H5VL__iod_numpy_init() */ /*------------------------------------------------------------------------- @@ -354,7 +354,7 @@ H5VL__iod_load_script(const char *script, const char *func_name) ret_value = po_func; done: - Py_DECREF(po_rstring); + //Py_DECREF(po_rstring); return ret_value; } /* end H5VL__iod_load_script() */ @@ -566,17 +566,11 @@ H5VL__iod_split(const char *split_script, void *data, size_t num_elmts, hid_t *split_data_type_id) { herr_t ret_value = SUCCEED; /* Return value */ + PyObject *po_func = NULL, *po_numpy_array = NULL, *po_args_tup = NULL; PyObject *po_numpy_array_split = NULL; - Py_BEGIN_ALLOW_THREADS - - pthread_mutex_lock(&h5python_mutex); - if(!numpy_initialized) { - H5VL__iod_numpy_init(); - numpy_initialized = TRUE; - } - pthread_mutex_unlock(&h5python_mutex); + if(!numpy_initialized) H5VL__iod_numpy_init(); /* Create numpy array */ if(NULL == (po_numpy_array = H5VL__iod_create_numpy_array(num_elmts, data_type_id, data))) @@ -605,11 +599,11 @@ H5VL__iod_split(const char *split_script, void *data, size_t num_elmts, done: /* Cleanup */ - Py_XDECREF(po_func); - Py_XDECREF(po_args_tup); - Py_XDECREF(po_numpy_array); - Py_XDECREF(po_numpy_array_split); - Py_END_ALLOW_THREADS + //Py_XDECREF(po_func); + //Py_XDECREF(po_args_tup); + //Py_XDECREF(po_numpy_array); + //Py_XDECREF(po_numpy_array_split); + return ret_value; } /* end H5VL__iod_split() */ @@ -635,14 +629,7 @@ H5VL__iod_combine(const char *combine_script, void **split_data, size_t *split_n size_t count = 0; size_t i, k = 0; - Py_BEGIN_ALLOW_THREADS - - pthread_mutex_lock(&h5python_mutex); - if(!numpy_initialized) { - H5VL__iod_numpy_init(); - numpy_initialized = TRUE; - } - pthread_mutex_unlock(&h5python_mutex); + if(!numpy_initialized) H5VL__iod_numpy_init(); for(i = 0; i < num_targets; i++) { if(0 != split_num_elmts[i]) @@ -693,13 +680,13 @@ H5VL__iod_combine(const char *combine_script, void **split_data, size_t *split_n done: /* Cleanup */ - Py_XDECREF(po_func); - Py_XDECREF(po_args_tup); + //Py_XDECREF(po_func); + //Py_XDECREF(po_args_tup); for(i = 0; i < count; i++) { - Py_XDECREF(po_numpy_arrays + i); + //Py_XDECREF(po_numpy_arrays + i); } - Py_XDECREF(po_numpy_array_combine); - Py_END_ALLOW_THREADS + //Py_XDECREF(po_numpy_array_combine); + return ret_value; } @@ -725,14 +712,7 @@ H5VL__iod_integrate(const char *integrate_script, void **combine_data, PyObject *po_numpy_array_integrate = NULL; size_t i, k = 0; - Py_BEGIN_ALLOW_THREADS - - pthread_mutex_lock(&h5python_mutex); - if(!numpy_initialized) { - H5VL__iod_numpy_init(); - numpy_initialized = TRUE; - } - pthread_mutex_unlock(&h5python_mutex); + if(!numpy_initialized) H5VL__iod_numpy_init(); // for(i = 0; i < count; i++) { // if(0 != combine_num_elmts[i]) @@ -783,13 +763,13 @@ H5VL__iod_integrate(const char *integrate_script, void **combine_data, done: /* Cleanup */ - Py_XDECREF(po_func); - Py_XDECREF(po_args_tup); + //Py_XDECREF(po_func); + //Py_XDECREF(po_args_tup); for(i = 0; i < count; i++) { - Py_XDECREF(po_numpy_arrays + i); + //Py_XDECREF(po_numpy_arrays + i); } - Py_XDECREF(po_numpy_array_integrate); - Py_END_ALLOW_THREADS + //Py_XDECREF(po_numpy_array_combine); + return ret_value; } @@ -814,6 +794,9 @@ H5VL__iod_request_container_open(const char *file_name, iod_handle_t **cohs) iod_ret_t ret; iod_hint_list_t *con_open_hint = NULL; int i; + + if(pthread_mutex_init(&h5python_mutex, NULL)) + HGOTO_ERROR_FF(FAIL, "can't init AS mutex"); if(NULL == (hg_reqs = (hg_request_t *)malloc(sizeof(hg_request_t) * (unsigned int) num_ions_g))) HGOTO_ERROR_FF(FAIL, "can't allocate HG requests"); @@ -906,6 +889,8 @@ H5VL__iod_request_container_close(iod_handle_t *cohs) free(hg_reqs); free(cohs); + if(pthread_mutex_destroy(&h5python_mutex)) + HGOTO_ERROR_FF(FAIL, "can't destroy AS mutex"); done: return ret_value; } /* end H5VL__iod_request_container_close */ @@ -1264,9 +1249,13 @@ H5VL__iod_farm_split(iod_handle_t coh, iod_obj_id_t obj_id, iod_trans_id_t rtid, /* Apply split python script on data from query */ #ifdef H5_HAVE_PYTHON if(nelmts) { + if (pthread_mutex_lock(&h5python_mutex)) + HGOTO_ERROR_FF(FAIL, "can't lock AS mutex"); if(FAIL == H5VL__iod_split(split_script, data, nelmts, type_id, split_data, split_num_elmts, split_type_id)) HGOTO_ERROR_FF(FAIL, "can't apply split script to data"); + if (pthread_mutex_unlock(&h5python_mutex)) + HGOTO_ERROR_FF(FAIL, "can't unlock AS mutex"); } #endif @@ -1503,6 +1492,9 @@ H5VL_iod_server_container_open(hg_handle_t handle) iod_hint_list_t *con_open_hint = NULL; int ret_value = HG_SUCCESS; + if(pthread_mutex_init(&h5python_mutex, NULL)) + HGOTO_ERROR_FF(FAIL, "can't init AS mutex"); + if(HG_FAIL == HG_Handler_get_input(handle, &file_name)) HGOTO_ERROR_FF(FAIL, "can't get input parameters"); @@ -1544,6 +1536,8 @@ H5VL_iod_server_container_close(hg_handle_t handle) if(iod_container_close(coh, NULL, NULL)) HGOTO_ERROR_FF(FAIL, "can't open file"); + if(pthread_mutex_destroy(&h5python_mutex)) + HGOTO_ERROR_FF(FAIL, "can't destroy AS mutex"); done: HG_Handler_start_output(handle, &ret_value); return ret_value; -- cgit v0.12