Skip to content

Commit

Permalink
Merge pull request #6 from hassansalehe/cpp-comments
Browse files Browse the repository at this point in the history
Use cpp commenting style
  • Loading branch information
hassansalehe authored Jun 19, 2021
2 parents 60f28b3 + f08cea9 commit df03508
Show file tree
Hide file tree
Showing 20 changed files with 142 additions and 218 deletions.
8 changes: 2 additions & 6 deletions src/common/CriticalSignatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,12 @@

namespace tasksan {

/**
* Returns signature to mark beginning of a critical section
*/
// Returns signature to mark beginning of a critical section
inline std::string getStartCriticalSignature() {
return "TASKSAN:BeginCriticalSection";
}

/*
* Returns a string signature to mark end of a critical section
*/
// Returns a string signature to mark end of a critical section
inline std::string getEndCriticalSignature() {
return "TASKSAN:EndCriticalSection";
}
Expand Down
7 changes: 3 additions & 4 deletions src/common/MemoryActions.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class MemoryActions {
storeAction( act );
}

/** Stores action if (a) is first action of task, or
* (b) is last write action */
// Stores action if (a) is first action of task, or
// (b) is last write action
inline void storeAction(Action & act) {
if ( isEmpty || act.isWrite ) {
action = act;
Expand All @@ -66,8 +66,7 @@ class MemoryActions {
}
}

/**
* Returns true if current action is a write */
// Returns true if current action is a write
bool hasWrite() {
if ( isEmpty || ( !action.isWrite )) {
return false;
Expand Down
10 changes: 4 additions & 6 deletions src/common/action.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,15 @@ class Action {

Action() { }

/**
* Generates std::string representation of the action and stores
* in "buff". It appends '\n' at the end of the std::string */
// Generates std::string representation of the action and stores
// in "buff". It appends '\n' at the end of the std::string
void printAction(std::ostringstream & buff) {
printActionNN( buff );
buff << std::endl;
}

/**
* Generates std::string representation of the action and stores in "buff".
* It does not append '\n' at the end of. the std::string */
// Generates std::string representation of the action and stores in "buff".
// It does not append '\n' at the end of. the std::string
void printActionNN(std::ostringstream & buff) {
std::string type = " R ";
if ( isWrite ) type = " W ";
Expand Down
32 changes: 15 additions & 17 deletions src/common/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,22 @@
#ifndef _COMMON_DEFS_H_
#define _COMMON_DEFS_H_

#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <cctype>
#include <vector>
#include <set>
#include <map>
#include <ctime>
#include <chrono>
#include <ctime>
#include <fstream>
#include <iostream>
#include <map>
#include <mutex>
#include <regex>
#include <set>
#include <sstream>

#include <mutex> // std::mutex
//#include<//pthread.h>
//#include <thread> // std::thread
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

typedef bool BOOL;
typedef void VOID;
Expand Down Expand Up @@ -94,8 +91,9 @@ static std::string OperRepresentation(OPERATION op) {
}
};

/**
* Definition below is for debugging printfs */
//////////////////////////////////////////////////
/// Definition below is for debugging printfs //
//////////////////////////////////////////////////
// #define DEBUG

static std::mutex printLock;
Expand All @@ -107,4 +105,4 @@ void inline PRINT_DEBUG(const std::string msg) {
#endif // debug
}

#endif
#endif // guard
60 changes: 26 additions & 34 deletions src/common/instruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@ class Instruction {
// raw representation of instruction
std::string raw;

/**
* Default constructor
*/
// Default constructor
Instruction() {}
/**
* This constructor takes in IIR representation of an
* instruction and constructs an object representaion of it. */

// This constructor takes in IIR representation of an
// instruction and constructs an object representaion of it.
Instruction(std::string stmt) {

raw = trim( stmt );
Expand Down Expand Up @@ -102,37 +100,33 @@ class Instruction {
oper = CALL;
}

/*
// find operation
if (std::regex_search(segments[0], std::regex("store ")) {
oper = STORE;
std::string tmp = ;
std::stringstream a(trim(segments[0]));
tmp = ""'
(getline(ss, tok, ','); //store
}
if (std::regex_search(segments[0], std::regex("load "))
oper = LOAD;
// // find operation
// if (std::regex_search(segments[0], std::regex("store ")) {
// oper = STORE;
// std::string tmp = ;
// std::stringstream a(trim(segments[0]));
// tmp = ""'
// (getline(ss, tok, ','); //store
// }
// if (std::regex_search(segments[0], std::regex("load "))
// oper = LOAD;

if (std::regex_search(segments[0], std::regex("call "))
oper = CALL;
// if (std::regex_search(segments[0], std::regex("call "))
// oper = CALL;

if (std::regex_search(segments[0], std::regex("alloca "))
oper = ALLOCA;
// if (std::regex_search(segments[0], std::regex("alloca "))
// oper = ALLOCA;

if (std::regex_search(segments[0], std::regex("bitcast "))
oper = BITCAST;
// if (std::regex_search(segments[0], std::regex("bitcast "))
// oper = BITCAST;

if (std::regex_search(segments[0], std::regex("[fidb]add "))
oper = ADD;
// if (std::regex_search(segments[0], std::regex("[fidb]add "))
// oper = ADD;

if (std::regex_search(segments[0], std::regex("[fidb]mull "))
oper = MULT;
*/
// if (std::regex_search(segments[0], std::regex("[fidb]mull "))
// oper = MULT;
}



void print() {
std::cout << "LineNo: " << lineNo
<< ", type: " << type
Expand All @@ -143,16 +137,14 @@ class Instruction {
<< std::endl;
}

/**
* Trims the left and right spaces from a std::string. */
// Trims the left and right spaces from a std::string
static std::string trim(std::string sentence) {
size_t start = sentence.find_first_not_of(' ');
size_t end = sentence.find_last_not_of(' ');
return sentence.substr(start, (end -start)+1);
}

/**
* Splits std::string into tokens substrings */
// Splits std::string into tokens substrings
std::vector<std::string> splitInstruction(std::string stmt) {

// split statements
Expand Down
12 changes: 4 additions & 8 deletions src/detector/commutativity/CommutativityChecker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
#include "detector/determinacy/conflict.h"
#include "detector/determinacy/report.h"

/**
* Parses IIR representation file for critical sections
*/
// Parses IIR representation file for critical sections
VOID CommutativityChecker::parseTasksIR(char * IRlogName) {
std::vector<Instruction> currentTask;
std::string sttmt; // program statement
Expand Down Expand Up @@ -56,10 +54,8 @@ VOID CommutativityChecker::parseTasksIR(char * IRlogName) {
<< Tasks.getSize() << std::endl;
}

/**
* Checks for commutative critical sections operations which have been
* flagged as conflicts.
*/
// Checks for commutative critical sections operations which have been
// flagged as conflicts.
bool CommutativityChecker::isCommutative(const Conflict & conflict) {

// skip commutativity check if read-write conflict
Expand All @@ -80,7 +76,7 @@ bool CommutativityChecker::isCommutative(const Conflict & conflict) {
}

BOOL CommutativityChecker::involveSimpleOperations(
/*std::string taskName,*/
// std::string taskName,
INTEGER lineNumber) {

// get the instructions of a task
Expand Down
5 changes: 2 additions & 3 deletions src/detector/commutativity/CommutativityChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ class CommutativityChecker {
inline bool isCriticalSectionEnd(const std::string& sttmt) {
return tasksan::getEndCriticalSignature() == sttmt;
}
/**
* Returns the line number from the IR statement std::string
*/

// Returns the line number from the IR statement std::string
INTEGER getLineNumber(const std::string & sttmt) {
std::smatch result; // get line number
regex_search(sttmt, result, std::regex("^[0-9]+") );
Expand Down
18 changes: 6 additions & 12 deletions src/detector/determinacy/checker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,8 @@ void Checker::saveTaskActions( const MemoryActions & taskActions ) {
writes[taskActions.addr].push_back( taskActions ); // save
}


/**
* Records the determinacy race warning to the conflicts table.
* This is per pair of concurrent tasks.
*/
// Records the determinacy race warning to the conflicts table.
// This is per pair of concurrent tasks.
VOID Checker::saveDeterminacyRaceReport(const Action& curMemAction,
const Action& prevMemAction) {
Conflict aConflict(curMemAction, prevMemAction);
Expand Down Expand Up @@ -224,7 +221,7 @@ void Checker::addTaskNode(std::string & logLine) {
Checker::saveHappensBeforeEdge(parId, sibId);
}

/** Constructs action object from the log file */
// Constructs action object from the log file
void Checker::constructMemoryAction(std::stringstream & ssin,
std::string & operation,
Action & action) {
Expand All @@ -245,7 +242,7 @@ void Checker::constructMemoryAction(std::stringstream & ssin,
} else {
action.isWrite = false;
}
#ifdef DEBUG // check if data correctly set.
#ifdef DEBUG // check if data correctly set
std::cout << "Action constructed: ";
std::ostringstream buff;
action.printAction(buff);
Expand Down Expand Up @@ -273,7 +270,6 @@ void Checker::checkCommutativeOperations(CommutativityChecker & validator) {
}
}


VOID Checker::reportConflicts() {
const std::string emptyLine(
" ");
Expand Down Expand Up @@ -351,10 +347,8 @@ VOID Checker::testing() {
}
}


/**
* implementation of the checker destructor frees
* the memory dynamically generated for S-bags */
// Implementation of the checker destructor frees
// the memory dynamically generated for S-bags
Checker::~Checker() {
for (auto it = serial_bags.begin(); it != serial_bags.end(); it++) {
delete it->second;
Expand Down
2 changes: 1 addition & 1 deletion src/detector/determinacy/checker.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Checker {
~Checker();

private:
/** Constructs action object from the log file */
// Constructs action object from the log file
VOID constructMemoryAction(std::stringstream & ssin,
std::string & opType,
Action & action);
Expand Down
5 changes: 2 additions & 3 deletions src/detector/determinacy/operationSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ class OperationSet {
operations.insert( op );
}

/**
* Checks if operation "op" commutes with previous
* operations which manipulate a shared memory location. */
// Checks if operation "op" commutes with previous
// operations which manipulate a shared memory location
bool isCommutative(const OPERATION op) {
// compare with other operation
for (auto i : operations) {
Expand Down
3 changes: 3 additions & 0 deletions src/functionengine/CallStack.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
#ifndef _FUNCTIONENGINE_CALLSTACK_H_
#define _FUNCTIONENGINE_CALLSTACK_H_

#include <stack>
#include <string>

class CallStack {
private:
std::stack funcStack;
Expand Down
12 changes: 4 additions & 8 deletions src/instrumentor/callbacks/InstrumentationCallbacks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static TaskInfo * getTaskInfo(int * _type = NULL) {
}
}

/** Callbacks for store operations */
// Callbacks for store operations
inline void INS_MemRead(
address addr,
ulong size,
Expand All @@ -89,8 +89,7 @@ inline void INS_MemRead(
}
}

/*
* Callbacks for store operations */
// Callbacks for store operations
inline void INS_MemWrite(
address addr,
lint value,
Expand All @@ -116,9 +115,7 @@ inline void INS_MemWrite(
}
}


/**
* A callback for memory writes of floats */
// A callback for memory writes of floats
void __tasksan_write_float(
address addr,
float value,
Expand All @@ -131,8 +128,7 @@ void __tasksan_register_iir_file(void * fileName) {
INS::initCommutativityChecker( (char *)fileName );
}

/**
* A callback for memory writes of doubles */
// A callback for memory writes of doubles
void __tasksan_write_double(
address addr,
double value,
Expand Down
Loading

0 comments on commit df03508

Please sign in to comment.