Commit ab73cdb7 authored by Jerry Clarke's avatar Jerry Clarke
Browse files

Making all classes not change size w/wo MPI

parent 8f7b72b6
......@@ -56,17 +56,18 @@ SET( XdmfModelSource
XdmfTopology
XdmfTime
XdmfGeometry
)
IF(XDMF_BUILD_MPI)
SET(XdmfModelSource ${XdmfModelSource} XdmfH5Driver)
ENDIF(XDMF_BUILD_MPI)
SET( XdmfMpiSource
XdmfH5Driver
XdmfDsm
XdmfDsmBuffer
XdmfDsmComm
XdmfDsmMsg
)
# IF(XDMF_BUILD_MPI)
# SET(XdmfModelSource ${XdmfModelSource} XdmfH5Driver)
# ENDIF(XDMF_BUILD_MPI)
SET( XdmfMpiSource
XdmfDsmCommMpi
)
......
......@@ -50,6 +50,13 @@ swig -v -c++ -make_default -includeall -shadow -java $(ICE_INCLUDES) -o XdmfJava
#include <XdmfXNode.h>
#include <XdmfNDGM.h>
*/
#include <XdmfDsm.h>
#include <XdmfDsmMsg.h>
#include <XdmfDsmBuffer.h>
#include <XdmfDsmComm.h>
#ifndef XDMF_NO_MPI
#include <XdmfDsmCommMpi.h>
#endif
#ifndef HAVE_STRTOLL
# define strtoll XDMF_strtoll
......@@ -122,6 +129,13 @@ inline XDMF_LONG64 XDMF_strtoll(char *str, void*, int)
%include XdmfXNode.h
%include XdmfNDGM.h
*/
%include XdmfDsm.h
%include XdmfDsmMsg.h
%include XdmfDsmBuffer.h
%include XdmfDsmComm.h
#ifndef XDMF_NO_MPI
%include XdmfDsmCommMpi.h
#endif
#ifdef SWIGPYTHON
%{
......
......@@ -69,6 +69,24 @@ XdmfAttribute::Build(){
if(XdmfElement::Build() != XDMF_SUCCESS) return(XDMF_FAIL);
this->Set("AttributeType", this->GetAttributeTypeAsString());
this->Set("Center", this->GetAttributeCenterAsString());
if(this->DataXml){
if(this->DOM){
if(this->InsertedDataXml == this->DataXml){
// Already done
return(XDMF_SUCCESS);
}
if(this->DOM->InsertFromString(this->GetElement(), this->DataXml)){
this->SetInsertedDataXml(this->DataXml);
return(XDMF_SUCCESS);
}else{
XdmfErrorMessage("Error Inserting Raw XML : " << endl << this->DataXml);
return(XDMF_FAIL);
}
}else{
XdmfErrorMessage("Can't insert raw XML sine DOM is not set");
return(XDMF_FAIL);
}
}
if(this->Values){
XdmfDataItem *di = NULL;
XdmfXmlNode node;
......@@ -267,9 +285,7 @@ if( this->AttributeType == XDMF_ATTRIBUTE_TYPE_NONE ){
ValuesNode = this->DOM->FindDataElement( 0, Element );
if( ValuesNode ){
ValueReader.SetDOM( this->DOM );
#ifndef XDMF_NO_MPI
ValueReader.SetDsmBuffer(this->DsmBuffer);
#endif
if( this->ValuesAreMine && this->Values ){
delete this->Values;
this->Values = NULL;
......
......@@ -159,4 +159,9 @@
#cmakedefine XDMF_HAVE_MALLOC_H
#cmakedefine XDMF_BUILD_MPI
#ifndef XDMF_BUILD_MPI
#define XDMF_NO_MPI
#endif
#endif /* __XdmfConfig_h */
......@@ -34,9 +34,7 @@ XdmfDataDesc::XdmfDataDesc() {
this->NextOffset = 0;
this->Rank = 1;
this->ShapeString = 0;
#ifndef XDMF_NO_MPI
this->DsmBuffer = NULL;
#endif
}
XdmfDataDesc::~XdmfDataDesc() {
......
......@@ -32,9 +32,7 @@
#define XDMF_HYPERSLAB 1
#define XDMF_COORDINATES 2
#ifndef XDMF_NO_MPI
class XdmfDsmBuffer;
#endif
//! Number Type and Shape
......@@ -198,12 +196,10 @@ public :
XdmfSetStringMacro(HeavyDataSetName);
//! Get the name of the Heavy Data Set when written (if applicable)
XdmfGetStringMacro(HeavyDataSetName);
#ifndef XDMF_NO_MPI
//! Get DSM Buffer
XdmfGetValueMacro(DsmBuffer, XdmfDsmBuffer *);
//! Set DSM Buffer
XdmfSetValueMacro(DsmBuffer, XdmfDsmBuffer *);
#endif
......@@ -236,9 +232,7 @@ protected:
void SetShapeString(XdmfConstString shape);
XdmfString ShapeString;
XdmfString HeavyDataSetName;
#ifndef XDMF_NO_MPI
XdmfDsmBuffer *DsmBuffer;
#endif
};
#endif // __XdmfDataDesc_h
......@@ -119,9 +119,7 @@ XdmfDataItem::Copy(XdmfElement *Source){
// this->SetDOM(ds->GetDOM());
this->SetFormat(ds->GetFormat());
this->SetHeavyDataSetName(ds->GetHeavyDataSetName());
#ifndef XDMF_NO_MPI
this->SetDsmBuffer(ds->GetDsmBuffer());
#endif
this->DataDesc->CopyType(ds->GetDataDesc());
this->DataDesc->CopyShape(ds->GetDataDesc());
this->DataDesc->CopySelection(ds->GetDataDesc());
......@@ -490,9 +488,7 @@ XdmfInt32 XdmfDataItem::Update(){
this->Values->SetDebug(this->GetDebug());
// this->SetDsmBuffer(this->Values->GetDsmBuffer());
// cout << "Setting Values Dsm to " << this->DsmBuffer << endl;
#ifndef XDMF_NO_MPI
this->Values->SetDsmBuffer(this->DsmBuffer);
#endif
XdmfDebug("Reading Data");
if(!((XdmfValuesHDF *)this->Values)->Read(this->Array)){
XdmfErrorMessage("Reading Values Failed");
......@@ -598,6 +594,35 @@ XdmfInt32 XdmfDataItem::Build(){
default :
break;
}
if(this->DataXml){
if(this->DOM){
if(this->InsertedDataXml == this->DataXml){
// Already done
return(XDMF_SUCCESS);
}
switch (this->Format) {
case XDMF_FORMAT_HDF :
this->Set("Format", "HDF");
break;
case XDMF_FORMAT_XML :
this->Set("Format", "XML");
break;
default :
XdmfErrorMessage("Unsupported Data Format");
return(XDMF_FAIL);
}
if(this->DOM->InsertFromString(this->GetElement(), this->DataXml)){
this->SetInsertedDataXml(this->DataXml);
return(XDMF_SUCCESS);
}else{
XdmfErrorMessage("Error Inserting Raw XML : " << endl << this->DataXml);
return(XDMF_FAIL);
}
}else{
XdmfErrorMessage("Can't insert raw XML sine DOM is not set");
return(XDMF_FAIL);
}
}
if(this->CheckValues(this->Format) != XDMF_SUCCESS){
XdmfErrorMessage("Error Accessing Internal XdmfValues");
return(XDMF_FAIL);
......@@ -607,9 +632,7 @@ XdmfInt32 XdmfDataItem::Build(){
case XDMF_FORMAT_HDF :
XdmfDebug("Writing Values in HDF Format");
Values->SetHeavyDataSetName(this->GetHeavyDataSetName());
#ifndef XDMF_NO_MPI
Values->SetDsmBuffer(this->GetDsmBuffer());
#endif
if(((XdmfValuesHDF *)Values)->Write(this->Array) != XDMF_SUCCESS){
XdmfErrorMessage("Writing Values Failed");
return(XDMF_FAIL);
......
......@@ -81,6 +81,13 @@ XdmfDsmBuffer::ServiceThread(){
return((void *)this);
}
XdmfInt32
XdmfDsmBuffer::ServiceInit(){
XdmfInt32 status = XDMF_SUCCESS;
return(status);
}
XdmfInt32
XdmfDsmBuffer::ServiceOnce(XdmfInt32 *ReturnOpcode){
XdmfInt32 status = XDMF_FAIL;
......
......@@ -26,7 +26,13 @@
#define __XdmfDsmCommMpi_h
#include "XdmfDsmComm.h"
#ifndef XDMF_NO_MPI
#ifndef SWIG
#include <mpi.h>
#endif // SWIG
#else // XDMF_NO_MPI
typedef int MPI_Comm;
#endif // XDMF_NO_MPI
//! Base comm object for Distributed Shared Memory implementation
/*!
......@@ -42,12 +48,14 @@ public:
XdmfConstString GetClassName() { return ( "XdmfDsmCommMpi" ) ; };
#ifndef SWIG
//! Set the MPI Communicator
XdmfSetValueMacro(Comm, MPI_Comm);
//! Get the MPI Communicator
XdmfGetValueMacro(Comm, MPI_Comm);
XdmfInt32 DupComm(MPI_Comm Source);
#endif
XdmfInt32 Init();
XdmfInt32 Send(XdmfDsmMsg *Msg);
XdmfInt32 Receive(XdmfDsmMsg *Msg);
......
......@@ -63,9 +63,9 @@ XdmfElement::XdmfElement() {
this->State = XDMF_ELEMENT_STATE_UNINITIALIZED;
this->CopyReferenceData = 1;
this->RootWhenParsed = 0;
#ifndef XDMF_NO_MPI
this->DsmBuffer = NULL;
#endif
this->DataXml = 0;
this->InsertedDataXml = 0;
}
XdmfElement::~XdmfElement() {
......@@ -84,6 +84,7 @@ XdmfElement::~XdmfElement() {
}
this->Element = NULL;
if(this->ElementName) delete [] this->ElementName;
if(this->DataXml) delete [] this->DataXml;
}
void XdmfElement::SetReferenceObject(XdmfXmlNode anElement, void *p){
......
......@@ -32,9 +32,7 @@
#define XDMF_ELEMENT_STATE_HEAVY_READ 2
class XdmfDOM;
#ifndef XDMF_NO_MPI
class XdmfDsmBuffer;
#endif
//! Basic XML Based Element
/*!
......@@ -140,6 +138,16 @@ public:
//! Set the ElementName. i.e. ElementName for <Information ... = "Information"
XdmfSetStringMacro(ElementName);
//! Get the DataXml. This is used by Build() when HeavyData has already been written
XdmfGetStringMacro(DataXml);
//! Set the DataXml. This will override the Build() method and inject the raw XML
XdmfSetStringMacro(DataXml);
//! Get the DataXml. This is used by Build() when HeavyData has already been written
XdmfGetStringMacro(InsertedDataXml);
//! Set the DataXml. This will override the Build() method and inject the raw XML
XdmfInt32 SetInsertedDataXml(XdmfString Inserted){this->InsertedDataXml = Inserted; return(XDMF_SUCCESS);};
//! Get the Element type : Grid, Topology, etc.
XdmfConstString GetElementType();
......@@ -166,12 +174,10 @@ public:
//! Follow a Refernce Chain one step, if it exists
XdmfXmlNode FollowReference(XdmfXmlNode Element);
#ifndef XDMF_NO_MPI
//! Get DSM Buffer
XdmfGetValueMacro(DsmBuffer, XdmfDsmBuffer *);
//! Set DSM Buffer
XdmfSetValueMacro(DsmBuffer, XdmfDsmBuffer *);
#endif
protected:
void SetReferenceObject(XdmfXmlNode Element, void *p);
......@@ -183,6 +189,8 @@ protected:
XdmfDOM *DOM;
XdmfInt32 State;
XdmfString ElementName;
XdmfString DataXml;
XdmfString InsertedDataXml;
//! Target XML That Represents this. In the case of a reference, this is the target XML not the Reference="XX" node.
XdmfXmlNode Element;
//! If this is a Reference XML, this is the head of the Reference chain (the Original XML node).
......@@ -190,9 +198,7 @@ protected:
XdmfInt32 IsReference;
// Copy, don't copy data out of reference element. Default is to copy.
XdmfInt32 CopyReferenceData;
#ifndef XDMF_NO_MPI
XdmfDsmBuffer *DsmBuffer;
#endif
XdmfDsmBuffer *DsmBuffer;
XdmfXmlNode RootWhenParsed;
};
#endif // __XdmfElement_h
......@@ -93,8 +93,27 @@ XdmfGeometry::Build(){
XdmfDataItem *di = NULL;
XdmfArray *array;
cout << "Building Geometry" << endl;
if(XdmfElement::Build() != XDMF_SUCCESS) return(XDMF_FAIL);
this->Set("GeometryType", this->GetGeometryTypeAsString());
if(this->DataXml){
if(this->DOM){
if(this->InsertedDataXml == this->DataXml){
// Already done
return(XDMF_SUCCESS);
}
if(this->DOM->InsertFromString(this->GetElement(), this->DataXml)){
this->SetInsertedDataXml(this->DataXml);
return(XDMF_SUCCESS);
}else{
XdmfErrorMessage("Error Inserting Raw XML : " << endl << this->DataXml);
return(XDMF_FAIL);
}
}else{
XdmfErrorMessage("Can't insert raw XML sine DOM is not set");
return(XDMF_FAIL);
}
}
switch( this->GeometryType ){
case XDMF_GEOMETRY_VXVYVZ:
if(!this->VectorX || !this->VectorY || !this->VectorZ){
......@@ -320,9 +339,7 @@ if( ( this->GeometryType == XDMF_GEOMETRY_X_Y_Z ) ||
if(PointsItem.SetDOM( this->DOM ) == XDMF_FAIL) return(XDMF_FAIL);
if(PointsItem.SetElement(PointsElement, 0) == XDMF_FAIL) return(XDMF_FAIL);
if(PointsItem.UpdateInformation() == XDMF_FAIL) return(XDMF_FAIL);
#ifndef XDMF_NO_MPI
PointsItem.SetDsmBuffer(this->DsmBuffer);
#endif
if(PointsItem.Update() == XDMF_FAIL) return(XDMF_FAIL);
TmpArray = PointsItem.GetArray();
if( TmpArray ){
......@@ -391,9 +408,7 @@ if( ( this->GeometryType == XDMF_GEOMETRY_X_Y_Z ) ||
if( this->GeometryType == XDMF_GEOMETRY_ORIGIN_DXDYDZ ) {
XdmfDataItem PointsItem;
PointsItem.SetDOM(this->DOM);
#ifndef XDMF_NO_MPI
PointsItem.SetDsmBuffer(this->DsmBuffer);
#endif
XdmfDebug("Reading Origin and Dx, Dy, Dz" );
PointsElement = this->DOM->FindDataElement(0, this->Element );
if( PointsElement ){
......
......@@ -243,9 +243,7 @@ XdmfGrid::AssignAttribute( XdmfAttribute *attribute ){
XdmfInt32 Status = 0;
if( attribute ){
#ifndef XDMF_NO_MPI
if(!attribute->GetDsmBuffer()) attribute->SetDsmBuffer(this->DsmBuffer);
#endif
attribute->Update();
// Status = attribute->SetBaseAttribute( this, this->BaseGrid );
this->AssignedAttribute = attribute;
......@@ -520,9 +518,7 @@ if((this->GridType & XDMF_GRID_MASK) != XDMF_GRID_UNIFORM){
XdmfInt32 i;
// SubSet, Tree or Collection
for(i=0; i < this->NumberOfChildren ; i++){
#ifndef XDMF_NO_MPI
if(!this->Children[i]->GetDsmBuffer()) this->Children[i]->SetDsmBuffer(this->DsmBuffer);
#endif
if(this->Children[i]->Update() == XDMF_FAIL){
XdmfErrorMessage("Error in Update() of Child Grid " << i);
return(XDMF_FAIL);
......@@ -593,16 +589,12 @@ if((this->GridType & XDMF_GRID_MASK) != XDMF_GRID_UNIFORM){
}
return(XDMF_SUCCESS);
}
#ifndef XDMF_NO_MPI
if(!this->Topology->GetDsmBuffer()) this->Topology->SetDsmBuffer(this->DsmBuffer);
#endif
if(this->Topology->Update() == XDMF_FAIL){
XdmfErrorMessage("Error in Update() of Topology");
return(XDMF_FAIL);
}
#ifndef XDMF_NO_MPI
if(!this->Geometry->GetDsmBuffer()) this->Geometry->SetDsmBuffer(this->DsmBuffer);
#endif
if(this->Geometry->Update() == XDMF_FAIL){
XdmfErrorMessage("Error in Update() of Geometry");
return(XDMF_FAIL);
......
......@@ -22,10 +22,8 @@
/* */
/*******************************************************************/
#include "XdmfHDF.h"
#ifndef XDMF_NO_MPI
#include "XdmfDsmBuffer.h"
#include "XdmfH5Driver.h"
#endif
#ifdef WIN32
#define XDMF_HDF5_SIZE_T ssize_t
......@@ -64,9 +62,7 @@ XdmfHDF::XdmfHDF() {
}
#endif
#ifndef XDMF_NO_MPI
this->DsmBuffer = 0;
#endif
strcpy( this->CwdName, "" );
}
......@@ -673,7 +669,6 @@ XdmfDebug("Using Domain " << this->Domain );
// H5Pset_fapl_core( this->AccessPlist, 1000000, 1 );
H5Pset_fapl_core( this->AccessPlist, 1000000, 0 );
} else if( STRCASECMP( this->Domain, "DSM" ) == 0 ) {
#ifndef XDMF_NO_MPI
XdmfDebug("Using DSM Interface");
if(!this->DsmBuffer){
XdmfErrorMessage("Cannot Open a DSM HDF5 File Until DsmBuffer has been set");
......@@ -683,10 +678,6 @@ XdmfDebug("Using Domain " << this->Domain );
this->AccessPlist = H5Pcreate( H5P_FILE_ACCESS );
XdmfDebug("DsmBuffer = " << this->DsmBuffer);
H5Pset_fapl_dsm( this->AccessPlist, H5FD_DSM_INCREMENT, this->DsmBuffer);
#else
XdmfErrorMessage("DSM Interface is unavailable");
return( XDMF_FAIL );
#endif
} else if( STRCASECMP( this->Domain, "NDGM" ) == 0 ) {
XdmfErrorMessage("NDGM Interface is unavailable");
return( XDMF_FAIL );
......@@ -739,7 +730,6 @@ if( this->File < 0 ){
// H5Pset_fapl_core( this->AccessPlist, 1000000, 1);
H5Pset_fapl_core( this->AccessPlist, 1000000, 0);
} else if( STRCASECMP( this->Domain, "DSM" ) == 0 ) {
#ifndef XDMF_NO_MPI
if(!this->DsmBuffer){
XdmfErrorMessage("Cannot Open a DSM HDF5 File Until DsmBuffer has been set");
return(XDMF_FAIL);
......@@ -747,10 +737,6 @@ if( this->File < 0 ){
H5FD_dsm_init();
this->AccessPlist = H5Pcreate( H5P_FILE_ACCESS );
H5Pset_fapl_dsm( this->AccessPlist, H5FD_DSM_INCREMENT, this->DsmBuffer);
#else
XdmfErrorMessage("DSM interface is unavailable");
return( XDMF_FAIL );
#endif
} else if( STRCASECMP( this->Domain, "NDGM" ) == 0 ) {
XdmfErrorMessage("NDGM interface is unavailable");
return( XDMF_FAIL );
......
......@@ -72,7 +72,7 @@ XdmfTopology::Build(){
if(XdmfElement::Build() != XDMF_SUCCESS) return(XDMF_FAIL);
this->Set("TopologyType", this->GetTopologyTypeAsString());
if(this->GetNumberOfElements()){
this->Set("NumberOfElements", this->Shape->GetShapeAsString());
this->Set("Dimensions", this->Shape->GetShapeAsString());
}
if( this->OrderIsDefault == 0 ){
this->Set("Order", this->GetOrderAsString());
......@@ -83,6 +83,24 @@ XdmfTopology::Build(){
OffsetStream << this->BaseOffset << ends;
this->Set("BaseOffset", Offset);
}
if(this->DataXml){
if(this->DOM){
if(this->InsertedDataXml == this->DataXml){
// Already done
return(XDMF_SUCCESS);
}
if(this->DOM->InsertFromString(this->GetElement(), this->DataXml)){
this->SetInsertedDataXml(this->DataXml);
return(XDMF_SUCCESS);
}else{
XdmfErrorMessage("Error Inserting Raw XML : " << endl << this->DataXml);
return(XDMF_FAIL);
}
}else{
XdmfErrorMessage("Can't insert raw XML sine DOM is not set");
return(XDMF_FAIL);
}
}
if(this->Connectivity){
XdmfDataItem *di = NULL;
XdmfXmlNode node;
......@@ -591,9 +609,7 @@ if( this->GetClass() == XDMF_UNSTRUCTURED ){
// cout << "Connection DataItem = " << &Connections << endl;
XdmfDebug("Reading Connections from DataItem");
if(Connections.SetDOM(this->DOM) == XDMF_FAIL) return(XDMF_FAIL);
#ifndef XDMF_NO_MPI
Connections.SetDsmBuffer(this->DsmBuffer);
#endif
if( this->ConnectivityIsMine && this->Connectivity ) delete this->Connectivity;
if(Connections.SetElement(ConnectionElement, 0) == XDMF_FAIL) return(XDMF_FAIL);
if(Connections.UpdateInformation() == XDMF_FAIL) return(XDMF_FAIL);
......
......@@ -54,9 +54,7 @@ XdmfValuesHDF::Read(XdmfArray *anArray){
}
XDMF_WORD_TRIM(DataSetName);
//! Possible Read from DSM. Make sure we're connected.
#ifndef XDMF_NO_MPI
if(!this->DsmBuffer) this->SetDsmBuffer(anArray->GetDsmBuffer());
#endif
XdmfDebug("Opening HDF5 Data for Reading : " << DataSetName);
// Allocate Array if Necessary
if(!RetArray){
......@@ -70,9 +68,7 @@ XdmfValuesHDF::Read(XdmfArray *anArray){
RetArray->CopySelection(this->DataDesc);
RetArray->Allocate();
}
#ifndef XDMF_NO_MPI
H5.SetDsmBuffer(this->DsmBuffer);
#endif
if( H5.Open( DataSetName, "r" ) == XDMF_FAIL ) {
XdmfErrorMessage("Can't Open Dataset " << DataSetName);
if(!anArray) delete RetArray;
......@@ -136,9 +132,7 @@ XdmfValuesHDF::Write(XdmfArray *anArray, XdmfConstString aHeavyDataSetName){
}
}
// Possible Write to DSM. Make sure we're connected
#ifndef XDMF_NO_MPI
if(!this->DsmBuffer) this->SetDsmBuffer(anArray->GetDsmBuffer());
#endif
XdmfDebug("Writing Values to " << aHeavyDataSetName);
if(!this->DataDesc ){
XdmfErrorMessage("DataDesc has not been set");
......@@ -154,9 +148,7 @@ XdmfValuesHDF::Write(XdmfArray *anArray, XdmfConstString aHeavyDataSetName){
H5.CopyType(this->DataDesc);
H5.CopyShape(this->DataDesc);
H5.CopySelection(this->DataDesc);
#ifndef XDMF_NO_MPI
H5.SetDsmBuffer(this->DsmBuffer);
#endif
if(H5.Open(hds, "rw") == XDMF_FAIL){
XdmfErrorMessage("Error Opening " << hds << " for Writing");
delete [] hds ;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment