Skip to content

Commit

Permalink
minor: some smaller changes + clang-tidy fixes
Browse files Browse the repository at this point in the history
philipportner committed Jan 27, 2025
1 parent 9862200 commit ee7e87e
Showing 7 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/api/cli/DaphneUserConfig.h
Original file line number Diff line number Diff line change
@@ -77,7 +77,7 @@ struct DaphneUserConfig {
bool explain_mlir_codegen_sparsity_exploiting_op_fusion = false;
bool explain_mlir_codegen_daphneir_to_mlir = false;
bool explain_mlir_codegen_mlir_specific = false;
bool statistics = false;
bool enable_statistics = false;

bool force_cuda = false;

4 changes: 2 additions & 2 deletions src/api/internal/daphne_internal.cpp
Original file line number Diff line number Diff line change
@@ -499,7 +499,7 @@ int startDAPHNE(int argc, const char **argv, DaphneLibResult *daphneLibRes, int
}
}

user_config.statistics = enableStatistics;
user_config.enable_statistics = enableStatistics;

if (user_config.use_distributed && distributedBackEndSetup == ALLOCATION_TYPE::DIST_MPI) {
#ifndef USE_MPI
@@ -671,7 +671,7 @@ int startDAPHNE(int argc, const char **argv, DaphneLibResult *daphneLibRes, int
std::cerr << "}" << std::endl;
}

if (user_config.statistics)
if (user_config.enable_statistics)
Statistics::instance().dumpStatistics(KernelDispatchMapping::instance());

// explicitly destroying the moduleOp here due to valgrind complaining about
7 changes: 3 additions & 4 deletions src/compiler/lowering/LowerToLLVMPass.cpp
Original file line number Diff line number Diff line change
@@ -570,8 +570,7 @@ class VectorizedPipelineOpLowering : public OpConversionPattern<daphne::Vectoriz
auto returnRef = funcBlock.addArgument(pppI1Ty, rewriter.getUnknownLoc());
auto inputsArg = funcBlock.addArgument(ptrPtrI1Ty, rewriter.getUnknownLoc());
auto daphneContext = funcBlock.addArgument(ptrI1Ty, rewriter.getUnknownLoc());
// TODO: we should not create a new daphneContext, instead pass the
// one created in the main function

for (auto callKernelOp : funcBlock.getOps<daphne::CallKernelOp>()) {
callKernelOp.setOperand(callKernelOp.getNumOperands() - 1, daphneContext);
}
@@ -603,7 +602,7 @@ class VectorizedPipelineOpLowering : public OpConversionPattern<daphne::Vectoriz
}

// Update function block to write return value by reference instead
auto oldReturn = funcBlock.getTerminator();
auto *oldReturn = funcBlock.getTerminator();
rewriter.setInsertionPoint(oldReturn);
for (auto i = 0u; i < oldReturn->getNumOperands(); ++i) {
auto retVal = oldReturn->getOperand(i);
@@ -677,7 +676,7 @@ class VectorizedPipelineOpLowering : public OpConversionPattern<daphne::Vectoriz

// Update function block to write return value by reference
// instead
auto oldReturn = funcBlock.getTerminator();
auto *oldReturn = funcBlock.getTerminator();
rewriter.setInsertionPoint(oldReturn);
for (auto i = 0u; i < oldReturn->getNumOperands(); ++i) {
auto retVal = oldReturn->getOperand(i);
4 changes: 2 additions & 2 deletions src/runtime/local/instrumentation/KernelInstrumentation.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include <runtime/local/instrumentation/KernelInstrumentation.h>

void preKernelInstrumentation(int kId, DaphneContext *ctx) {
if (ctx->getUserConfig().statistics)
if (ctx->getUserConfig().enable_statistics)
ctx->startKernelTimer(kId);
}

void postKernelInstrumentation(int kId, DaphneContext *ctx) {
if (ctx->getUserConfig().statistics)
if (ctx->getUserConfig().enable_statistics)
ctx->stopKernelTimer(kId);
}
2 changes: 1 addition & 1 deletion src/util/KernelDispatchMapping.cpp
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ KernelDispatchMapping &KernelDispatchMapping::instance() {
return INSTANCE;
}

int KernelDispatchMapping::registerKernel(std::string name, mlir::Operation *op) {
int KernelDispatchMapping::registerKernel(const std::string &name, mlir::Operation *op) {
std::lock_guard<std::mutex> lg(m_dispatchMapping);
int kId = kIdCounter++;
if (auto flcLoc = llvm::dyn_cast<mlir::FileLineColLoc>(op->getLoc())) {
2 changes: 1 addition & 1 deletion src/util/KernelDispatchMapping.h
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ struct KernelDispatchMapping {
* \param name The symbol name of the kernel.
* \param op The mlir::Operation being lowered to dispatch a kernel call.
*/
int registerKernel(std::string name, mlir::Operation *op);
int registerKernel(const std::string &name, mlir::Operation *op);
//
KDMInfo getKernelDispatchInfo(int kId);
};
2 changes: 1 addition & 1 deletion src/util/Statistics.cpp
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ void Statistics::stopKernelTimer(int kId) {
auto const stopTime = std::chrono::high_resolution_clock::now();
std::lock_guard<std::mutex> lg(m_times);
std::chrono::duration<double> kernelTime = stopTime - startTimes[kId];
kernelExecutionTimes.push_back({kId, kernelTime});
kernelExecutionTimes.emplace_back(kId, kernelTime);
}

size_t getMaxKernelNameLength(KernelDispatchMapping &kdm) {

0 comments on commit ee7e87e

Please sign in to comment.