Commit 3b3b2f9b authored by Richard Angersbach's avatar Richard Angersbach
Browse files

Use new MPI_IV_Comm in visualization and I/O classes.

parent a25ab0ff
......@@ -121,7 +121,6 @@ abstract class IR_FileAccess(interfaceName : String) extends IR_Statement with I
}).distinct.to[ListBuffer]
/* commonly used variable accesses */
val mpiCommunicator = IR_VariableAccess("mpiCommunicator", IR_UnknownDatatype)
def stride(bufIdx : Int) = IR_VariableAccess(stride_decl(bufIdx))
def count(bufIdx : Int) = IR_VariableAccess(count_decl(bufIdx))
def localDims(bufIdx : Int) = IR_VariableAccess(localDims_decl(bufIdx))
......
......@@ -11,6 +11,7 @@ import exastencils.config.Knowledge
import exastencils.domain.ir.IR_IV_IsValidForDomain
import exastencils.logger.Logger
import exastencils.optimization.ir.IR_SimplifyExpression
import exastencils.parallelization.api.mpi.MPI_IV_MpiComm
import exastencils.util.ir.IR_Print
case class IR_FileAccess_HDF5(
......@@ -158,7 +159,7 @@ case class IR_FileAccess_HDF5(
ListBuffer[IR_Statement](
IR_Print(IR_VariableAccess("std::cerr", IR_UnknownDatatype), IR_StringConstant("zlib not available for en- and decoding"), IR_Print.endl),
if (Knowledge.mpi_enabled)
IR_FunctionCall(IR_ExternalFunctionReference("MPI_Abort"), mpiCommunicator, IR_IntegerConstant(1))
IR_FunctionCall(IR_ExternalFunctionReference("MPI_Abort"), MPI_IV_MpiComm, IR_IntegerConstant(1))
else
IR_FunctionCall(IR_ExternalFunctionReference("exit"), IR_IntegerConstant(1))
))
......@@ -168,7 +169,7 @@ case class IR_FileAccess_HDF5(
statements ++= H5Pcreate(fapl, IR_VariableAccess("H5P_FILE_ACCESS", IR_UnknownDatatype))
if (Knowledge.mpi_enabled) {
statements ++= info.setHints()
statements ++= H5Pset_fapl_mpio(err, fapl, mpiCommunicator, info)
statements ++= H5Pset_fapl_mpio(err, fapl, MPI_IV_MpiComm, info)
}
// set alignment if knowledge flag does not have default value (this option is mainly meant for MPI parallel applications)
......
......@@ -8,6 +8,7 @@ import exastencils.baseExt.ir.IR_LoopOverFragments
import exastencils.config.Knowledge
import exastencils.domain.ir.IR_IV_IsValidForDomain
import exastencils.logger.Logger
import exastencils.parallelization.api.mpi.MPI_IV_MpiComm
import exastencils.util.ir.IR_Print
/// IR_FileAccess_MPIIO
......@@ -58,7 +59,7 @@ case class IR_FileAccess_MPIIO(
IR_IfCondition(ierrName EqEq "MPI_ERR_UNSUPPORTED_DATAREP",
ListBuffer[IR_Statement](
IR_Print(IR_VariableAccess("std::cerr", IR_UnknownDatatype), IR_StringConstant("Unsupported data representation when using MPI-I/O"), IR_Print.endl),
IR_FunctionCall(IR_ExternalFunctionReference("MPI_Abort"), mpiCommunicator, IR_IntegerConstant(1))
IR_FunctionCall(IR_ExternalFunctionReference("MPI_Abort"), MPI_IV_MpiComm, IR_IntegerConstant(1))
)
)
)
......@@ -121,7 +122,7 @@ case class IR_FileAccess_MPIIO(
// open file
statements += IR_FunctionCall(IR_ExternalFunctionReference("MPI_File_open"),
mpiCommunicator, IR_Cast(IR_PointerDatatype(IR_CharDatatype), filenameAsCString), fileMode, info, IR_AddressOf(fileHandle))
MPI_IV_MpiComm, IR_Cast(IR_PointerDatatype(IR_CharDatatype), filenameAsCString), fileMode, info, IR_AddressOf(fileHandle))
statements
}
......
......@@ -10,6 +10,7 @@ import exastencils.baseExt.ir.IR_LoopOverFragments
import exastencils.config.Knowledge
import exastencils.domain.ir.IR_IV_IsValidForDomain
import exastencils.logger.Logger
import exastencils.parallelization.api.mpi.MPI_IV_MpiComm
import exastencils.parallelization.api.mpi.MPI_IsRootProc
@deprecated
......@@ -168,14 +169,14 @@ case class IR_FileAccess_PnetCDF(
if (writeAccess && !appendedMode) {
if (Knowledge.mpi_enabled) {
statements ++= info.setHints()
statements ++= ncmpi_create(mpiCommunicator, filenameAsCString, fileMode, info, ncFile)
statements ++= ncmpi_create(MPI_IV_MpiComm, filenameAsCString, fileMode, info, ncFile)
} else {
statements ++= nc_create(filenameAsCString, fileMode, ncFile)
}
} else {
if (Knowledge.mpi_enabled) {
statements ++= info.setHints()
statements ++= ncmpi_open(mpiCommunicator, filenameAsCString, fileMode, info, ncFile)
statements ++= ncmpi_open(MPI_IV_MpiComm, filenameAsCString, fileMode, info, ncFile)
} else {
statements ++= nc_open(filenameAsCString, fileMode, ncFile)
}
......
......@@ -11,6 +11,7 @@ import exastencils.config.Settings
import exastencils.domain.ir.IR_IV_IsValidForDomain
import exastencils.logger.Logger
import exastencils.optimization.ir.IR_SimplifyExpression
import exastencils.parallelization.api.mpi.MPI_IV_MpiComm
import exastencils.parallelization.api.mpi.MPI_IV_MpiRank
import exastencils.util.ir.IR_Print
......@@ -52,7 +53,7 @@ case class IR_FileAccess_SIONlib(
val fileId_decl = IR_VariableDeclaration(IR_IntegerDatatype, IR_FileAccess.declareVariable("fileId"))
val numTasks_decl = IR_VariableDeclaration(IR_IntegerDatatype, IR_FileAccess.declareVariable("numTasks"), nTasks)
val numPhysFiles_decl = IR_VariableDeclaration(IR_IntegerDatatype, IR_FileAccess.declareVariable("nFiles"), nPhysFiles)
val localCommunicator_decl = IR_VariableDeclaration(MPI_Comm, IR_FileAccess.declareVariable("lComm"), mpiCommunicator)
val localCommunicator_decl = IR_VariableDeclaration(MPI_Comm, IR_FileAccess.declareVariable("lComm"), MPI_IV_MpiComm)
val fsBlockSize_decl = IR_VariableDeclaration(sion_int32, IR_FileAccess.declareVariable("fsBlockSize"), IR_IntegerConstant(-1)) // -1: automatically determine file system block size
val bytesAccessed_decl = IR_VariableDeclaration(IR_SpecialDatatype("size_t"), IR_FileAccess.declareVariable("bytes" + (if (writeAccess) "Written" else "Read")), 0)
val chunkSizes_decl : IR_VariableDeclaration = if (Knowledge.mpi_enabled) {
......@@ -111,7 +112,7 @@ case class IR_FileAccess_SIONlib(
statements += IR_Assignment(fileId,
IR_FunctionCall(
IR_ExternalFunctionReference("sion_paropen_mpi"),
filenameAsCString, fileMode, IR_AddressOf(numPhysFiles), mpiCommunicator, IR_AddressOf(localCommunicator),
filenameAsCString, fileMode, IR_AddressOf(numPhysFiles), MPI_IV_MpiComm, IR_AddressOf(localCommunicator),
IR_AddressOf(chunkSizes), IR_AddressOf(fsBlockSize), IR_AddressOf(globalRanks), IR_AddressOf(filePtr), IR_AddressOf(newPhysFilenames)
)
)
......
......@@ -92,7 +92,7 @@ trait IR_Hdf5_API {
def H5Pset_mdc_config(err : IR_VariableAccess, fileId : IR_VariableAccess, configPtr : IR_AddressOf) : ListBuffer[IR_Statement] =
callH5Function(err, "H5Pset_mdc_config", fileId, configPtr)
def H5Pset_fapl_mpio(err : IR_VariableAccess, propertyList : IR_VariableAccess, comm : IR_VariableAccess, info : IR_Expression) : ListBuffer[IR_Statement] =
def H5Pset_fapl_mpio(err : IR_VariableAccess, propertyList : IR_VariableAccess, comm : IR_Expression, info : IR_Expression) : ListBuffer[IR_Statement] =
callH5Function(err, "H5Pset_fapl_mpio", propertyList, comm, info)
def H5Pset_dxpl_mpio(err : IR_VariableAccess, transferList : IR_VariableAccess, ioMode : IR_VariableAccess) : ListBuffer[IR_Statement] =
......
......@@ -10,6 +10,7 @@ import exastencils.core.StateManager
import exastencils.domain.ir.IR_DomainFunctions
import exastencils.domain.ir.IR_IV_IsValidForDomain
import exastencils.parallelization.api.mpi.MPI_AllReduce
import exastencils.parallelization.api.mpi.MPI_IV_MpiComm
import exastencils.parallelization.api.mpi.MPI_IV_MpiRank
object IR_IV_FragmentInfo {
......@@ -30,7 +31,6 @@ object IR_IV_FragmentInfo {
if (firstCall) {
// communicate once at startup
val mpiInt = IR_VariableAccess(IR_IntegerDatatype.prettyprint_mpi, IR_UnknownDatatype)
val mpiComm = IR_VariableAccess("mpiCommunicator", IR_UnknownDatatype)
StateManager.findFirst[IR_DomainFunctions]().get.functions foreach {
case func : IR_PlainFunction if func.name == "initGeometry" =>
firstCall = false
......@@ -48,7 +48,7 @@ object IR_IV_FragmentInfo {
func.body += IR_FunctionCall(
IR_ExternalFunctionReference("MPI_Allgather"),
IR_AddressOf(IR_IV_NumValidFrags(domainIdx)), 1, mpiInt,
IR_IV_NumValidFragsPerBlock(domainIdx), 1, mpiInt, mpiComm
IR_IV_NumValidFragsPerBlock(domainIdx), 1, mpiInt, MPI_IV_MpiComm
)
}
case _ =>
......
......@@ -119,10 +119,10 @@ trait IR_PnetCDF_API {
callNcFunction("nc_open", datatype = None, filename, mode, IR_AddressOf(fileId))
/* parallel functions */
def ncmpi_create(comm : IR_VariableAccess, filename : IR_Expression, mode : IR_VariableAccess, info : IR_Expression, fileId : IR_VariableAccess) : ListBuffer[IR_Statement] =
def ncmpi_create(comm : IR_Expression, filename : IR_Expression, mode : IR_VariableAccess, info : IR_Expression, fileId : IR_VariableAccess) : ListBuffer[IR_Statement] =
callNcFunction("ncmpi_create", datatype = None, comm, filename, mode, info, IR_AddressOf(fileId))
def ncmpi_open(comm : IR_VariableAccess, filename : IR_Expression, mode : IR_VariableAccess, info : IR_Expression, fileId : IR_VariableAccess) : ListBuffer[IR_Statement] =
def ncmpi_open(comm : IR_Expression, filename : IR_Expression, mode : IR_VariableAccess, info : IR_Expression, fileId : IR_VariableAccess) : ListBuffer[IR_Statement] =
callNcFunction("ncmpi_open", datatype = None, comm, filename, mode, info, IR_AddressOf(fileId))
def ncmpi_def_dim(fileId : IR_VariableAccess, name : IR_Expression, dimLength : IR_Expression, dimIdPtr : IR_Expression) : ListBuffer[IR_Statement] =
......
......@@ -54,7 +54,7 @@ object MPI_View {
}
}
/// IR_MPI_View
/// MPI_View
// describes the data layout in memory and/or in file via MPI derived datatypes
case class MPI_View(
......
......@@ -6,6 +6,7 @@ import exastencils.base.ir.IR_ImplicitConversion._
import exastencils.base.ir._
import exastencils.visualization.ir.interactive.visit.IR_VisItUtil._
import exastencils.config._
import exastencils.parallelization.api.mpi.MPI_IV_MpiComm
case class IR_VisItBroadcastIntCallback() extends IR_VisItFuturePlainFunction {
val intValue = IR_FunctionArgument("value", IR_PointerDatatype(IR_IntegerDatatype))
......@@ -15,7 +16,7 @@ case class IR_VisItBroadcastIntCallback() extends IR_VisItFuturePlainFunction {
val fctBody = ListBuffer[IR_Statement]()
fctBody += IR_Return(callExtFunction("MPI_Bcast",
intValue.access, IR_IntegerConstant(1), IR_Native("MPI_INT"), sender.access, Knowledge.mpi_defaultCommunicator))
intValue.access, IR_IntegerConstant(1), IR_Native("MPI_INT"), sender.access, MPI_IV_MpiComm))
IR_PlainFunction(
name,
......@@ -38,7 +39,7 @@ case class IR_VisItBroadcastStringCallback() extends IR_VisItFuturePlainFunction
val fctBody = ListBuffer[IR_Statement]()
fctBody += IR_Return(callExtFunction("MPI_Bcast",
str.access, len.access, IR_Native("MPI_CHAR"), sender.access, Knowledge.mpi_defaultCommunicator))
str.access, len.access, IR_Native("MPI_CHAR"), sender.access, MPI_IV_MpiComm))
IR_PlainFunction(
name,
......@@ -58,7 +59,7 @@ case class IR_VisItSlaveProcessCallback() extends IR_VisItFuturePlainFunction {
fctBody += cmdDecl
fctBody += callExtFunction("MPI_Bcast",
IR_AddressOf(IR_VariableAccess(cmdDecl)), IR_IntegerConstant(1), IR_Native("MPI_INT"), IR_IntegerConstant(0), Knowledge.mpi_defaultCommunicator)
IR_AddressOf(IR_VariableAccess(cmdDecl)), IR_IntegerConstant(1), IR_Native("MPI_INT"), IR_IntegerConstant(0), MPI_IV_MpiComm)
IR_PlainFunction(
name,
......
......@@ -61,7 +61,7 @@ case class IR_VisItMainloop() extends IR_VisItFuturePlainFunction {
MPI_IsRootProc.apply(),
IR_Assignment(visitInput, callExtFunction("VisItDetectInput", blocking, IR_FunctionCall(funcRef, IR_Native("stdin"))))
)
whileBody += callExtFunction("MPI_Bcast", IR_AddressOf(visitInput), IR_IntegerConstant(1), IR_Native("MPI_INT"), IR_IntegerConstant(0), Knowledge.mpi_defaultCommunicator)
whileBody += callExtFunction("MPI_Bcast", IR_AddressOf(visitInput), IR_IntegerConstant(1), IR_Native("MPI_INT"), IR_IntegerConstant(0), MPI_IV_MpiComm)
} else {
whileBody += IR_VariableDeclaration(visitInput, callExtFunction("VisItDetectInput", blocking, IR_FunctionCall(funcRef, IR_Native("stdin"))))
}
......@@ -78,7 +78,7 @@ case class IR_VisItMainloop() extends IR_VisItFuturePlainFunction {
IR_Break()
)
)
consoleInputBody += callExtFunction("MPI_Bcast", command, IR_IntegerConstant(1000), IR_Native("MPI_CHAR"), IR_IntegerConstant(0), Knowledge.mpi_defaultCommunicator)
consoleInputBody += callExtFunction("MPI_Bcast", command, IR_IntegerConstant(1000), IR_Native("MPI_CHAR"), IR_IntegerConstant(0), MPI_IV_MpiComm)
} else {
consoleInputBody += IR_IfCondition(
callExtFunction("VisItReadConsole", IR_IntegerConstant(1000), command) Neq visitOkay,
......
......@@ -26,11 +26,11 @@ case class IR_VisItProcessVisItCommand() extends IR_VisItFuturePlainFunction {
IR_EqEq(1, callExtFunction("VisItProcessEngineCommand")),
ListBuffer[IR_Statement](
IR_Assignment(command, 1),
callExtFunction("MPI_Bcast", IR_AddressOf(command), 1, IR_Native("MPI_INT"), 0, Knowledge.mpi_defaultCommunicator),
callExtFunction("MPI_Bcast", IR_AddressOf(command), 1, IR_Native("MPI_INT"), 0, MPI_IV_MpiComm),
IR_Return(1)),
ListBuffer[IR_Statement](
IR_Assignment(command, 0),
callExtFunction("MPI_Bcast", IR_AddressOf(command), 1, IR_Native("MPI_INT"), 0, Knowledge.mpi_defaultCommunicator),
callExtFunction("MPI_Bcast", IR_AddressOf(command), 1, IR_Native("MPI_INT"), 0, MPI_IV_MpiComm),
IR_Return(0))
)
),
......@@ -38,7 +38,7 @@ case class IR_VisItProcessVisItCommand() extends IR_VisItFuturePlainFunction {
IR_WhileLoop(
1,
ListBuffer[IR_Statement](
callExtFunction("MPI_Bcast", IR_AddressOf(command), 1, IR_Native("MPI_INT"), 0, Knowledge.mpi_defaultCommunicator),
callExtFunction("MPI_Bcast", IR_AddressOf(command), 1, IR_Native("MPI_INT"), 0, MPI_IV_MpiComm),
IR_IfCondition(
IR_EqEq(command, 0),
callExtFunction("VisItProcessEngineCommand")),
......
......@@ -13,6 +13,7 @@ import exastencils.domain.ir.IR_IV_IsValidForDomain
import exastencils.grid.ir._
import exastencils.io.ir._
import exastencils.logger.Logger
import exastencils.parallelization.api.mpi.MPI_IV_MpiComm
import exastencils.parallelization.api.mpi.MPI_IV_MpiRank
import exastencils.util.ir.IR_Print
import exastencils.visualization.ir.postprocessing.IR_PrintVisualization
......@@ -105,7 +106,6 @@ abstract class IR_PrintExodus() extends IR_Statement with IR_Expandable with IR_
val wordSizeCPU = IR_VariableAccess(wordSizeCPU_decl)
val wordSizeIO = IR_VariableAccess(wordSizeIO_decl)
val truthTable = IR_VariableAccess(truthTable_decl)
val mpiCommunicator = IR_VariableAccess("mpiCommunicator", IR_UnknownDatatype)
val openMode = IR_VariableAccess("EX_CLOBBER | EX_LARGE_MODEL", IR_UnknownDatatype)
// helper functions
......@@ -138,7 +138,7 @@ abstract class IR_PrintExodus() extends IR_Statement with IR_Expandable with IR_
IR_Assignment(exoId, IR_FunctionCall(IR_ExternalFunctionReference("ex_open"), IR_FileAccess.filenameAsCString(filename), "EX_WRITE", IR_AddressOf(wordSizeCPU), IR_AddressOf(wordSizeIO), IR_AddressOf("version")))
)
def ex_create_par() : ListBuffer[IR_Statement] = ListBuffer(
IR_Assignment(exoId, IR_FunctionCall(IR_ExternalFunctionReference("ex_create_par"), IR_FileAccess.filenameAsCString(filename), openMode, IR_AddressOf(wordSizeCPU), IR_AddressOf(wordSizeIO), mpiCommunicator, info)))
IR_Assignment(exoId, IR_FunctionCall(IR_ExternalFunctionReference("ex_create_par"), IR_FileAccess.filenameAsCString(filename), openMode, IR_AddressOf(wordSizeCPU), IR_AddressOf(wordSizeIO), MPI_IV_MpiComm, info)))
def ex_put_init() : ListBuffer[IR_Statement] =
callExodusFunction("ex_put_init", exoId, IR_CStringConstant("title"), numDimsGrid, numNodes, numElem, numElemBlocks, numNodeSets, numSideSets)
def ex_put_block() : ListBuffer[IR_Statement] =
......
Markdown is supported
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