Skip to content
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
6 changes: 4 additions & 2 deletions benchmark/src/Benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ void runSingleThreadTest(std::string configName) {
uint64_t usingMeter = cfg->tryU64("usingMeter", 0, true);
std::string meterTag = cfg->tryString("meterTag", "intelMsr", true);
uint64_t useCPP = cfg->tryU64("useCPP", 0, true);
uint64_t forceMP=cfg->tryU64("forceMP", 0, true);
if (usingMeter) {
eMeter = meterTable.findMeter(meterTag);
if (eMeter != nullptr) {
Expand Down Expand Up @@ -67,7 +68,7 @@ auto B = torch::rand({(long) aCol, (long) bCol});*/
ThreadPerf pef(-1);
pef.setPerfList();
AMMBench::BlockPartitionRunner br;
if (threads > 1) {
if (threads > 1||forceMP) {
INTELLI_WARNING("use multithread");
br.setConfig(cfg);
br.createABC(A, B);
Expand Down Expand Up @@ -113,9 +114,10 @@ auto B = torch::rand({(long) aCol, (long) bCol});*/
resultCsv->edit("energyAll", (double) energyConsumption);
resultCsv->edit("energyOnlyMe", (double) pureEnergy);
}
if (threads > 1) {
if (threads > 1||forceMP) {
INTELLI_WARNING("consider multithread elapsed time");
resultCsv->edit("perfElapsedTime", (uint64_t) br.getElapsedTime());
br.appendThreadInfo(resultCsv);
}
// error
INTELLI_WARNING("evaluating the error, may takes some time");
Expand Down
2 changes: 1 addition & 1 deletion commit.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
BRANCH=count-sketch-cpp
BRANCH=core-bind-bug
git init
git checkout -b $BRANCH
git add .
Expand Down
2 changes: 1 addition & 1 deletion commit_info
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1. FIX CONFLICTS WITH MAIN
1. fix core bind bugs
13 changes: 13 additions & 0 deletions include/Parallelization/BlockPartitionRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ class BlockPartitionWorker : public INTELLI::AbstractC20Thread {
* @param mycore the core to be binded
*/
void setWorkParameters(uint64_t aStart, uint64_t aEnd, int mycore);
void setCoreBInd(int cno)
{
coreBind=cno;
}
~BlockPartitionWorker() {

}
Expand Down Expand Up @@ -118,6 +122,10 @@ class BlockPartitionRunner {
*/
TensorPtr matC = nullptr; // Output matrix C
std::vector<BlockPartitionWorkerPtr> workers;
/**
* @brief special bind of first core, if need
*/
uint64_t firstCoreBind=0;
public:
BlockPartitionRunner() {}
~BlockPartitionRunner() {}
Expand Down Expand Up @@ -154,6 +162,11 @@ class BlockPartitionRunner {
* @note Exclude the overhead of cleaning thread states such as loaded module
*/
uint64_t getElapsedTime();
/**
* @brief append the running information of each thread to the result csv
* @param ru The result csv to be appended
*/
void appendThreadInfo(INTELLI::ConfigMapPtr ru);
};

} // AMMBench
Expand Down
13 changes: 13 additions & 0 deletions src/Parallelization/BlockPartitionRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,12 @@ void AMMBench::BlockPartitionRunner::setConfig(INTELLI::ConfigMapPtr _cfg) {
cfg = _cfg;
threads = cfg->tryU64("threads", 2, true);
workers = std::vector<BlockPartitionWorkerPtr>(threads);
firstCoreBind=cfg->tryU64("firstCoreBind",0, false);
for (uint64_t i = 0; i < threads; i++) {
workers[i] = newBlockPartitionWorker();
workers[i]->setConfig(cfg);
}

INTELLI_INFO("set up " + to_string(threads) + "workers.");
}
void AMMBench::BlockPartitionRunner::createABC(torch::Tensor A, torch::Tensor B) {
Expand All @@ -89,6 +91,11 @@ void AMMBench::BlockPartitionRunner::createABC(torch::Tensor A, torch::Tensor B)
workers[i]->setABC(matA, matB, matC);
workers[i]->setWorkParameters(start_row, end_row, i);
}
if(firstCoreBind!=0)
{
workers[0]->setCoreBInd((int)firstCoreBind);
INTELLI_INFO("first thread is bound to core" + to_string(firstCoreBind) );
}
}
torch::Tensor AMMBench::BlockPartitionRunner::parallelForward() {
for (uint64_t i = 0; i < threads; i++) {
Expand All @@ -114,4 +121,10 @@ uint64_t AMMBench::BlockPartitionRunner::getElapsedTime() {
ti += workers[i]->getElapsedTime();
}
return ti / threads;
}
void AMMBench::BlockPartitionRunner::appendThreadInfo(INTELLI::ConfigMapPtr ru) {
for (uint64_t i = 0; i < threads; i++) {
std::string keyElapesedTime="thread"+ to_string(i)+"RunTime";
ru->edit(keyElapesedTime,(uint64_t) workers[i]->getElapsedTime());
}
}
12 changes: 12 additions & 0 deletions src/Utils/UtilityFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
#include <iostream>
#include <numeric>

#include <time.h>
#include <sched.h>
#include <pthread.h>
#include<cstdlib>
#include<time.h>
using namespace std;

/*
Expand All @@ -27,6 +32,13 @@ int INTELLI::UtilityFunctions::bind2Core(int id) {
cpu_set_t mask;
CPU_ZERO(&mask);
CPU_SET(cpuId, &mask);
/**
* @brief fixed some core bind bugs
*/
if (sched_setaffinity(0, sizeof(cpu_set_t), &mask) < 0) {
AT_ERROR("Error: setaffinity()\n");
exit(0);
}
return cpuId;
}

Expand Down