Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push 2024 12 11 #890

Merged
merged 7 commits into from
Dec 13, 2024
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
34 changes: 20 additions & 14 deletions src/cpucounters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1444,29 +1444,19 @@ bool PCM::discoverSystemTopology()
}
if(num_sockets == 0) {
num_sockets = (int32)(std::max)(socketIdMap.size(), (size_t)1);
// std::cerr << " num_sockets = " << num_sockets << "\n";
}

socketIdMap_type::iterator s = socketIdMap.begin();
for (uint32 sid = 0; s != socketIdMap.end(); ++s)
{
s->second = sid++;
// first is apic id, second is logical socket id
systemTopology->addSocket( s->first, s->second );
}

for (int32 cid = 0; cid < num_cores; ++cid)
{
//std::cerr << "Cid: " << cid << "\n";
systemTopology->addThread( cid, topology[cid] );
}

// All threads are here now so we can set the refCore for a socket
for ( auto& socket : systemTopology->sockets() )
socket->setRefCore();

// use map to change apic socket id to the logical socket id
for (int i = 0; (i < (int)num_cores) && (!socketIdMap.empty()); ++i)
{
// std::cerr << "socket_id: " << topology[i].socket_id << ", socketIdMap tells me: " << socketIdMap[topology[i].socket_id] << "\n";
if(isCoreOnline((int32)i))
topology[i].socket_id = socketIdMap[topology[i].socket_id];
}
Expand All @@ -1483,14 +1473,30 @@ bool PCM::discoverSystemTopology()
{
for (int i = 0; i < (int)num_cores; ++i)
{
if (topology[i].socket_id == topology[0].socket_id && topology[i].core_id == topology[0].core_id)
if (topology[i].isSameCore( topology[0] ))
++threads_per_core;
}
assert(threads_per_core != 0);
}
if(num_phys_cores_per_socket == 0 && num_cores == num_online_cores) num_phys_cores_per_socket = num_cores / num_sockets / threads_per_core;
if(num_online_cores == 0) num_online_cores = num_cores;

s = socketIdMap.begin();
for (; s != socketIdMap.end(); ++s)
{
systemTopology->addSocket( s->second );
}

for (int32 cid = 0; cid < num_cores; ++cid)
{
//std::cerr << "Cid: " << cid << "\n";
systemTopology->addThread( cid, topology[cid] );
}

// All threads are here now so we can set the refCore for a socket
for ( auto& socket : systemTopology->sockets() )
socket->setRefCore();

int32 i = 0;

socketRefCore.resize(num_sockets, -1);
Expand Down Expand Up @@ -3421,11 +3427,11 @@ void PCM::destroyMSR()

PCM::~PCM()
{
deleteAndNullify(systemTopology);
if (instance)
{
destroyMSR();
instance = NULL;
deleteAndNullify(systemTopology);
}
}

Expand Down
24 changes: 21 additions & 3 deletions src/pcm-sensor-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ class PrometheusPrinter : Visitor
}

virtual void dispatch( Core* c ) override {
addToHierarchy( std::string( "core=\"" ) + std::to_string( c->coreID() ) + "\"" );
addToHierarchy( std::string( "core=\"" ) + std::to_string( c->dieGroupID()*256 + c->dieID()*64 + c->tileID()*16 + c->moduleID()*4 + c->coreID() ) + "\"" );
auto vec = c->threads();
iterateVectorAndCallAccept( vec );

Expand Down Expand Up @@ -801,6 +801,7 @@ class PrometheusPrinter : Visitor
}
removeFromHierarchy();
}

