Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6aed9fb
just fix some confusing naming
Nov 10, 2020
ebf86c6
adding check for in and outdegree
Nov 10, 2020
12363ea
adding check for in and outdegree
Nov 10, 2020
f930110
remove attempt to fix graphs with no zero indegree or outdegree nodes
Nov 10, 2020
44770e6
update ref
Nov 10, 2020
949d86d
some hot fixes for the psy2dawn project
mroethlin Dec 8, 2021
b81f35f
add test, update old test
mroethlin Dec 10, 2021
4ade903
revert copy stencil benchmark
mroethlin Dec 10, 2021
5aed526
fix codegen bug, add test
mroethlin Dec 13, 2021
ddaa487
Merge remote-tracking branch 'origin/fix_fieldversion2' into hotfixes…
mroethlin Dec 16, 2021
5921cef
add curiously failing gtclang test
mroethlin Dec 20, 2021
1fbf658
fixed bug that for MS involving temp fields only
mroethlin Jan 3, 2022
e01f4f1
update ref (accidental revert?)
mroethlin Jan 3, 2022
c234f1c
rough implementation of a c interface compatible structured cuda code…
mroethlin Mar 18, 2022
79b3287
milestone 0: new dawn ifaces compiling with nemo_gtc
mroethlin Mar 18, 2022
5f27bef
pointer steal wip
mroethlin Apr 22, 2022
1b09266
add results serialization
mroethlin May 20, 2022
74c1b7d
hopefully fixing strides
mroethlin May 20, 2022
1728e52
striding looks right now for cubic domains
mroethlin May 20, 2022
d1b28fd
use human readable version of stencil name
mroethlin May 23, 2022
e2ff27f
strides finally correct
mroethlin Jun 9, 2022
94843f9
correct handling of globals in the c and fortran interfaces
mroethlin Aug 10, 2022
8043e97
only emit globals if globals are present
mroethlin Oct 18, 2022
da9e02f
fix globals
mroethlin Oct 25, 2022
e58b303
variadic min/max funs
mroethlin Nov 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions dawn/src/dawn/CodeGen/CodeGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,19 +298,19 @@ void CodeGen::generateStencilWrapperSyncMethod(Class& stencilWrapperClass) const
syncStoragesMethod.commit();
}

