Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace FileUtil with std::filesystem calls #936

Merged
merged 2 commits into from
Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion dawn/src/dawn/IIR/StencilInstantiation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "dawn/SIR/SIR.h"
#include "dawn/Support/Casting.h"
#include "dawn/Support/DiagnosticsEngine.h"
#include "dawn/Support/FileUtil.h"
#include "dawn/Support/Format.h"
#include "dawn/Support/Json.h"
#include "dawn/Support/Logging.h"
Expand Down
1 change: 0 additions & 1 deletion dawn/src/dawn/IIR/StencilMetaInformation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "dawn/IIR/StencilFunctionInstantiation.h"
#include "dawn/SIR/SIR.h"
#include "dawn/Support/Casting.h"
#include "dawn/Support/FileUtil.h"
#include "dawn/Support/Format.h"
#include "dawn/Support/Json.h"
#include <cstdlib>
Expand Down
6 changes: 3 additions & 3 deletions dawn/src/dawn/Optimizer/PassStageMerger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "dawn/IIR/StencilInstantiation.h"
#include "dawn/Optimizer/OptimizerContext.h"
#include "dawn/Optimizer/ReadBeforeWriteConflict.h"
#include "dawn/Support/FileUtil.h"
#include "dawn/Support/FileSystem.h"

