[MOAB-dev] r1694 - MOAB/trunk
kraftche at mcs.anl.gov
kraftche at mcs.anl.gov
Tue Mar 25 13:11:27 CDT 2008
Author: kraftche
Date: 2008-03-25 13:11:27 -0500 (Tue, 25 Mar 2008)
New Revision: 1694
Modified:
MOAB/trunk/WriteHDF5.cpp
Log:
Chunk writes of set description data. Reduces time to write file
with many empty sets (e.g. kD-tree) by almost 50%.
Modified: MOAB/trunk/WriteHDF5.cpp
===================================================================
--- MOAB/trunk/WriteHDF5.cpp 2008-03-25 17:47:24 UTC (rev 1693)
+++ MOAB/trunk/WriteHDF5.cpp 2008-03-25 18:11:27 UTC (rev 1694)
@@ -814,12 +814,14 @@
CHK_MHDF_ERR_1(status, set_table);
}
+ long* buffer = reinterpret_cast<long*>(dataBuffer);
+ int chunk_size = bufferSize / (4*sizeof(long));
+ long remaining = sets.size();
MBRange set_contents;
MBRange::const_iterator iter = sets.begin();
+ const MBRange::const_iterator end = sets.end();
MBRange::const_iterator comp = rangeSets.begin();
- const MBRange::const_iterator end = sets.end();
- long set_data[4];
long set_offset = setSet.offset;
long content_offset = setContentsOffset;
long child_offset = setChildrenOffset;
@@ -827,59 +829,65 @@
unsigned long flags;
std::vector<id_t> id_list;
std::vector<MBEntityHandle> handle_list;
- for ( ; iter != end; ++iter )
- {
- rval = get_set_info( *iter, data_size, child_size, parent_size, flags );
- CHK_MB_ERR_2C(rval, set_table, writeSetContents, content_table, status);
+ while (remaining) {
+ long* set_data = buffer;
+ long count = remaining < chunk_size ? remaining : chunk_size;
+ remaining -= count;
+ for (long i = 0; i < count; ++i, ++iter, set_data += 4) {
- id_list.clear();
- if (*iter == *comp)
- {
- set_contents.clear();
-
- rval = iFace->get_entities_by_handle( *iter, set_contents, false );
+ rval = get_set_info( *iter, data_size, child_size, parent_size, flags );
CHK_MB_ERR_2C(rval, set_table, writeSetContents, content_table, status);
- rval = range_to_blocked_list( set_contents, id_list );
- CHK_MB_ERR_2C(rval, set_table, writeSetContents, content_table, status);
+ id_list.clear();
+ if (*iter == *comp)
+ {
+ set_contents.clear();
- assert (id_list.size() < (unsigned long)data_size);
- flags |= mhdf_SET_RANGE_BIT;
- data_size = id_list.size();
- ++comp;
+ rval = iFace->get_entities_by_handle( *iter, set_contents, false );
+ CHK_MB_ERR_2C(rval, set_table, writeSetContents, content_table, status);
+
+ rval = range_to_blocked_list( set_contents, id_list );
+ CHK_MB_ERR_2C(rval, set_table, writeSetContents, content_table, status);
+
+ assert (id_list.size() < (unsigned long)data_size);
+ flags |= mhdf_SET_RANGE_BIT;
+ data_size = id_list.size();
+ ++comp;
+ }
+ else
+ {
+ handle_list.clear();
+
+ rval = iFace->get_entities_by_handle( *iter, handle_list, false );
+ CHK_MB_ERR_2C(rval, set_table, writeSetContents, content_table, status);
+
+ rval = vector_to_id_list( handle_list, id_list );
+ CHK_MB_ERR_2C(rval, set_table, writeSetContents, content_table, status);
+ }
+
+ child_offset += child_size;
+ parent_offset += parent_size;
+ set_data[0] = content_offset + data_size - 1;
+ set_data[1] = child_offset - 1;
+ set_data[2] = parent_offset - 1;
+ set_data[3] = flags;
+
+ if (id_list.size())
+ {
+ mhdf_writeSetData( content_table,
+ content_offset,
+ id_list.size(),
+ id_type,
+ &id_list[0],
+ &status );
+ CHK_MHDF_ERR_2C(status, set_table, writeSetContents, content_table );
+ content_offset += data_size;
+ }
}
- else
- {
- handle_list.clear();
-
- rval = iFace->get_entities_by_handle( *iter, handle_list, false );
- CHK_MB_ERR_2C(rval, set_table, writeSetContents, content_table, status);
-
- rval = vector_to_id_list( handle_list, id_list );
- CHK_MB_ERR_2C(rval, set_table, writeSetContents, content_table, status);
- }
-
- child_offset += child_size;
- parent_offset += parent_size;
- set_data[0] = content_offset + data_size - 1;
- set_data[1] = child_offset - 1;
- set_data[2] = parent_offset - 1;
- set_data[3] = flags;
- mhdf_writeSetMeta( set_table, set_offset++, 1L, H5T_NATIVE_LONG, set_data, &status );
+ mhdf_writeSetMeta( set_table, set_offset, count, H5T_NATIVE_LONG, buffer, &status );
CHK_MHDF_ERR_2C(status, set_table, writeSetContents, content_table );
-
- if (id_list.size())
- {
- mhdf_writeSetData( content_table,
- content_offset,
- id_list.size(),
- id_type,
- &id_list[0],
- &status );
- CHK_MHDF_ERR_2C(status, set_table, writeSetContents, content_table );
- content_offset += data_size;
- }
+ set_offset += count;
}
rval = write_shared_set_descriptions( set_table );
More information about the moab-dev
mailing list