summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Warren <Richard.Warren@hdfgroup.org>2020-10-01 14:24:50 (GMT)
committerRichard Warren <Richard.Warren@hdfgroup.org>2020-10-01 14:24:50 (GMT)
commit8b9212b0156ace0f30f7ff05222e956a23d3f243 (patch)
treefc5223fdbe8887f415c0b58502d96710d6d2a414
parent2368e610d5d6e4ec4f3b182f4c2ea14ec8fcacf3 (diff)
downloadhdf5-8b9212b0156ace0f30f7ff05222e956a23d3f243.zip
hdf5-8b9212b0156ace0f30f7ff05222e956a23d3f243.tar.gz
hdf5-8b9212b0156ace0f30f7ff05222e956a23d3f243.tar.bz2
Change the linux usage of reallocarray to a more portable realloc. Also updated the initailization of the work queue.
-rw-r--r--src/H5FDsubfile_mpi.c4
-rw-r--r--src/H5FDsubfile_threads.c21
2 files changed, 20 insertions, 5 deletions
diff --git a/src/H5FDsubfile_mpi.c b/src/H5FDsubfile_mpi.c
index 5bffdad..6774536 100644
--- a/src/H5FDsubfile_mpi.c
+++ b/src/H5FDsubfile_mpi.c
@@ -806,8 +806,8 @@ record_fid_to_subfile(hid_t fid, hid_t subfile_context_id, int *next_index)
}
if (index == sf_file_map_size) {
int i;
- sf_open_file_map = reallocarray(sf_open_file_map,
- (size_t)(sf_file_map_size * 2), sizeof(file_map_to_context_t));
+ sf_open_file_map = realloc(sf_open_file_map,
+ ((size_t)(sf_file_map_size * 2) * sizeof(file_map_to_context_t)));
if (sf_open_file_map == NULL) {
perror("realloc");
return FAIL;
diff --git a/src/H5FDsubfile_threads.c b/src/H5FDsubfile_threads.c
index dcf2e80..8317009 100644
--- a/src/H5FDsubfile_threads.c
+++ b/src/H5FDsubfile_threads.c
@@ -42,9 +42,12 @@ static hg_thread_t ioc_thread;
#ifndef HG_TEST_NUM_THREADS_DEFAULT
# define HG_TEST_NUM_THREADS_DEFAULT 4
#endif
-#define POOL_CONCURRENT_MAX 256
+/* Could this be the reason that benchmarks hang for sizes > 256 ??? */
+// #define POOL_CONCURRENT_MAX 256
+// #define POOL_CONCURRENT_MAX 131072
-static struct hg_thread_work pool_request[POOL_CONCURRENT_MAX];
+static int pool_concurrent_max = 0;
+static struct hg_thread_work *pool_request = NULL;
/*-------------------------------------------------------------------------
* Function: local ioc_thread_main
@@ -104,6 +107,8 @@ initialize_ioc_threads(subfiling_context_t *sf_context)
int status;
unsigned int thread_pool_count = HG_TEST_NUM_THREADS_DEFAULT;
int64_t *context_id = (int64_t *) malloc(sizeof(int64_t));
+ int world_size = sf_context->topology->world_size;
+ size_t alloc_size = ((size_t)world_size * sizeof(struct hg_thread_work));
char *envValue;
assert(context_id != NULL);
/* Initialize the main IOC thread input argument.
@@ -114,6 +119,16 @@ initialize_ioc_threads(subfiling_context_t *sf_context)
*/
context_id[0] = sf_context->sf_context_id;
+ if (pool_request == NULL) {
+ if ((pool_request = (struct hg_thread_work *)malloc(alloc_size)) == NULL) {
+ perror("malloc error");
+ return -1;
+ }
+ else pool_concurrent_max = world_size;
+ }
+
+ memset(pool_request, 0, alloc_size);
+
/* Initialize a couple of mutex variables that are used
* during IO concentrator operations to serialize
* access to key objects, e.g. reference counting.
@@ -285,7 +300,7 @@ tpool_add_work(sf_work_request_t *work)
{
static int work_index = 0;
hg_thread_mutex_lock(&ioc_mutex);
- if (work_index == POOL_CONCURRENT_MAX)
+ if (work_index == pool_concurrent_max)
work_index = 0;
pool_request[work_index].func = handle_work_request;
pool_request[work_index].args = work;