void printSystemCounterState( SystemCounterState const& before, SystemCounterState const& after ) {
addToHierarchy( "source=\"uncore\"" );
PCM* pcm = PCM::getInstance();
Expand Down Expand Up @@ -3759,6 +3760,7 @@ int mainThrows(int argc, char * argv[]) {
bool useRealtimePriority = false;
#endif
bool forceRTMAbortMode = false;
bool printTopology = false;
unsigned short port = 0;
unsigned short debug_level = 0;
std::string certificateFile;
Expand All @@ -3774,7 +3776,12 @@ int mainThrows(int argc, char * argv[]) {
MainLoop mainLoop;
std::string ev_file_name;

if ( argc > 1 ) {
const char* PPTEnv = std::getenv( "PCMSENSORSERVER_PRINT_TOPOLOGY" );
if ( PPTEnv ) {
if ( *PPTEnv == '1' ) {
printTopology = true;
}
} else if ( argc > 1 ) {
std::string arg_value;

for ( int i=1; i < argc; ++i ) {
Expand Down Expand Up @@ -3901,7 +3908,7 @@ int mainThrows(int argc, char * argv[]) {
}
}

#ifdef __linux__
#ifdef __linux__
// check kernel version for driver dependency.
if (accel != ACCEL_NOCONFIG)
{
Expand Down Expand Up @@ -4035,6 +4042,17 @@ int mainThrows(int argc, char * argv[]) {

accs_->programAccelCounters();
}
if ( printTopology ) {
TopologyPrinter* tp = new TopologyPrinter();
tp->dispatch( PCM::getInstance()->getSystemTopology() );
std::vector<std::string> & tpData = tp->topologyDataStrings();
std::sort( tpData.begin(), tpData.end(), TopologyStringCompare );
for( auto& line: tpData ) {
std::cout << line << "\n";
}
deleteAndNullify( tp );
exit( 0 );
}
#if defined (USE_SSL)
if ( useSSL ) {
if ( port == 0 )
Expand Down
2 changes: 1 addition & 1 deletion src/simdjson
Submodule simdjson updated 82 files
+29 −0 .github/workflows/aarch64.yml
+1 −1 .github/workflows/cifuzz.yml
+1 −1 .github/workflows/fix-trailing-whitespace.yml
+1 −1 .github/workflows/msys2.yml
+1 −1 .github/workflows/ppc64.yml
+1 −1 .github/workflows/riscv64.yml
+1 −1 .github/workflows/s390x.yml
+22 −0 .github/workflows/ubuntu24-cxx20.yml
+1 −2 .github/workflows/vs17-arm-ci.yml
+4 −4 .github/workflows/vs17-ci.yml
+37 −0 .github/workflows/vs17-clang-ci-cxx20.yml
+18 −6 .vscode/settings.json
+4 −3 CMakeLists.txt
+1 −1 Doxyfile
+4 −0 README.md
+1 −1 benchmark/find_tweet/nlohmann_json.h
+2 −2 benchmark/top_tweet/nlohmann_json.h
+24 −0 cmake/CPM.cmake
+76 −37 dependencies/CMakeLists.txt
+0 −48 dependencies/import.cmake
+334 −97 doc/basics.md
+64 −0 doc/dom.md
+115 −1 doc/iterate_many.md
+6 −1 doc/parse_many.md
+2 −2 doc/performance.md
+0 −1 include/simdjson.h
+9 −3 include/simdjson/arm64/bitmanipulation.h
+6 −0 include/simdjson/arm64/numberparsing_defs.h
+7 −7 include/simdjson/arm64/simd.h
+1 −0 include/simdjson/base.h
+12 −0 include/simdjson/compiler_check.h
+113 −0 include/simdjson/concepts.h
+14 −0 include/simdjson/dom/array-inl.h
+16 −0 include/simdjson/dom/array.h
+11 −0 include/simdjson/dom/element-inl.h
+19 −0 include/simdjson/dom/element.h
+12 −0 include/simdjson/dom/object-inl.h
+18 −0 include/simdjson/dom/object.h
+22 −1 include/simdjson/dom/parser.h
+6 −0 include/simdjson/fallback/numberparsing_defs.h
+0 −1 include/simdjson/generic/dependencies.h
+0 −1 include/simdjson/generic/numberparsing.h
+7 −1 include/simdjson/generic/ondemand/amalgamated.h
+1 −47 include/simdjson/generic/ondemand/array-inl.h
+2 −1 include/simdjson/generic/ondemand/array.h
+1 −0 include/simdjson/generic/ondemand/dependencies.h
+123 −0 include/simdjson/generic/ondemand/deserialize.h
+48 −9 include/simdjson/generic/ondemand/document-inl.h
+143 −21 include/simdjson/generic/ondemand/document.h
+0 −1 include/simdjson/generic/ondemand/document_stream-inl.h
+21 −1 include/simdjson/generic/ondemand/parser.h
+166 −0 include/simdjson/generic/ondemand/std_deserialize.h
+18 −9 include/simdjson/generic/ondemand/value-inl.h
+56 −10 include/simdjson/generic/ondemand/value.h
+2 −0 include/simdjson/generic/ondemand/value_iterator-inl.h
+6 −0 include/simdjson/haswell/begin.h
+64 −0 include/simdjson/jsonpathutil.h
+6 −0 include/simdjson/lasx/numberparsing_defs.h
+6 −0 include/simdjson/lsx/numberparsing_defs.h
+9 −1 include/simdjson/padded_string-inl.h
+5 −0 include/simdjson/padded_string_view-inl.h
+9 −0 include/simdjson/padded_string_view.h
+39 −0 include/simdjson/portability.h
+6 −0 include/simdjson/ppc64/numberparsing_defs.h
+3 −3 include/simdjson/simdjson_version.h
+4 −0 singleheader/amalgamate.py
+272 −31 singleheader/simdjson.cpp
+17,458 −13,090 singleheader/simdjson.h
+1 −0 tests/dom/CMakeLists.txt
+350 −0 tests/dom/json_path_tests.cpp
+45 −0 tests/dom/readme_examples.cpp
+31 −26 tests/ondemand/CMakeLists.txt
+22 −2 tests/ondemand/ondemand_cacheline.cpp
+263 −0 tests/ondemand/ondemand_car_deserialization.cpp
+335 −0 tests/ondemand/ondemand_car_tag_invoke_deserialization.cpp
+178 −0 tests/ondemand/ondemand_custom_types_document_tests.cpp
+195 −0 tests/ondemand/ondemand_custom_types_tests.cpp
+49 −0 tests/ondemand/ondemand_json_path_tests.cpp
+32 −24 tests/ondemand/ondemand_readme_examples.cpp
+12 −3 tests/ondemand/ondemand_scalar_tests.cpp
+257 −0 tests/ondemand/ondemand_stl_types_tests.cpp
+1 −0 tests/test_macros.h
16 changes: 14 additions & 2 deletions src/topology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ UncoreCounterState ClientUncore::uncoreCounterState( void ) const
return ucs;
}

Socket::Socket( PCM* m, int32 apicID, int32 logicalID )
: pcm_(m), refCore_(nullptr), apicID_(apicID), logicalID_(logicalID)
Socket::Socket( PCM* m, int32 logicalID )
: pcm_(m), refCore_(nullptr), logicalID_(logicalID)
{
if ( pcm_->isServerCPU() )
uncore_ = new ServerUncore( pcm_, logicalID );
Expand Down Expand Up @@ -102,4 +102,16 @@ void Aggregator::dispatch( SystemRoot const& syp ) {
readAccelCounters(sycs_);
}

bool TopologyStringCompare( const std::string& topology1, const std::string& topology2 ) {
if ( topology1.size() == 0 ) return true;
if ( topology2.size() == 0 ) return false;

int topo1asint, topo2asint;
std::stringstream ss1(topology1);
std::stringstream ss2(topology2);
ss1 >> topo1asint;
ss2 >> topo2asint;
return topo1asint < topo2asint;
}

}// namespace pcm
Loading
Loading