mirror of
https://github.com/paboyle/Grid.git
synced 2026-06-22 11:43:16 +01:00
Merge with Christoph GPT checksum debug
This commit is contained in:
@@ -372,4 +372,53 @@ void FlightRecorder::recvLog(void *buf,uint64_t bytes,int rank)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef GRID_LOG_VIEWS
|
||||
|
||||
bool ViewLogger::Enabled = false;
|
||||
std::vector<ViewLogger::Entry_t> ViewLogger::LogVector;
|
||||
|
||||
void ViewLogger::Begin() { Enabled = true; LogVector.resize(0); }
|
||||
void ViewLogger::End() { Enabled = false; }
|
||||
|
||||
void ViewLogger::Log(const char* filename, int line, int index, int mode, void* data, uint64_t bytes)
|
||||
{
|
||||
if (!Enabled)
|
||||
return;
|
||||
|
||||
size_t i = LogVector.size();
|
||||
LogVector.resize(i + 1);
|
||||
auto & n = LogVector[i];
|
||||
|
||||
n.filename = filename;
|
||||
n.line = line;
|
||||
n.index = index;
|
||||
|
||||
if (bytes < sizeof(uint64_t)) {
|
||||
|
||||
n.head = n.tail = 0;
|
||||
|
||||
} else {
|
||||
|
||||
switch (mode) {
|
||||
case AcceleratorRead:
|
||||
case AcceleratorWrite:
|
||||
case AcceleratorWriteDiscard:
|
||||
acceleratorCopyFromDevice((char*)data, &n.head, sizeof(uint64_t));
|
||||
acceleratorCopyFromDevice((char*)data + bytes - sizeof(uint64_t), &n.tail, sizeof(uint64_t));
|
||||
break;
|
||||
|
||||
case CpuRead:
|
||||
case CpuWrite:
|
||||
//case CpuWriteDiscard:
|
||||
n.head = *(uint64_t*)data;
|
||||
n.tail = *(uint64_t*)((char*)data + bytes - sizeof(uint64_t));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
NAMESPACE_END(Grid);
|
||||
|
||||
@@ -42,5 +42,22 @@ class FlightRecorder {
|
||||
static void xmitLog(void *,uint64_t bytes);
|
||||
static void recvLog(void *,uint64_t bytes,int rank);
|
||||
};
|
||||
#ifdef GRID_LOG_VIEWS
|
||||
class ViewLogger {
|
||||
struct Entry_t {
|
||||
const char* filename;
|
||||
int line;
|
||||
int index;
|
||||
uint64_t head, tail;
|
||||
};
|
||||
|
||||
public:
|
||||
static bool Enabled;
|
||||
static std::vector<Entry_t> LogVector;
|
||||
static void Begin();
|
||||
static void End();
|
||||
static void Log(const char* filename, int line, int index, int mode, void* data, uint64_t bytes);
|
||||
};
|
||||
#endif
|
||||
NAMESPACE_END(Grid);
|
||||
|
||||
|
||||
@@ -416,12 +416,28 @@ void Grid_init(int *argc,char ***argv)
|
||||
} else {
|
||||
FILE *fp;
|
||||
std::ostringstream fname;
|
||||
|
||||
int rank = CartesianCommunicator::RankWorld();
|
||||
int radix=64;
|
||||
char* root = getenv("GRID_STDOUT_ROOT");
|
||||
if (root) {
|
||||
fname << root ;
|
||||
mkdir(fname.str().c_str(), S_IRWXU );
|
||||
fname << "/";
|
||||
}
|
||||
fname << (rank/radix)*radix ;
|
||||
mkdir(fname.str().c_str(), S_IRWXU );
|
||||
fname << "/";
|
||||
fname<<"Grid.stdout.";
|
||||
fname<<CartesianCommunicator::RankWorld();
|
||||
fp=freopen(fname.str().c_str(),"w",stdout);
|
||||
assert(fp!=(FILE *)NULL);
|
||||
|
||||
std::ostringstream ename;
|
||||
if (root){
|
||||
ename << root << "/";
|
||||
}
|
||||
ename << (rank/radix)*radix << "/";
|
||||
ename<<"Grid.stderr.";
|
||||
ename<<CartesianCommunicator::RankWorld();
|
||||
fp=freopen(ename.str().c_str(),"w",stderr);
|
||||
|
||||
Reference in New Issue
Block a user