From 9af2f23bdfbd92712a4bfedb945be80a930ca842 Mon Sep 17 00:00:00 2001 From: Gerhard Raven Date: Thu, 23 Oct 2025 00:54:55 +0200 Subject: [PATCH] Migrate from gsl::span to std::span --- AllenOnline/CMakeLists.txt | 2 -- AllenOnline/application/MPISend.cpp | 6 +++--- AllenOnline/application/bench_mep_offsets.cpp | 2 +- AllenOnline/include/AllenOnline/ReadMEP.h | 5 ++--- AllenOnline/include/AllenOnline/TransposeMEP.h | 2 +- AllenOnline/src/AllenApplication.cpp | 2 +- AllenOnline/src/AllenApplication.h | 2 +- AllenOnline/src/MBMOutput.cpp | 8 ++++---- AllenOnline/src/MEPProvider.cpp | 10 +++++----- AllenOnline/src/MEPProvider.h | 4 ++-- AllenOnline/src/ReadMEP.cpp | 5 ++--- AllenOnline/src/TransposeMEP.cpp | 2 +- cmake/MooreOnlineDependencies.cmake | 1 - 13 files changed, 23 insertions(+), 28 deletions(-) mode change 100755 => 100644 AllenOnline/src/MBMOutput.cpp mode change 100755 => 100644 AllenOnline/src/MEPProvider.cpp diff --git a/AllenOnline/CMakeLists.txt b/AllenOnline/CMakeLists.txt index 50dbf1e90..695783918 100644 --- a/AllenOnline/CMakeLists.txt +++ b/AllenOnline/CMakeLists.txt @@ -19,7 +19,6 @@ gaudi_add_library(AllenOnlineLib src/TransposeMEP.cpp LINK PUBLIC Gaudi::GaudiKernel - cppgsl::cppgsl Online::EventBuildingLib Allen::AllenLib ) @@ -50,7 +49,6 @@ gaudi_add_module(AllenOnlineComp Online::OnlineBase Online::RPC Online::dim - cppgsl::cppgsl rt ) diff --git a/AllenOnline/application/MPISend.cpp b/AllenOnline/application/MPISend.cpp index 8a1dc9cbd..46f017f3f 100644 --- a/AllenOnline/application/MPISend.cpp +++ b/AllenOnline/application/MPISend.cpp @@ -77,13 +77,13 @@ int main( int argc, char* argv[] ) { std::vector requests( window_size ); // Read all files in connections - std::vector>> meps; + std::vector>> meps; std::cout << MPI::rank_str() << "Reading " << ( number_of_meps != 0 ? std::to_string( number_of_meps ) : std::string{"all"} ) << " meps from files\n"; std::vector data; - gsl::span mep_span; + std::span mep_span; size_t n_meps_read = 0; std::optional packing_factor = std::nullopt; @@ -115,7 +115,7 @@ int main( int argc, char* argv[] ) { std::copy_n( mep_span.data(), mep_span.size(), contents ); ++n_meps_read; - meps.emplace_back( mep, gsl::span{contents, mep_span.size()} ); + meps.emplace_back( mep, std::span{contents, mep_span.size()} ); } if ( n_meps_read >= number_of_meps && number_of_meps != 0 ) { input.close(); diff --git a/AllenOnline/application/bench_mep_offsets.cpp b/AllenOnline/application/bench_mep_offsets.cpp index 3ef6559c4..62460c68a 100644 --- a/AllenOnline/application/bench_mep_offsets.cpp +++ b/AllenOnline/application/bench_mep_offsets.cpp @@ -81,7 +81,7 @@ std::vector contiguous_mfps( Allen::Slice const& mep_data ) { auto const& mfps = mep_data.fragments; vector mep_fragments( mep_data.fragments_mem_size, '\0' ); char* destination = &mep_fragments[0]; - for ( gsl::span mfp : mfps ) { + for ( std::span mfp : mfps ) { ::memcpy( destination, mfp.data(), mfp.size_bytes() ); destination += mfp.size_bytes(); } diff --git a/AllenOnline/include/AllenOnline/ReadMEP.h b/AllenOnline/include/AllenOnline/ReadMEP.h index df6def1d5..f43eb1f2d 100644 --- a/AllenOnline/include/AllenOnline/ReadMEP.h +++ b/AllenOnline/include/AllenOnline/ReadMEP.h @@ -4,15 +4,14 @@ #pragma once #include +#include #include -#include - #include #include #include namespace MEP { - std::tuple> + std::tuple> read_mep( LHCb::StreamDescriptor::Access& input, std::vector& buffer, MsgStream& out_stream ); } diff --git a/AllenOnline/include/AllenOnline/TransposeMEP.h b/AllenOnline/include/AllenOnline/TransposeMEP.h index e89880eb2..db90dc8a0 100644 --- a/AllenOnline/include/AllenOnline/TransposeMEP.h +++ b/AllenOnline/include/AllenOnline/TransposeMEP.h @@ -61,7 +61,7 @@ namespace MEP { struct Slice { EB::MEP const* mep = nullptr; - gsl::span mep_data; + std::span mep_data; unsigned packing_factor = 0u; Blocks blocks; SourceOffsets offsets; diff --git a/AllenOnline/src/AllenApplication.cpp b/AllenOnline/src/AllenApplication.cpp index a78430856..9fe43b54b 100644 --- a/AllenOnline/src/AllenApplication.cpp +++ b/AllenOnline/src/AllenApplication.cpp @@ -302,7 +302,7 @@ void AllenApplication::allenLoop( std::string_view config, std::string_view conf } } -void AllenApplication::update( gsl::span odin_data ) { +void AllenApplication::update( std::span odin_data ) { LHCb::ODIN odin{odin_data}; auto const run = odin.runNumber(); diff --git a/AllenOnline/src/AllenApplication.h b/AllenOnline/src/AllenApplication.h index 4c0f6c3bb..dd0d68e47 100644 --- a/AllenOnline/src/AllenApplication.h +++ b/AllenOnline/src/AllenApplication.h @@ -66,7 +66,7 @@ public: bool initMPI(); // Updater - void update( gsl::span odin_data ) override; + void update( std::span odin_data ) override; void registerConsumer( std::string const& id, std::unique_ptr c ) override; diff --git a/AllenOnline/src/MBMOutput.cpp b/AllenOnline/src/MBMOutput.cpp old mode 100755 new mode 100644 index 579b5abc5..aa943d3f9 --- a/AllenOnline/src/MBMOutput.cpp +++ b/AllenOnline/src/MBMOutput.cpp @@ -38,7 +38,7 @@ namespace Allen { StatusCode start() override; protected: - gsl::span buffer( size_t thread_id, size_t buffer_size, size_t n_events ) override; + std::span buffer( size_t thread_id, size_t buffer_size, size_t n_events ) override; bool write_buffer( size_t thread_id ) override; @@ -49,7 +49,7 @@ namespace Allen { private: struct MBMSlot { BMID id = MBM_INV_DESC; - gsl::span buffer; + std::span buffer; size_t n_events = 0; }; @@ -94,7 +94,7 @@ Allen::MBMOutput::MBMOutput( std::string name, ISvcLocator* loc ) : Service{name int Allen::MBMOutput::spaceCallback( void* /* param */ ) { return MBM_NORMAL; } -gsl::span Allen::MBMOutput::buffer( size_t thread_id, size_t buffer_size, size_t n_events ) { +std::span Allen::MBMOutput::buffer( size_t thread_id, size_t buffer_size, size_t n_events ) { if ( m_cancelled ) { return {}; } auto& slot = m_buffers[thread_id]; @@ -187,7 +187,7 @@ StatusCode Allen::MBMOutput::start() { } else { bmID = mbm_connect( m_buffers[0].id, m_processName.c_str(), m_partitionID ); } - m_buffers.emplace_back( MBMSlot{bmID, gsl::span{}, 0u} ); + m_buffers.emplace_back( MBMSlot{bmID, std::span{}, 0u} ); if ( bmID == MBM_INV_DESC ) { error() << "MBMOutput: failed to connect to MBM buffer for thread " << id << " " << connection() << endmsg; diff --git a/AllenOnline/src/MEPProvider.cpp b/AllenOnline/src/MEPProvider.cpp old mode 100755 new mode 100644 index 9ab678f46..cb5193133 --- a/AllenOnline/src/MEPProvider.cpp +++ b/AllenOnline/src/MEPProvider.cpp @@ -131,7 +131,7 @@ std::tuple MEPProvider::get_slice( s if ( !m_read_error && has_transposed() && ( !timeout || ( timeout && !timed_out ) ) ) { transposed = get_transposed(); if ( transposed->n_transposed && *( transposed->n_transposed ) > 0 ) { - odin_span = gsl::span{m_odins[transposed->slice_index]}; + odin_span = std::span{m_odins[transposed->slice_index]}; } } } @@ -227,7 +227,7 @@ void MEPProvider::slice_free( size_t slice_index ) { } } -void MEPProvider::event_sizes( size_t const slice_index, gsl::span const selected_events, +void MEPProvider::event_sizes( size_t const slice_index, std::span const selected_events, std::vector& sizes ) const { int i_buffer = 0; size_t interval_start = 0, interval_end = 0; @@ -243,7 +243,7 @@ void MEPProvider::event_sizes( size_t const slice_index, gsl::span buffer ) const { +void MEPProvider::copy_banks( size_t const slice_index, unsigned int const event, std::span buffer ) const { auto [i_buffer, interval_start, interval_end] = m_slice_to_buffer[slice_index]; const auto mep_event = interval_start + event; @@ -1228,7 +1228,7 @@ void MEPProvider::mpi_read() { break; } - slice.mep_data = gsl::span{contents, static_cast( slice.slice_size )}; + slice.mep_data = std::span{contents, static_cast( slice.slice_size )}; } // Number of full-size (MPI::mdf_chunk_size) messages @@ -1264,7 +1264,7 @@ void MEPProvider::mpi_read() { MPI_Waitall( n_sends, requests.data(), MPI_STATUSES_IGNORE ); slice.mep = reinterpret_cast( contents ); - slice.mep_data = gsl::span{contents, static_cast( mep_size )}; + slice.mep_data = std::span{contents, static_cast( mep_size )}; auto const* mep = slice.mep; auto const* mfp = mep->at( 0 ); diff --git a/AllenOnline/src/MEPProvider.h b/AllenOnline/src/MEPProvider.h index e127dc4da..5bf58655b 100644 --- a/AllenOnline/src/MEPProvider.h +++ b/AllenOnline/src/MEPProvider.h @@ -142,10 +142,10 @@ public: bool release_buffers() override; - void event_sizes( size_t const slice_index, gsl::span const selected_events, + void event_sizes( size_t const slice_index, std::span const selected_events, std::vector& sizes ) const override; - void copy_banks( size_t const slice_index, unsigned int const event, gsl::span buffer ) const override; + void copy_banks( size_t const slice_index, unsigned int const event, std::span buffer ) const override; StatusCode initialize() override; diff --git a/AllenOnline/src/ReadMEP.cpp b/AllenOnline/src/ReadMEP.cpp index da7334ce5..fb276d2ab 100644 --- a/AllenOnline/src/ReadMEP.cpp +++ b/AllenOnline/src/ReadMEP.cpp @@ -10,10 +10,9 @@ #include #include #include +#include #include -#include - #include #include #include @@ -30,7 +29,7 @@ * * @return (eof, success, mep_header, span of mep data) */ -std::tuple> +std::tuple> MEP::read_mep( LHCb::StreamDescriptor::Access& input, std::vector& buffer, MsgStream& out_stream ) { // Allocate space for the first few words of the MEP header buffer.resize( sizeof( EB::MEP_header ) ); diff --git a/AllenOnline/src/TransposeMEP.cpp b/AllenOnline/src/TransposeMEP.cpp index cc65b14f9..054fdd304 100644 --- a/AllenOnline/src/TransposeMEP.cpp +++ b/AllenOnline/src/TransposeMEP.cpp @@ -12,7 +12,7 @@ namespace { template - T* event_entries( gsl::span offsets, unsigned const event ) { + T* event_entries( std::span offsets, unsigned const event ) { return reinterpret_cast( &offsets[0] ) + offsets[event]; } } // namespace diff --git a/cmake/MooreOnlineDependencies.cmake b/cmake/MooreOnlineDependencies.cmake index 6406337cd..bf0011f2f 100644 --- a/cmake/MooreOnlineDependencies.cmake +++ b/cmake/MooreOnlineDependencies.cmake @@ -34,7 +34,6 @@ pkg_check_modules(sodium libsodium REQUIRED IMPORTED_TARGET) if(WITH_MooreOnline_PRIVATE_DEPENDENCIES) find_package(Python REQUIRED Interpreter) find_package(MPI QUIET COMPONENTS C CXX) - find_package(cppgsl REQUIRED) find_package(Boost REQUIRED program_options) pkg_check_modules(hwloc QUIET IMPORTED_TARGET hwloc) -- GitLab