mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-17 15:27:06 +01:00
Merge branch 'develop' into feature/staggered-comms-compute
Conflicts: lib/qcd/action/fermion/ImprovedStaggeredFermion.cc
This commit is contained in:
@ -49,6 +49,7 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
|
||||
#include <Grid/Grid.h>
|
||||
|
||||
#include <Grid/util/CompilerCompatible.h>
|
||||
#include <version.h>
|
||||
|
||||
|
||||
#include <fenv.h>
|
||||
@ -204,7 +205,7 @@ std::string GridCmdVectorIntToString(const std::vector<int> & vec){
|
||||
// Reinit guard
|
||||
/////////////////////////////////////////////////////////
|
||||
static int Grid_is_initialised = 0;
|
||||
|
||||
static MemoryStats dbgMemStats;
|
||||
|
||||
void Grid_init(int *argc,char ***argv)
|
||||
{
|
||||
@ -220,11 +221,11 @@ void Grid_init(int *argc,char ***argv)
|
||||
arg= GridCmdOptionPayload(*argv,*argv+*argc,"--shm");
|
||||
GridCmdOptionInt(arg,MB);
|
||||
uint64_t MB64 = MB;
|
||||
CartesianCommunicator::MAX_MPI_SHM_BYTES = MB64*1024LL*1024LL;
|
||||
GlobalSharedMemory::MAX_MPI_SHM_BYTES = MB64*1024LL*1024LL;
|
||||
}
|
||||
|
||||
if( GridCmdOptionExists(*argv,*argv+*argc,"--shm-hugepages") ){
|
||||
CartesianCommunicator::Hugepages = 1;
|
||||
GlobalSharedMemory::Hugepages = 1;
|
||||
}
|
||||
|
||||
|
||||
@ -251,6 +252,11 @@ void Grid_init(int *argc,char ***argv)
|
||||
assert(fp!=(FILE *)NULL);
|
||||
}
|
||||
|
||||
if( GridCmdOptionExists(*argv,*argv+*argc,"--debug-mem") ){
|
||||
MemoryProfiler::debug = true;
|
||||
MemoryProfiler::stats = &dbgMemStats;
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
// Banner
|
||||
////////////////////////////////////
|
||||
@ -283,6 +289,7 @@ void Grid_init(int *argc,char ***argv)
|
||||
std::cout << "but WITHOUT ANY WARRANTY; without even the implied warranty of"<<std::endl;
|
||||
std::cout << "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"<<std::endl;
|
||||
std::cout << "GNU General Public License for more details."<<std::endl;
|
||||
printHash();
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
@ -324,6 +331,7 @@ void Grid_init(int *argc,char ***argv)
|
||||
std::cout<<GridLogMessage<<" --decomposition : report on default omp,mpi and simd decomposition"<<std::endl;
|
||||
std::cout<<GridLogMessage<<" --debug-signals : catch sigsegv and print a blame report"<<std::endl;
|
||||
std::cout<<GridLogMessage<<" --debug-stdout : print stdout from EVERY node"<<std::endl;
|
||||
std::cout<<GridLogMessage<<" --debug-mem : print Grid allocator activity"<<std::endl;
|
||||
std::cout<<GridLogMessage<<" --notimestamp : suppress millisecond resolution stamps"<<std::endl;
|
||||
std::cout<<GridLogMessage<<std::endl;
|
||||
std::cout<<GridLogMessage<<"Performance:"<<std::endl;
|
||||
@ -379,6 +387,7 @@ void Grid_init(int *argc,char ***argv)
|
||||
if( GridCmdOptionExists(*argv,*argv+*argc,"--comms-threads") ){
|
||||
arg= GridCmdOptionPayload(*argv,*argv+*argc,"--comms-threads");
|
||||
GridCmdOptionInt(arg,CartesianCommunicator::nCommThreads);
|
||||
assert(CartesianCommunicator::nCommThreads > 0);
|
||||
}
|
||||
if( GridCmdOptionExists(*argv,*argv+*argc,"--cacheblocking") ){
|
||||
arg= GridCmdOptionPayload(*argv,*argv+*argc,"--cacheblocking");
|
||||
@ -394,8 +403,8 @@ void Grid_init(int *argc,char ***argv)
|
||||
Grid_default_latt,
|
||||
Grid_default_mpi);
|
||||
|
||||
std::cout << GridLogMessage << "Requesting "<< CartesianCommunicator::MAX_MPI_SHM_BYTES <<" byte stencil comms buffers "<<std::endl;
|
||||
if ( CartesianCommunicator::Hugepages) {
|
||||
std::cout << GridLogMessage << "Requesting "<< GlobalSharedMemory::MAX_MPI_SHM_BYTES <<" byte stencil comms buffers "<<std::endl;
|
||||
if ( GlobalSharedMemory::Hugepages) {
|
||||
std::cout << GridLogMessage << "Mapped stencil comms buffers as MAP_HUGETLB "<<std::endl;
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,7 @@ namespace Grid {
|
||||
std::vector<int> &simd,
|
||||
std::vector<int> &mpi);
|
||||
|
||||
void printHash(void);
|
||||
|
||||
};
|
||||
#endif
|
||||
|
72
lib/util/Profiling.h
Normal file
72
lib/util/Profiling.h
Normal file
@ -0,0 +1,72 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./lib/util/Profiling.h
|
||||
|
||||
Copyright (C) 2018
|
||||
|
||||
Author: Guido Cossu <guido.cossu@ed.ac.uk>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
See the full license in the file "LICENSE" in the top level distribution directory
|
||||
*************************************************************************************/
|
||||
/* END LEGAL */
|
||||
|
||||
#ifndef GRID_PERF_PROFILING_H
|
||||
#define GRID_PERF_PROFILING_H
|
||||
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <functional>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
|
||||
struct System
|
||||
{
|
||||
static void profile(const std::string& name,std::function<void()> body) {
|
||||
std::string filename = name.find(".data") == std::string::npos ? (name + ".data") : name;
|
||||
|
||||
// Launch profiler
|
||||
pid_t pid;
|
||||
std::stringstream s;
|
||||
s << getpid();
|
||||
pid = fork();
|
||||
if (pid == 0) {
|
||||
auto fd=open("/dev/null",O_RDWR);
|
||||
dup2(fd,1);
|
||||
dup2(fd,2);
|
||||
exit(execl("/usr/bin/perf","perf","record","-o",filename.c_str(),"-p",s.str().c_str(),nullptr));
|
||||
}
|
||||
|
||||
// Run body
|
||||
body();
|
||||
|
||||
// Kill profiler
|
||||
kill(pid,SIGINT);
|
||||
waitpid(pid,nullptr,0);
|
||||
}
|
||||
|
||||
static void profile(std::function<void()> body) {
|
||||
profile("perf.data",body);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // GRID_PERF_PROFILING_H
|
12
lib/util/version.cc
Normal file
12
lib/util/version.cc
Normal file
@ -0,0 +1,12 @@
|
||||
#include <iostream>
|
||||
#include <version.h>
|
||||
namespace Grid {
|
||||
void printHash(){
|
||||
#ifdef GITHASH
|
||||
std::cout << "Current Grid git commit hash=" << GITHASH << std::endl;
|
||||
#else
|
||||
std::cout << "Current Grid git commit hash is undefined. Check makefile." << std::endl;
|
||||
#endif
|
||||
#undef GITHASH
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user