std::string CodeGen::getStorageType(const ast::FieldDimensions& dimensions) {
std::string CodeGen::getStorageType(const ast::FieldDimensions& dimensions, std::string prefix, std::string suffix) {
DAWN_ASSERT_MSG(
ast::dimension_isa<ast::CartesianFieldDimension>(dimensions.getHorizontalFieldDimension()),
"Storage type requested for a non cartesian horizontal dimension");
auto const& cartesianDimensions =
dawn::ast::dimension_cast<dawn::ast::CartesianFieldDimension const&>(
dimensions.getHorizontalFieldDimension());

std::string storageType = "storage_";
std::string storageType = prefix == "" ? "" : prefix + "_";
storageType += cartesianDimensions.I() ? "i" : "";
storageType += cartesianDimensions.J() ? "j" : "";
storageType += dimensions.K() ? "k" : "";
storageType += "_t";
storageType += suffix;
return storageType;
}

Expand Down Expand Up @@ -338,10 +338,10 @@ void CodeGen::addTmpStorageDeclaration(
Structure& stencilClass,
IndexRange<const std::map<int, iir::Stencil::FieldInfo>>& tempFields) const {
if(!(tempFields.empty())) {
stencilClass.addMember(tmpMetadataTypename_, tmpMetadataName_);
stencilClass.addMember("static " + tmpMetadataTypename_, tmpMetadataName_);

for(const auto& field : tempFields) {
stencilClass.addMember(tmpStorageTypename_, "m_" + field.second.Name);
stencilClass.addMember("static " + tmpStorageTypename_, "m_" + field.second.Name);
}
}
}
Expand Down Expand Up @@ -448,16 +448,16 @@ void CodeGen::generateGlobalIndices(const iir::Stencil& stencil, Structure& sten
bool genCheckOffset) const {
for(auto& stage : iterateIIROver<iir::Stage>(stencil)) {
if(stage->getIterationSpace()[0].has_value()) {
stencilClass.addMember("std::array<int, 2>",
stencilClass.addMember("static std::array<int, 2>",
"stage" + std::to_string(stage->getStageID()) + "GlobalIIndices");
}
if(stage->getIterationSpace()[1].has_value()) {
stencilClass.addMember("std::array<int, 2>",
stencilClass.addMember("static std::array<int, 2>",
"stage" + std::to_string(stage->getStageID()) + "GlobalJIndices");
}
}

stencilClass.addMember("std::array<unsigned int, 2>", "globalOffsets");
stencilClass.addMember("static std::array<unsigned int, 2>", "globalOffsets");
auto globalOffsetFunc =
stencilClass.addMemberFunction("static std::array<unsigned int, 2>", "computeGlobalOffsets");
globalOffsetFunc.addArg("int rank, const " + c_dgt + "domain& dom, int xcols, int ycols");
Expand Down
2 changes: 1 addition & 1 deletion dawn/src/dawn/CodeGen/CodeGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class CodeGen {

static std::string getStorageType(const sir::Field& field);
static std::string getStorageType(const iir::Stencil::FieldInfo& field);
static std::string getStorageType(const ast::FieldDimensions& dimensions);
static std::string getStorageType(const ast::FieldDimensions& dimensions, std::string prefix="storage", std::string suffix="_t");

void generateBoundaryConditionFunctions(
Class& stencilWrapperClass,
Expand Down
8 changes: 5 additions & 3 deletions dawn/src/dawn/CodeGen/Cuda-ico/CudaIcoCodeGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1704,7 +1704,8 @@ generateF90InterfaceSI(FortranInterfaceModuleGen& fimGen,
runWrapper.addACCLine("host_data use_device( &");
auto fieldArgs = getFieldArgs(/*includeSavedState*/ true);
for(int i = 0; i < fieldArgs.size(); ++i) {
runWrapper.addACCLine(fortranIndent + fieldArgs[i] + (i == (fieldArgs.size() - 1) ? " &" : ", &"));
runWrapper.addACCLine(fortranIndent + fieldArgs[i] +
(i == (fieldArgs.size() - 1) ? " &" : ", &"));
}
runWrapper.addACCLine(")");
runWrapper.addBodyLine("#ifdef __DSL_VERIFY", /*withIndentation*/ false);
Expand All @@ -1722,7 +1723,7 @@ generateF90InterfaceSI(FortranInterfaceModuleGen& fimGen,
for(auto fieldID : getUsedFields(stencil, {dawn::iir::Field::IntendKind::Output,
dawn::iir::Field::IntendKind::InputOutput})) {
verticalBoundNames.push_back(stencilInstantiation->getMetaData().getNameFromAccessID(fieldID) +
"_kvert_max");
"_kvert_max");
}

// memory management functions for production interface
Expand Down Expand Up @@ -1787,7 +1788,8 @@ generateF90InterfaceSI(FortranInterfaceModuleGen& fimGen,
setupWrapper.addBodyLine(fortranIndent + verticalBoundNames[i] + ", &");
}

setupWrapper.addBodyLine(fortranIndent + verticalBoundNames[verticalBoundNames.size() - 1] + " &");
setupWrapper.addBodyLine(fortranIndent + verticalBoundNames[verticalBoundNames.size() - 1] +
" &");

setupWrapper.addBodyLine(")");

Expand Down
45 changes: 44 additions & 1 deletion dawn/src/dawn/CodeGen/Cuda/CodeGeneratorHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,50 @@ std::vector<std::string> CodeGeneratorHelper::generateStrideArguments(
}
}
}
if(!tempFields.empty()) {
if(!tempFields.empty() && nonTempFields.empty()) {
const auto& firstTmpField = *(tempFields.begin());
std::string fieldName = metadata.getFieldNameFromAccessID(firstTmpField.second.getAccessID());
if(funArg == CodeGeneratorHelper::FunctionArgType::FT_Caller) {
strides.push_back("m_" + fieldName + ".strides()[3]," + "m_" + fieldName + ".strides()[4]," + "m_" + fieldName + ".get_storage_info_ptr()->template begin<0>()," + "m_" +
fieldName + ".get_storage_info_ptr()->template begin<1>()," + "m_" +
fieldName + ".get_storage_info_ptr()->template stride<1>()," + "m_" +
fieldName + ".get_storage_info_ptr()->template stride<4>()");
}

Array3i dims{-1, -1, -1};
for(const auto& fieldInfo : ms->getParent()->getFields()) {
if(fieldInfo.second.field.getAccessID() == firstTmpField.second.getAccessID()) {
DAWN_ASSERT_MSG(
dawn::ast::dimension_isa<dawn::ast::CartesianFieldDimension>(
fieldInfo.second.field.getFieldDimensions().getHorizontalFieldDimension()),
"Field has non cartesian horizontal dimension");
auto const& dimCartesian =
dawn::ast::dimension_cast<dawn::ast::CartesianFieldDimension const&>(
fieldInfo.second.field.getFieldDimensions().getHorizontalFieldDimension());
dims[0] = dimCartesian.I() == 1;
dims[1] = dimCartesian.J() == 1;
dims[2] = fieldInfo.second.field.getFieldDimensions().K() == 1;
break;
}
}

int usedDim = 0;
for(int i = 0; i < dims.size(); ++i) {
if(!dims[i])
continue;
if(!(usedDim++))
continue;
if(funArg == CodeGeneratorHelper::FunctionArgType::FT_Callee) {
strides.push_back("const int stride_" + CodeGeneratorHelper::indexIteratorName(dims) + "_" +
std::to_string(i));
}
}
if(funArg == CodeGeneratorHelper::FunctionArgType::FT_Callee) {
strides.push_back("const int tmpBeginIIndex, const int tmpBeginJIndex, const int "
"jstride_tmp, const int kstride_tmp");
}
}
else if(!tempFields.empty()) {
const auto& firstTmpField = *(tempFields.begin());
std::string fieldName = metadata.getFieldNameFromAccessID(firstTmpField.second.getAccessID());
if(funArg == CodeGeneratorHelper::FunctionArgType::FT_Caller) {
Expand Down
Loading