summaryrefslogtreecommitdiffstats
path: root/test/ttsafe_dcreate.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/ttsafe_dcreate.c')
-rw-r--r--test/ttsafe_dcreate.c82
1 files changed, 33 insertions, 49 deletions
diff --git a/test/ttsafe_dcreate.c b/test/ttsafe_dcreate.c
index 36b5f1f..cedafd0 100644
--- a/test/ttsafe_dcreate.c
+++ b/test/ttsafe_dcreate.c
@@ -31,39 +31,24 @@
#ifdef H5_HAVE_THREADSAFE
-#define FILENAME "ttsafe_dcreate.h5"
-#define NUM_THREAD 16
+#define FILENAME "ttsafe_dcreate.h5"
+#define NUM_THREAD 16
void *tts_dcreate_creator(void *);
typedef struct thread_info {
- int id;
- hid_t file;
- const char *dsetname;
+ int id;
+ hid_t file;
+ const char *dsetname;
} thread_info;
/*
* Set individual dataset names (rather than generated the names
* automatically)
*/
-const char *dsetname[NUM_THREAD]={
- "zero",
- "one",
- "two",
- "three",
- "four",
- "five",
- "six",
- "seven",
- "eight",
- "nine",
- "ten",
- "eleven",
- "twelve",
- "thirteen",
- "fourteen",
- "fifteen"
-};
+const char *dsetname[NUM_THREAD] = {"zero", "one", "two", "three", "four", "five",
+ "six", "seven", "eight", "nine", "ten", "eleven",
+ "twelve", "thirteen", "fourteen", "fifteen"};
thread_info thread_out[NUM_THREAD];
@@ -79,11 +64,11 @@ tts_dcreate(void)
H5TS_thread_t threads[NUM_THREAD];
/* HDF5 data definitions */
- hid_t file = H5I_INVALID_HID;
- hid_t dataset = H5I_INVALID_HID;
- int datavalue, i;
+ hid_t file = H5I_INVALID_HID;
+ hid_t dataset = H5I_INVALID_HID;
+ int datavalue, i;
H5TS_attr_t attribute;
- herr_t status;
+ herr_t status;
/* set pthread attribute to perform global scheduling */
H5TS_attr_init(&attribute);
@@ -101,30 +86,31 @@ tts_dcreate(void)
CHECK(file, H5I_INVALID_HID, "H5Fcreate");
/* simultaneously create a large number of datasets within the file */
- for(i = 0; i < NUM_THREAD; i++) {
- thread_out[i].id = i;
- thread_out[i].file = file;
+ for (i = 0; i < NUM_THREAD; i++) {
+ thread_out[i].id = i;
+ thread_out[i].file = file;
thread_out[i].dsetname = dsetname[i];
- threads[i] = H5TS_create_thread(tts_dcreate_creator, NULL, &thread_out[i]);
+ threads[i] = H5TS_create_thread(tts_dcreate_creator, NULL, &thread_out[i]);
}
- for(i = 0;i < NUM_THREAD; i++)
+ for (i = 0; i < NUM_THREAD; i++)
H5TS_wait_for_thread(threads[i]);
/* compare data to see if it is written correctly */
- for(i = 0; i < NUM_THREAD; i++) {
- if((dataset = H5Dopen2(file, dsetname[i], H5P_DEFAULT)) < 0) {
+ for (i = 0; i < NUM_THREAD; i++) {
+ if ((dataset = H5Dopen2(file, dsetname[i], H5P_DEFAULT)) < 0) {
TestErrPrintf("Dataset name not found - test failed\n");
H5Fclose(file);
return;
- } else {
+ }
+ else {
status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &datavalue);
CHECK(status, FAIL, "H5Dread");
- if(datavalue != i) {
- TestErrPrintf("Wrong value read %d for dataset name %s - test failed\n",
- datavalue, dsetname[i]);
+ if (datavalue != i) {
+ TestErrPrintf("Wrong value read %d for dataset name %s - test failed\n", datavalue,
+ dsetname[i]);
status = H5Dclose(dataset);
CHECK(status, FAIL, "H5Dclose");
status = H5Fclose(file);
@@ -132,7 +118,7 @@ tts_dcreate(void)
return;
}
- status= H5Dclose(dataset);
+ status = H5Dclose(dataset);
CHECK(status, FAIL, "H5Dclose");
}
}
@@ -148,27 +134,26 @@ tts_dcreate(void)
void *
tts_dcreate_creator(void *_thread_data)
{
- hid_t dataspace = H5I_INVALID_HID;
- hid_t dataset = H5I_INVALID_HID;
- herr_t status;
- hsize_t dimsf[1]; /* dataset dimensions */
+ hid_t dataspace = H5I_INVALID_HID;
+ hid_t dataset = H5I_INVALID_HID;
+ herr_t status;
+ hsize_t dimsf[1]; /* dataset dimensions */
struct thread_info thread_data;
memcpy(&thread_data, _thread_data, sizeof(struct thread_info));
/* define dataspace for dataset */
- dimsf[0] = 1;
+ dimsf[0] = 1;
dataspace = H5Screate_simple(1, dimsf, NULL);
CHECK(dataspace, H5I_INVALID_HID, "H5Screate_simple");
/* create a new dataset within the file */
- dataset = H5Dcreate2(thread_data.file, thread_data.dsetname,
- H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dataset = H5Dcreate2(thread_data.file, thread_data.dsetname, H5T_NATIVE_INT, dataspace, H5P_DEFAULT,
+ H5P_DEFAULT, H5P_DEFAULT);
CHECK(dataset, H5I_INVALID_HID, "H5Dcreate2");
/* initialize data for dataset and write value to dataset */
- status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
- H5P_DEFAULT, &thread_data.id);
+ status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &thread_data.id);
CHECK(status, FAIL, "H5Dwrite");
/* close dataset and dataspace resources */
@@ -186,4 +171,3 @@ cleanup_dcreate(void)
HDunlink(FILENAME);
}
#endif /*H5_HAVE_THREADSAFE*/
-