namespace dawn {

Expand All @@ -40,8 +40,8 @@ bool PassStageMerger::run(const std::shared_ptr<iir::StencilInstantiation>& sten
if(!MergeDoMethods && !stencilNeedsMergePass)
return true;

std::string filenameWE =
getFilenameWithoutExtension(stencilInstantiation->getMetaData().getFileName());
const std::string filenameWE =
fs::path(stencilInstantiation->getMetaData().getFileName()).filename().stem();
if(context_.getOptions().ReportPassStageMerger)
stencilInstantiation->jsonDump(filenameWE + "_before.json");

Expand Down
6 changes: 3 additions & 3 deletions dawn/src/dawn/Optimizer/PassStageReordering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "dawn/Optimizer/PassStageReordering.h"
#include "dawn/IIR/StencilInstantiation.h"
#include "dawn/Optimizer/OptimizerContext.h"
#include "dawn/Support/FileUtil.h"
#include "dawn/Support/FileSystem.h"
#include "dawn/Support/Unreachable.h"

#include "dawn/Optimizer/ReorderStrategyGreedy.h"
Expand All @@ -30,8 +30,8 @@ PassStageReordering::PassStageReordering(OptimizerContext& context, ReorderStrat

bool PassStageReordering::run(
const std::shared_ptr<iir::StencilInstantiation>& stencilInstantiation) {
std::string filenameWE =
getFilenameWithoutExtension(stencilInstantiation->getMetaData().getFileName());
const std::string filenameWE =
fs::path(stencilInstantiation->getMetaData().getFileName()).filename().stem();
if(context_.getOptions().ReportPassStageReodering)
stencilInstantiation->jsonDump(filenameWE + "_before.json");

Expand Down
2 changes: 0 additions & 2 deletions dawn/src/dawn/Support/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ add_library(DawnSupport
DiagnosticsQueue.h
DoubleSidedMap.h
EditDistance.h
FileUtil.cpp
Exception.h
Exception.cpp
FileUtil.h
Format.h
HashCombine.h
IndexGenerator.cpp
Expand Down
35 changes: 0 additions & 35 deletions dawn/src/dawn/Support/FileUtil.cpp

This file was deleted.

44 changes: 0 additions & 44 deletions dawn/src/dawn/Support/FileUtil.h

This file was deleted.

14 changes: 7 additions & 7 deletions dawn/test/unit-test/dawn/CodeGen/TestCodeGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
//===------------------------------------------------------------------------------------------===//

#include "dawn/SIR/SIR.h"
#include "dawn/Support/FileUtil.h"
#include "dawn/Unittest/CompilerUtil.h"
#include "dawn/Unittest/IIRBuilder.h"

Expand Down Expand Up @@ -123,16 +122,17 @@ class TestCodeGen : public ::testing::Test {
return getStencilFromIIR("conditional_stencil");
}

void runTest(const std::shared_ptr<StencilInstantiation> stencil_inst,
const std::string& ref_file) {
void runTest(const std::shared_ptr<StencilInstantiation> stencilInstantiation,
const std::string& refFile) {
std::ostringstream oss;
if(ref_file.find(".cu") != std::string::npos) {
CompilerUtil::dumpCuda(oss, stencil_inst);
if(refFile.find(".cu") != std::string::npos) {
CompilerUtil::dumpCuda(oss, stencilInstantiation);
} else {
CompilerUtil::dumpNaive(oss, stencil_inst);
CompilerUtil::dumpNaive(oss, stencilInstantiation);
}

std::string ref = readFile("../reference/" + ref_file);
std::ifstream t("../reference/" + refFile);
const std::string ref((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>());
ASSERT_EQ(oss.str(), ref) << "Generated code does not match reference code";
}
};
Expand Down
6 changes: 3 additions & 3 deletions gtclang/src/gtclang/Frontend/GTClangASTVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

#include "gtclang/Frontend/GTClangASTVisitor.h"
#include "dawn/SIR/SIR.h"
#include "dawn/Support/FileSystem.h"
#include "dawn/Support/Logging.h"
#include "gtclang/Frontend/GTClangContext.h"
#include "gtclang/Support/ClangCompat/SourceLocation.h"
#include "gtclang/Support/FileUtil.h"
#include "clang/AST/ASTContext.h"

namespace gtclang {
Expand Down Expand Up @@ -79,7 +79,7 @@ bool GTClangASTVisitor::VisitCXXRecordDecl(clang::CXXRecordDecl* recordDecl) {
auto name = recordDecl->getIdentifier()->getName().str();

DAWN_LOG(INFO) << "Parsing stencil `" << name << "` at "
<< getFilename(clang_compat::getBeginLoc(base).printToString(SM)).str();
<< fs::path(clang_compat::getBeginLoc(base).printToString(SM)).filename();

stencilParser_.parseStencil(recordDecl, name);
}
Expand All @@ -89,7 +89,7 @@ bool GTClangASTVisitor::VisitCXXRecordDecl(clang::CXXRecordDecl* recordDecl) {
auto name = recordDecl->getIdentifier()->getName().str();

DAWN_LOG(INFO) << "Parsing stencil function `" << name << "` at "
<< getFilename(clang_compat::getBeginLoc(base).printToString(SM)).str();
<< fs::path(clang_compat::getBeginLoc(base).printToString(SM)).filename();

stencilParser_.parseStencilFunction(recordDecl, name);
}
Expand Down
4 changes: 2 additions & 2 deletions gtclang/src/gtclang/Frontend/GlobalVariableParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
//===------------------------------------------------------------------------------------------===//

#include "gtclang/Frontend/GlobalVariableParser.h"
#include "dawn/Support/FileSystem.h"
#include "dawn/Support/Format.h"
#include "dawn/Support/Unreachable.h"
#include "gtclang/Frontend/GTClangContext.h"
#include "gtclang/Support/ASTUtils.h"
#include "gtclang/Support/ClangCompat/SourceLocation.h"
#include "gtclang/Support/FileUtil.h"
#include "gtclang/Support/Logger.h"
#include "clang/AST/AST.h"
#include <cstdlib>
Expand Down Expand Up @@ -94,7 +94,7 @@ void GlobalVariableParser::parseGlobals(clang::CXXRecordDecl* recordDecl) {

DAWN_LOG(INFO)
<< "Parsing globals at "
<< getFilename(recordDecl->getLocation().printToString(context_->getSourceManager())).str()
<< fs::path(recordDecl->getLocation().printToString(context_->getSourceManager())).filename()
<< " ...";

recordDecl_ = recordDecl;
Expand Down