diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2004-12-29 14:32:06 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2004-12-29 14:32:06 (GMT) |
commit | 37232bd4f0f8199f956c823cdff72ece2ca9aa16 (patch) | |
tree | 38e37f7208355500b7f223e90bf014424c63300b /test/ttsafe_acreate.c | |
parent | 20146575aaeead9e05af73977dee863de63bf50f (diff) | |
download | hdf5-37232bd4f0f8199f956c823cdff72ece2ca9aa16.zip hdf5-37232bd4f0f8199f956c823cdff72ece2ca9aa16.tar.gz hdf5-37232bd4f0f8199f956c823cdff72ece2ca9aa16.tar.bz2 |
[svn-r9729] Purpose:
Bug Fix/Code Cleanup/Doc Cleanup/Optimization/Branch Sync :-)
Description:
Generally speaking, this is the "signed->unsigned" change to selections.
However, in the process of merging code back, things got stickier and stickier
until I ended up doing a big "sync the two branches up" operation. So... I
brought back all the "infrastructure" fixes from the development branch to the
release branch (which I think were actually making some improvement in
performance) as well as fixed several bugs which had been fixed in one branch,
but not the other.
I've also tagged the repository before making this checkin with the label
"before_signed_unsigned_changes".
Platforms tested:
FreeBSD 4.10 (sleipnir) w/parallel & fphdf5
FreeBSD 4.10 (sleipnir) w/threadsafe
FreeBSD 4.10 (sleipnir) w/backward compatibility
Solaris 2.7 (arabica) w/"purify options"
Solaris 2.8 (sol) w/FORTRAN & C++
AIX 5.x (copper) w/parallel & FORTRAN
IRIX64 6.5 (modi4) w/FORTRAN
Linux 2.4 (heping) w/FORTRAN & C++
Misc. update:
Diffstat (limited to 'test/ttsafe_acreate.c')
-rw-r--r-- | test/ttsafe_acreate.c | 197 |
1 files changed, 96 insertions, 101 deletions
diff --git a/test/ttsafe_acreate.c b/test/ttsafe_acreate.c index d5ed7b7..f535541 100644 --- a/test/ttsafe_acreate.c +++ b/test/ttsafe_acreate.c @@ -41,7 +41,7 @@ * * 19 May 2000, Bill Wendling * Changed so that it creates its own HDF5 file and removes it at cleanup - * time. Added num_errs flag. + * time. * ********************************************************************/ @@ -67,114 +67,109 @@ typedef struct acreate_data_struct { void tts_acreate(void) { - /* Pthread declarations */ - pthread_t threads[NUM_THREADS]; - - /* HDF5 data declarations */ - hid_t file, dataset; - hid_t dataspace, datatype; - hid_t attribute; - hsize_t dimsf[1]; /* dataset dimensions */ - - /* data declarations */ - int data; /* data to write */ - int buffer, ret, i; - - ttsafe_name_data_t *attrib_data; - - /* - * Create an HDF5 file using H5F_ACC_TRUNC access, default file - * creation plist and default file access plist - */ - file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* create a simple dataspace for the dataset */ - dimsf[0] = 1; - dataspace = H5Screate_simple(1, dimsf, NULL); - - /* define datatype for the data using native little endian integers */ - datatype = H5Tcopy(H5T_NATIVE_INT); - H5Tset_order(datatype, H5T_ORDER_LE); - - /* create a new dataset within the file */ - dataset = H5Dcreate(file, DATASETNAME, datatype, dataspace, - H5P_DEFAULT); - - /* initialize data for dataset and write value to dataset */ - data = NUM_THREADS; - H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, &data); - - /* - * Simultaneously create a large number of attributes to be associated - * with the dataset - */ - for (i = 0; i < NUM_THREADS; i++) { - attrib_data = malloc(sizeof(ttsafe_name_data_t)); - attrib_data->dataset = dataset; - attrib_data->datatype = datatype; - attrib_data->dataspace = dataspace; - attrib_data->current_index = i; - pthread_create(&threads[i], NULL, tts_acreate_thread, - attrib_data); - } - - for (i = 0; i < NUM_THREADS; i++) - pthread_join(threads[i], NULL); - - /* verify the correctness of the test */ - for (i = 0; i < NUM_THREADS; i++) { - attribute = H5Aopen_name(dataset,gen_name(i)); - - if (attribute < 0) { - TestErrPrintf( - "unable to open appropriate attribute. " - "Test failed!\n"); - } else { - ret = H5Aread(attribute, H5T_NATIVE_INT, &buffer); - - if (ret < 0 || buffer != i) { - TestErrPrintf("wrong data values. Test failed!\n"); - } - - H5Aclose(attribute); - } - } - - /* close remaining resources */ - H5Sclose(dataspace); - H5Tclose(datatype); - H5Dclose(dataset); - H5Fclose(file); + /* Pthread declarations */ + pthread_t threads[NUM_THREADS]; + + /* HDF5 data declarations */ + hid_t file, dataset; + hid_t dataspace, datatype; + hid_t attribute; + hsize_t dimsf[1]; /* dataset dimensions */ + + /* data declarations */ + int data; /* data to write */ + int buffer, ret, i; + + ttsafe_name_data_t *attrib_data; + + /* + * Create an HDF5 file using H5F_ACC_TRUNC access, default file + * creation plist and default file access plist + */ + file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + + /* create a simple dataspace for the dataset */ + dimsf[0] = 1; + dataspace = H5Screate_simple(1, dimsf, NULL); + + /* define datatype for the data using native little endian integers */ + datatype = H5Tcopy(H5T_NATIVE_INT); + H5Tset_order(datatype, H5T_ORDER_LE); + + /* create a new dataset within the file */ + dataset = H5Dcreate(file, DATASETNAME, datatype, dataspace, H5P_DEFAULT); + + /* initialize data for dataset and write value to dataset */ + data = NUM_THREADS; + H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, + H5P_DEFAULT, &data); + + /* + * Simultaneously create a large number of attributes to be associated + * with the dataset + */ + for (i = 0; i < NUM_THREADS; i++) { + attrib_data = malloc(sizeof(ttsafe_name_data_t)); + attrib_data->dataset = dataset; + attrib_data->datatype = datatype; + attrib_data->dataspace = dataspace; + attrib_data->current_index = i; + pthread_create(&threads[i], NULL, tts_acreate_thread, attrib_data); + } + + for (i = 0; i < NUM_THREADS; i++) + pthread_join(threads[i], NULL); + + /* verify the correctness of the test */ + for (i = 0; i < NUM_THREADS; i++) { + attribute = H5Aopen_name(dataset,gen_name(i)); + + if (attribute < 0) + TestErrPrintf("unable to open appropriate attribute. Test failed!\n"); + else { + ret = H5Aread(attribute, H5T_NATIVE_INT, &buffer); + + if (ret < 0 || buffer != i) + TestErrPrintf("wrong data values. Test failed!\n"); + + H5Aclose(attribute); + } + } + + /* close remaining resources */ + H5Sclose(dataspace); + H5Tclose(datatype); + H5Dclose(dataset); + H5Fclose(file); } void *tts_acreate_thread(void *client_data) { - hid_t attribute; - char *attribute_name; - int *attribute_data; /* data for attributes */ - - ttsafe_name_data_t *attrib_data; - - attrib_data = (ttsafe_name_data_t *)client_data; - - /* Create attribute */ - attribute_name = gen_name(attrib_data->current_index); - attribute = H5Acreate(attrib_data->dataset, attribute_name, - attrib_data->datatype, attrib_data->dataspace, - H5P_DEFAULT); - - /* Write data to the attribute */ - attribute_data = malloc(sizeof(int)); - *attribute_data = attrib_data->current_index; - H5Awrite(attribute, H5T_NATIVE_INT, attribute_data); - H5Aclose(attribute); - return NULL; + hid_t attribute; + char *attribute_name; + int *attribute_data; /* data for attributes */ + + ttsafe_name_data_t *attrib_data; + + attrib_data = (ttsafe_name_data_t *)client_data; + + /* Create attribute */ + attribute_name = gen_name(attrib_data->current_index); + attribute = H5Acreate(attrib_data->dataset, attribute_name, + attrib_data->datatype, attrib_data->dataspace, + H5P_DEFAULT); + + /* Write data to the attribute */ + attribute_data = malloc(sizeof(int)); + *attribute_data = attrib_data->current_index; + H5Awrite(attribute, H5T_NATIVE_INT, attribute_data); + H5Aclose(attribute); + return NULL; } void cleanup_acreate(void) { - HDunlink(FILENAME); + HDunlink(FILENAME); } #endif /*H5_HAVE_THREADSAFE*/ |