From 5dbf9569d3ac505c74d564e93486e75cda050c47 Mon Sep 17 00:00:00 2001 From: Default Online user <Markus.Frank@cern.ch> Date: Thu, 19 Aug 2021 11:36:06 +0200 Subject: [PATCH] Fix tests. Update NUMA controls and adapt to Python 3.7 --- Online/Dataflow/options/NumaTest.opts | 2 +- .../Dataflow/src/components/NumaControl.cpp | 65 +++-- .../qmtest/dataflow.qms/01_numa_test.qmt | 2 +- .../GaudiOnline/components/NumaControlSvc.cpp | 41 ++- .../GaudiOnlineTests/components/GaudiMain.cpp | 77 +++++ .../scripts/go_test_CreateMEP.sh | 2 +- Online/GaudiOnlineTests/src/scr_test.cpp | 1 + Online/OnlineBase/src/LOG/FifoLog_module.cpp | 7 +- Online/OnlineBase/src/SCR/MouseSensor.cpp | 13 +- Online/OnlineBase/src/SCR/ScrDisplay.cpp | 4 +- Online/OnlineBase/src/SCR/listr.cpp | 2 +- Online/OnlineBase/src/SCR/lists.cpp | 2 +- Online/OnlineBase/src/SCR/scr.cpp | 2 +- Online/OnlineBase/src/SCR/scr_ansi.cpp | 10 +- Online/OnlineBase/src/SCR/scr_recorder.cpp | 8 +- Online/OnlineBase/src/SCR/scr_test.cpp | 267 ------------------ Online/OnlineBase/src/SCR/scr_window.cpp | 3 +- Online/OnlineBase/src/SCR/scrcc.cpp | 2 +- Online/OnlineBase/src/TAN/TanDB.cpp | 14 +- Online/OnlineBase/src/TAN/TanDB_Dump.cpp | 19 +- Online/OnlineBase/src/TAN/TanDB_tst.cpp | 20 +- Online/OnlineBase/src/TAN/TanInterface.cpp | 24 +- Online/OnlineBase/src/TAN/TanMon.cpp | 19 +- Online/OnlineBase/src/TAN/tan_alloc_tst.cpp | 4 +- Online/OnlineBase/src/TAN/tan_inquire_tst.cpp | 24 +- Online/OnlineBase/src/WT/wtlib.cpp | 6 +- Online/OnlineBase/src/WT/wttest.cpp | 6 +- Online/OnlineKernel/dict/PyInteractor.cpp | 4 +- Online/PyDIM/src/dimcppmodule.cpp | 2 + Online/PyDIM/src/dimmodule.cpp | 7 +- Online/RawBankSizes/CMakeLists.txt | 3 - 31 files changed, 290 insertions(+), 372 deletions(-) create mode 100644 Online/GaudiOnlineTests/components/GaudiMain.cpp delete mode 100644 Online/OnlineBase/src/SCR/scr_test.cpp diff --git a/Online/Dataflow/options/NumaTest.opts b/Online/Dataflow/options/NumaTest.opts index 6af762b77..e31b8959b 100644 --- a/Online/Dataflow/options/NumaTest.opts +++ b/Online/Dataflow/options/NumaTest.opts @@ -3,7 +3,7 @@ Manager.Services = {"Dataflow_NumastatPlugin/Numastat","Dataflow_NumaControl Numa.When = "(initialize)"; Numa.BindCPU = true; Numa.BindMemory = true; -Numa.CPUSlots = [0]; +Numa.CPUMask = [1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]; Numa.Print = "(all)(result)"; Numastat.When = "(initialize) (start)"; Logger.OutputLevel = @OnlineEnv.OutputLevel; diff --git a/Online/Dataflow/src/components/NumaControl.cpp b/Online/Dataflow/src/components/NumaControl.cpp index c3a45470b..e7e7f24ac 100644 --- a/Online/Dataflow/src/components/NumaControl.cpp +++ b/Online/Dataflow/src/components/NumaControl.cpp @@ -18,7 +18,7 @@ #define ONLINE_DATAFLOW_NUMACONTROL_H // Framework include files -#include "Dataflow/DataflowComponent.h" +#include <Dataflow/DataflowComponent.h> // C/C++ include files #include <vector> @@ -41,6 +41,7 @@ namespace Online { /// Property: String representation of the key to be added to the event context std::string when; std::vector<int> cpuSlots {}; + std::vector<int> cpuMask {}; bool bindCPU = true; bool bindMemory = true; @@ -85,12 +86,13 @@ namespace Online { //========================================================================== /// Framework includes -#include "Dataflow/Plugins.h" -#include "DD4hep/Primitives.h" -#include "RTL/strdef.h" -#include "RTL/rtl.h" +#include <Dataflow/Plugins.h> +#include <DD4hep/Primitives.h> +#include <RTL/strdef.h> +#include <RTL/rtl.h> #include <cerrno> +#include <set> using namespace std; using namespace Online; @@ -105,6 +107,7 @@ NumaControl::NumaControl(const string& nam, Context& ctxt) declareProperty("BindCPU", bindCPU); declareProperty("BindMemory", bindMemory); declareProperty("CPUSlots", cpuSlots); + declareProperty("CPUMask", cpuMask); declareProperty("Print", printOption); } @@ -208,26 +211,20 @@ void NumaControl::printSettings() const { /// Apply NUMA configuration settings according to job options void NumaControl::apply_numa_config() { - if ( cpuSlots.empty() ) { - return; - } if ( -1 == numa_available() ) { warning("Numa is not available on this node. No settings applied."); return; } + if ( cpuSlots.empty() && cpuMask.empty() ) { + return; + } string opt = RTL::str_lower(printOption); - bitmask* nm = ::numa_allocate_nodemask(); - bitmask* nmfree = ::numa_allocate_nodemask(); - bitmask* cm = ::numa_allocate_cpumask(); - ::numa_bitmask_clearall(nm); - ::numa_bitmask_clearall(cm); /// Now optional printout if ( opt.find("all") != string::npos ) printSettings(); if ( opt.find("initial") != string::npos ) printStatus(); /// Setup the bitmasks for the nodes to run on: - bitmask* cmtmp = ::numa_allocate_cpumask(); int task_nodes = ::numa_num_task_nodes(); bool bad_config = false; for(auto i : cpuSlots ) { @@ -240,16 +237,35 @@ void NumaControl::apply_numa_config() { warning("Abort NUMA binding due to bad configuration."); return; } - for(int i : cpuSlots ) { - ::numa_bitmask_clearall(cmtmp); - ::numa_node_to_cpus(i,cmtmp); - for(size_t b=0; b<cmtmp->size; ++b) { - if ( ::numa_bitmask_isbitset(cmtmp,b) ) { - ::numa_bitmask_setbit(cm,b); + bitmask* nm = ::numa_allocate_nodemask(); + bitmask* nmfree = ::numa_allocate_nodemask(); + bitmask* cm = ::numa_allocate_cpumask(); + ::numa_bitmask_clearall(nm); + ::numa_bitmask_clearall(cm); + ::numa_bitmask_clearall(nmfree); + if ( !cpuMask.empty() ) { + std::set<int> slots; + for(size_t i=0; i < cpuMask.size(); ++i ) { + if ( cpuMask[i] != 0 ) { + int node = ::numa_node_of_cpu(i); + ::numa_bitmask_setbit(cm, i); + ::numa_bitmask_setbit(nm, node); + slots.insert(node); + } + } + cpuSlots.clear(); + for(int i : slots) { + cpuSlots.push_back(i); + } + } + else if ( !cpuSlots.empty() ) { + ::numa_bitmask_clearall(cm); + for(int i : cpuSlots ) { + if ( 0 == ::numa_node_to_cpus(i,cm) ) { + ::numa_bitmask_setbit(nm, i); } } } - ::numa_bitmask_free(cmtmp); /// Setup the bitmask with all the nodes to free when migrating pages: ::numa_bitmask_clearall(nmfree); @@ -258,6 +274,7 @@ void NumaControl::apply_numa_config() { ::numa_bitmask_setbit(nmfree,b); } } + int ret; /// Propagate the CPU bindings unless switched off if ( bindCPU ) { @@ -265,12 +282,12 @@ void NumaControl::apply_numa_config() { info("| Set numa affinity mask to: %s",c_mask(cm).c_str()); ret = ::numa_run_on_node_mask(nm); if ( ret != 0 ) { - warning("NUMA failed bind task to CPU slots %s: [%s]", + warning("FAIL: NUMA failed bind task to CPU slots %s: [%s]", c_mask(nm).c_str(), RTL::errorString().c_str()); } ret = ::numa_sched_setaffinity(::lib_rtl_pid(),cm); if ( ret != 0 ) { - warning("NUMA failed set task affinity to mask %s: [%s]", + warning("FAIL: NUMA failed set task affinity to mask %s: [%s]", c_mask(cm).c_str(), RTL::errorString().c_str()); } } @@ -280,7 +297,7 @@ void NumaControl::apply_numa_config() { ::numa_set_membind(nm); ret = ::numa_migrate_pages(::lib_rtl_pid(), nmfree, nm); if ( ret != 0 ) { - warning("NUMA failed to migrate pages: %s",RTL::errorString().c_str()); + warning("FAIL: NUMA failed to migrate pages: %s",RTL::errorString().c_str()); } } ::numa_bitmask_free(cm); diff --git a/Online/Dataflow/tests/qmtest/dataflow.qms/01_numa_test.qmt b/Online/Dataflow/tests/qmtest/dataflow.qms/01_numa_test.qmt index 2e8d2af0b..44a2fdc03 100644 --- a/Online/Dataflow/tests/qmtest/dataflow.qms/01_numa_test.qmt +++ b/Online/Dataflow/tests/qmtest/dataflow.qms/01_numa_test.qmt @@ -11,7 +11,7 @@ </set></argument> <argument name="unsupported_platforms"><set><text>win.*</text></set></argument> <argument name="validator"><text> -expected_string = "numa_sched_getaffinity: 1111111100000000000000000000000000000000000000000000000000000000" +expected_string = "numa_sched_getaffinity: 1010101000000000000000000000000000000000000000000000000000000000" if stdout.find(expected_string) == -1: causes.append('missing string') result['GaudiTest.expected_string'] = result.Quote(expected_string) diff --git a/Online/GaudiOnline/components/NumaControlSvc.cpp b/Online/GaudiOnline/components/NumaControlSvc.cpp index 88b3e9700..3013ae3dc 100644 --- a/Online/GaudiOnline/components/NumaControlSvc.cpp +++ b/Online/GaudiOnline/components/NumaControlSvc.cpp @@ -45,6 +45,7 @@ namespace Online { /// Property: String representation of the key to be added to the event context std::string when; std::vector<int> cpuSlots {}; + std::vector<int> cpuMask {}; bool bindCPU = true; bool bindMemory = true; @@ -108,6 +109,7 @@ NumaControlSvc::NumaControlSvc(const string& nam, ISvcLocator* ctxt) declareProperty("BindCPU", bindCPU); declareProperty("BindMemory", bindMemory); declareProperty("CPUSlots", cpuSlots); + declareProperty("CPUMask", cpuMask); declareProperty("Print", printOption); } @@ -181,29 +183,40 @@ void NumaControlSvc::apply_numa_config() { return; } string opt = RTL::str_lower(printOption); + /// Now optional printout + if ( opt.find("all") != string::npos ) printSettings(); + if ( opt.find("initial") != string::npos ) printStatus(); + + /// Setup the bitmasks for the nodes to run on: bitmask* nm = ::numa_allocate_nodemask(); bitmask* nmfree = ::numa_allocate_nodemask(); bitmask* cm = ::numa_allocate_cpumask(); ::numa_bitmask_clearall(nm); ::numa_bitmask_clearall(cm); - /// Now optional printout - if ( opt.find("all") != string::npos ) printSettings(); - if ( opt.find("initial") != string::npos ) printStatus(); - - /// Setup the bitmasks for the nodes to run on: - bitmask* cmtmp = ::numa_allocate_cpumask(); - for(int i : cpuSlots ) { - ::numa_bitmask_clearall(cmtmp); - ::numa_node_to_cpus(i,cmtmp); - ::numa_bitmask_setbit(nm,i); - for(size_t b=0; b<cmtmp->size; ++b) { - if ( ::numa_bitmask_isbitset(cmtmp,b) ) { - ::numa_bitmask_setbit(cm,b); + if ( !cpuMask.empty() ) { + std::set<int> slots; + for(size_t i=0; i < cpuMask.size(); ++i ) { + if ( cpuMask[i] != 0 ) { + int node = ::numa_node_of_cpu(i); + ::numa_bitmask_setbit(cm, i); + ::numa_bitmask_setbit(nm, node); + slots.insert(node); + } + } + cpuSlots.clear(); + for(int i : slots) { + cpuSlots.push_back(i); + } + } + else if ( !cpuSlots.empty() ) { + ::numa_bitmask_clearall(cm); + for(int i : cpuSlots ) { + if ( 0 == ::numa_node_to_cpus(i,cm) ) { + ::numa_bitmask_setbit(nm, i); } } } - ::numa_bitmask_free(cmtmp); /// Setup the bitmask with all the nodes to free when migrating pages: ::numa_bitmask_clearall(nmfree); diff --git a/Online/GaudiOnlineTests/components/GaudiMain.cpp b/Online/GaudiOnlineTests/components/GaudiMain.cpp new file mode 100644 index 000000000..1ed0a0895 --- /dev/null +++ b/Online/GaudiOnlineTests/components/GaudiMain.cpp @@ -0,0 +1,77 @@ +//========================================================================== +// LHCb Online software suite +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see OnlineSys/LICENSE. +// +// Author : M.Frank +// +//========================================================================== +#include <Gaudi/Application.h> +#include <gsl/span> +#include <iostream> +#include <string_view> +#include <type_traits> + +extern "C" GAUDI_API int GaudiMain( int argc, char** argv ) { + Gaudi::Application::Options opts; + + std::string_view appType{"Gaudi::Application"}; + std::string_view optsFile; + + gsl::span args{argv, static_cast<std::remove_cv_t<decltype( gsl::dynamic_extent )>>( argc )}; + + auto usage = [name = args[0]]( std::ostream& out ) -> std::ostream& { + return out << "usage: " << name << " [options] option_file\n"; + }; + + auto arg = args.begin(); + ++arg; // ignore application name + while ( arg != args.end() ) { + std::string_view opt{*arg}; + if ( opt == "--application" ) + appType = *++arg; + else if ( opt == "-h" || opt == "--help" ) { + usage( std::cout ); + std::cout << R"( +Options: + -h, --help show this help message and exit + --application APPLICATION + name of the application class to use [default: Gaudi::Application] +)"; + return EXIT_SUCCESS; + } else if ( opt[0] == '-' ) { + std::cerr << "error: unknown option " << opt << '\n'; + usage( std::cerr ); + return EXIT_FAILURE; + } else { + optsFile = *arg++; + break; // we stop after the first positional argument + } + ++arg; + } + if ( arg != args.end() ) { std::cerr << "warning: ignoring extra positional arguments\n"; } + if ( optsFile.empty() ) { + std::cerr << "error: missing option file argument\n"; + usage( std::cerr ); + return EXIT_FAILURE; + } + + if ( optsFile.size() > 3 && optsFile.substr( optsFile.size() - 3 ) == ".py" ) { + opts["ApplicationMgr.EvtSel"] = "NONE"; + opts["ApplicationMgr.JobOptionsType"] = "NONE"; + opts["ApplicationMgr.DLLs"] = "['GaudiPython']"; + opts["ApplicationMgr.Runable"] = "PythonScriptingSvc"; + } else { + opts["ApplicationMgr.JobOptionsPath"] = optsFile; + } + + auto app = Gaudi::Application::create( appType, std::move( opts ) ); + if ( !app ) { + std::cerr << "error: failure creating " << appType << '\n'; + return EXIT_FAILURE; + } + return app->run(); +} diff --git a/Online/GaudiOnlineTests/scripts/go_test_CreateMEP.sh b/Online/GaudiOnlineTests/scripts/go_test_CreateMEP.sh index 8a5ad8339..3bfa70254 100755 --- a/Online/GaudiOnlineTests/scripts/go_test_CreateMEP.sh +++ b/Online/GaudiOnlineTests/scripts/go_test_CreateMEP.sh @@ -40,7 +40,7 @@ Writer_0.OutputLevel = 2; END-OF-OPTS # cat ${opts_file}; -`which gentest.exe` libGaudiKernel.so GaudiMain ${opts_file}; +`which gentest.exe` libGaudiOnlineTestsComp.so GaudiMain ${opts_file}; if test -f ${opts_file}; then rm ${opts_file}; fi; diff --git a/Online/GaudiOnlineTests/src/scr_test.cpp b/Online/GaudiOnlineTests/src/scr_test.cpp index 05c72c641..892ba20dd 100755 --- a/Online/GaudiOnlineTests/src/scr_test.cpp +++ b/Online/GaudiOnlineTests/src/scr_test.cpp @@ -246,6 +246,7 @@ extern "C" int scr_test(int argc, char** argv) { ::printf("\n\n\n +---------------------------------------+\n"); ::printf(" | It looks like SCR seems to work |\n"); ::printf(" +---------------------------------------+\n\n\n"); + ::lib_rtl_sleep(1000); return 0; } diff --git a/Online/OnlineBase/src/LOG/FifoLog_module.cpp b/Online/OnlineBase/src/LOG/FifoLog_module.cpp index 6c1932535..b39b31f49 100644 --- a/Online/OnlineBase/src/LOG/FifoLog_module.cpp +++ b/Online/OnlineBase/src/LOG/FifoLog_module.cpp @@ -175,12 +175,13 @@ PyMODINIT_FUNC PyInit__fifo_log(void) PyMODINIT_FUNC init_fifo_log(void) #endif { - PyObject *m; +#if PY_MAJOR_VERSION <=2 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 7) PyEval_InitThreads(); +#endif #if PY_MAJOR_VERSION >= 3 - m = ::PyModule_Create(&logger_module); + PyObject *m = ::PyModule_Create(&logger_module); #else - m = Py_InitModule3("_fifo_log", LoggerMethods, "Logger methods"); + PyObject *m = Py_InitModule3("_fifo_log", LoggerMethods, "Logger methods"); #endif if (m == NULL) { PyMODINIT_RETURN(m); diff --git a/Online/OnlineBase/src/SCR/MouseSensor.cpp b/Online/OnlineBase/src/SCR/MouseSensor.cpp index 949681a1b..07401987e 100644 --- a/Online/OnlineBase/src/SCR/MouseSensor.cpp +++ b/Online/OnlineBase/src/SCR/MouseSensor.cpp @@ -7,13 +7,14 @@ // For the licensing terms see OnlineSys/LICENSE. // //========================================================================== + // Framework include files -#include "SCR/MouseSensor.h" -#include "CPP/Interactor.h" -#include "SCR/scr.h" -#include "WT/wtdef.h" -#include "CPP/Event.h" -#include "RTL/SysTime.h" +#include <SCR/MouseSensor.h> +#include <CPP/Interactor.h> +#include <SCR/scr.h> +#include <WT/wtdef.h> +#include <CPP/Event.h> +#include <RTL/SysTime.h> using namespace SCR; typedef unsigned char uc8; diff --git a/Online/OnlineBase/src/SCR/ScrDisplay.cpp b/Online/OnlineBase/src/SCR/ScrDisplay.cpp index b6df710a9..22f606e66 100644 --- a/Online/OnlineBase/src/SCR/ScrDisplay.cpp +++ b/Online/OnlineBase/src/SCR/ScrDisplay.cpp @@ -13,8 +13,8 @@ /* */ /*-----------------------------------------------------------------------*/ #include <cstdio> -#include "SCR/scr.h" -#include "SCR/ScrDisplay.h" +#include <SCR/scr.h> +#include <SCR/ScrDisplay.h> #ifdef _WIN32 #define vsnprintf _vsnprintf diff --git a/Online/OnlineBase/src/SCR/listr.cpp b/Online/OnlineBase/src/SCR/listr.cpp index 086a12665..ba9a54ec5 100644 --- a/Online/OnlineBase/src/SCR/listr.cpp +++ b/Online/OnlineBase/src/SCR/listr.cpp @@ -13,7 +13,7 @@ */ #define __LISTS_C__ -#include "SCR/lists.h" +#include <SCR/lists.h> #include <cstdlib> diff --git a/Online/OnlineBase/src/SCR/lists.cpp b/Online/OnlineBase/src/SCR/lists.cpp index 9c8039a69..c49e12248 100644 --- a/Online/OnlineBase/src/SCR/lists.cpp +++ b/Online/OnlineBase/src/SCR/lists.cpp @@ -15,7 +15,7 @@ /*---------------------------------------------------------------------------*/ #define __LISTS_C__ #include <cstdlib> -#include "SCR/lists.h" +#include <SCR/lists.h> /*---------------------------------------------------------------------------*/ void list_init (Linked_list* _list) { diff --git a/Online/OnlineBase/src/SCR/scr.cpp b/Online/OnlineBase/src/SCR/scr.cpp index d4349c0f3..3a3270d41 100644 --- a/Online/OnlineBase/src/SCR/scr.cpp +++ b/Online/OnlineBase/src/SCR/scr.cpp @@ -10,7 +10,7 @@ #include <cstdio> #include <cstdlib> #include <cstring> -#include "SCR/scr.h" +#include <SCR/scr.h> using namespace SCR; diff --git a/Online/OnlineBase/src/SCR/scr_ansi.cpp b/Online/OnlineBase/src/SCR/scr_ansi.cpp index 7440a2518..6a3b01d3e 100644 --- a/Online/OnlineBase/src/SCR/scr_ansi.cpp +++ b/Online/OnlineBase/src/SCR/scr_ansi.cpp @@ -9,21 +9,21 @@ //========================================================================== #ifdef _WIN32 #include <io.h> -#include "RTL/conioex.h" +#include <RTL/conioex.h> #else #include <sys/ioctl.h> #include <unistd.h> #include <cerrno> -#include "termios.h" +#include <termios.h> static struct termios neu, alt; #endif #include <cstdio> #include <cstdlib> #include <cstring> -#include "SCR/scr.h" -#include "WT/wtdef.h" -#include "NET/IOPortManager.h" +#include <SCR/scr.h> +#include <WT/wtdef.h> +#include <NET/IOPortManager.h> using namespace SCR; diff --git a/Online/OnlineBase/src/SCR/scr_recorder.cpp b/Online/OnlineBase/src/SCR/scr_recorder.cpp index 9fcc5ad75..9f6d46460 100644 --- a/Online/OnlineBase/src/SCR/scr_recorder.cpp +++ b/Online/OnlineBase/src/SCR/scr_recorder.cpp @@ -10,10 +10,10 @@ #include <ctime> #include <cstdio> #include <cstring> -#include "SCR/scr.h" -#include "CPP/Event.h" -#include "CPP/Interactor.h" -#include "SCR/MouseSensor.h" +#include <SCR/scr.h> +#include <CPP/Event.h> +#include <CPP/Interactor.h> +#include <SCR/MouseSensor.h> using namespace SCR; diff --git a/Online/OnlineBase/src/SCR/scr_test.cpp b/Online/OnlineBase/src/SCR/scr_test.cpp deleted file mode 100644 index cd35710dd..000000000 --- a/Online/OnlineBase/src/SCR/scr_test.cpp +++ /dev/null @@ -1,267 +0,0 @@ -//========================================================================== -// LHCb Online software suite -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see OnlineSys/LICENSE. -// -//========================================================================== -#include <cstdio> -#include <cstring> -#include "SCR/scr.h" -#include "RTL/rtl.h" -using namespace SCR; -#ifdef _WIN32 -#define popen _popen -#endif -static Pasteboard* pb; -typedef Display* PDisplay; -static PDisplay d0, d1, d2, d3, d4, d5; - -#if 0 // not used -static void broadcast_handler (char* message) { - scrc_begin_pasteboard_update (pb); - scrc_put_chars (d5, message, NORMAL, 1, 1, 1); - scrc_end_pasteboard_update (pb); -} -#endif - -static bool s_showMem = true; -static int show_memory() { - int memory; - char text[64]; - int i; - static int n = 0; - if ( s_showMem ) { - ::scrc_begin_pasteboard_update (pb); - memory = ::scrc_memory_of_pasteboard (pb); - snprintf(text,sizeof(text), "Pb:%d", memory); - ::scrc_put_chars (d4, text, NORMAL, 1, 1, 1); - memory = ::scrc_memory_of_display (d0); - snprintf(text,sizeof(text), "D0:%d", memory); - ::scrc_put_chars (d4, text, NORMAL|CYAN, 2, 1, 1); - memory = ::scrc_memory_of_display (d1); - snprintf(text,sizeof(text), "D1:%d", memory); - ::scrc_put_chars (d4, text, NORMAL|MAGENTA, 3, 1, 1); - memory = ::scrc_memory_of_display (d2); - snprintf(text,sizeof(text), "D2:%d", memory); - ::scrc_put_chars (d4, text, NORMAL, 4, 1, 1); - memory = ::scrc_memory_of_display (d3); - snprintf(text,sizeof(text), "D3:%d", memory); - ::scrc_put_chars (d4, text, 0x200|RED, 5, 1, 1); - memory = ::scrc_memory_of_display (d4); - snprintf(text,sizeof(text), "D4:%d", memory); - ::scrc_put_chars (d4, text, BOLD|INVERSE|RED, 6, 1, 1); - memory = ::scrc_memory_of_display (d5); - snprintf(text,sizeof(text), "D5:%d", memory); - ::scrc_put_chars (d5, text, NORMAL, 7, 1, 1); - - for (i=0; i<n; i++) ::scrc_put_char (d4, '.', INVERSE|BLUE, 8, i+1); - for (; i<10; i++) ::scrc_put_char (d4, ' ', NORMAL, 8, i+1); - n++; - if (n >= 10) n = 0; - ::scrc_end_pasteboard_update (pb); - } - return 1; -} - -static void end_update (Pasteboard* pb) { - ::scrc_end_pasteboard_update (pb); - ::scrc_fflush (pb); -} - -static void wait_next() { - end_update (pb); - show_memory(); - ::scrc_set_cursor (d3, 1, 1); - ::scrc_wait(d3); -} - -static void help() {} - -extern "C" int scr_test(int argc, char** argv) { - int i, pb_rows = 0, pb_cols = 80; - char text[128], font[80]; - const char *device = 0; - std::string arg; - RTL::CLI cli(argc, argv, help); - cli.getopt("font",1,arg="tcs.font"); - ::strcpy (font, arg.c_str()); - s_showMem = cli.getopt("nomemory",1) == 0; - device = cli.getopt("device",1); - - ::scrc_create_pasteboard (&pb, device, &pb_rows, &pb_cols); - - // init_timer (show_memory); - // ::scrc_set_broadcast_trapping (pb, broadcast_handler); - - ::scrc_create_display (&d0, 11, 20, INVERSE|BLUE, ON, " display 0 "); - ::scrc_create_display (&d1, 15, 20, NORMAL, ON, " display 1 "); - ::scrc_create_display (&d2, 15, 30, NORMAL|CYAN, ON, " display 2 "); - ::scrc_create_display (&d3, 1, 50, BOLD|RED|INVERSE, ON, " Doing : "); - ::scrc_create_display (&d4, 8, 32, INVERSE, ON, " Memory "); - ::scrc_create_display (&d5, 1, 15, BOLD, ON, " Messages "); - - ::scrc_paste_display (d3, pb, 2, 20); - ::scrc_paste_display (d4, pb, 15, 65); - ::scrc_paste_display (d5, pb, 20, 40); - snprintf(text,sizeof(text),"Create displays:%X",RED); - ::scrc_put_chars (d3, text, NORMAL|MAGENTA, 1, 1, 1); - end_update (pb); - - wait_next(); - - ::scrc_begin_pasteboard_update (pb); - ::scrc_paste_display (d0, pb, 2, 2); - ::scrc_paste_display (d1, pb, 5, 5); - ::scrc_paste_display (d2, pb, 8, 17); - ::scrc_paste_display (d3, pb, 2, 20); - end_update (pb); - - for (i=1;i<=10;i++) { - snprintf(text,sizeof(text), "%d----------", i); - ::scrc_put_chars (d0, text,BOLD|INVERSE|MAGENTA, i, 1, 1); - } - for (i=13;i<=15;i++) { - snprintf(text,sizeof(text), "%d............", i); - ::scrc_put_chars (d1, text, NORMAL, i, 1, 1); - } - for (i=1;i<=15;i++) { - snprintf(text,sizeof(text), "%d", i); - if ( (i%2) == 0 ) - ::scrc_put_chars (d2, text, BOLD|BLUE, i, 1, 1); - else - ::scrc_put_chars (d2, text, INVERSE|RED, i, 1, 1); - } - - ::scrc_put_chars (d1, "normal", NORMAL, 1, 1, 1); - ::scrc_put_chars (d1, "underline", UNDERLINE, 2, 1, 1); - ::scrc_put_chars (d1, "inverse", INVERSE, 3, 1, 1); - ::scrc_put_chars (d1, "bold", BOLD, 4, 1, 1); - // ::scrc_put_chars (d1, "graphic : ", NORMAL, 5, 1, 0); - // ::scrc_put_chars (d1, "abcdefghijkl", GRAPHIC, 5, 11, 0); - ::scrc_put_chars (d1, "dec_sup : ", NORMAL, 6, 1, 0); - ::scrc_put_chars (d1, "abcdefghijkl", FONT_SUPP, 6, 11, 0); - ::scrc_load_font (pb, font); - ::scrc_put_chars (d1, "user : ", NORMAL, 7, 1, 0); - ::scrc_put_chars (d1, "abcdefghijkl", FONT_USER, 7, 11, 0); - ::scrc_put_chars (d1, "RED : ", RED, 8, 1, 0); - ::scrc_put_chars (d1, "abcdefghijkl", INVERSE|RED, 8, 11, 0); - ::scrc_put_chars (d1, "GREEN : ", GREEN, 9, 1, 0); - ::scrc_put_chars (d1, "abcdefghijkl", INVERSE|GREEN, 9, 11, 0); - ::scrc_put_chars (d1, "BLUE : ", BLUE, 10, 1, 0); - ::scrc_put_chars (d1, "abcdefghijkl", INVERSE|BLUE, 10, 11, 0); - ::scrc_put_chars (d1, "MAGENTA: ", MAGENTA, 11, 1, 0); - ::scrc_put_chars (d1, "abcdefghijkl", INVERSE|MAGENTA, 11, 11, 0); - ::scrc_put_chars (d1, "RED : ", BOLD|RED, 12, 1, 0); - ::scrc_put_chars (d1, "abcdefghijkl", BOLD|INVERSE|RED, 12, 11, 0); - - wait_next(); - - ::scrc_put_chars (d3, "Move display 1", NORMAL|RED, 1, 1, 1); - end_update (pb); - - for (i=6; i<20; i+=4) ::scrc_move_display (d1, pb, 4, 4); - for (i=20; i<40; i+=4) ::scrc_move_display (d1, pb, -4, 4); - wait_next(); - - ::scrc_put_chars (d3, "Repaste display 0", NORMAL|BLUE, 1, 1, 1); - end_update (pb); - - ::scrc_begin_pasteboard_update (pb); - ::scrc_paste_display (d0, pb, 2, 2); - ::scrc_paste_display (d3, pb, 2, 20); - wait_next(); - - ::scrc_put_chars (d3, "Bring it to back", NORMAL|CYAN|INVERSE, 1, 1, 1); - end_update (pb); - - ::scrc_begin_pasteboard_update (pb); - ::scrc_bring_display_to_back (d0, pb); - ::scrc_paste_display (d3, pb, 2, 20); - wait_next(); - - ::scrc_put_chars (d3, "And drag it", NORMAL|YELLOW|INVERSE, 1, 1, 1); - end_update (pb); - - for (i=3; i<20; i+=4) ::scrc_move_display (d0, pb, 4, 4); - for (i=20; i<50; i+=4) ::scrc_move_display (d0, pb, -4, 4); - ::scrc_begin_pasteboard_update (pb); - for (i=50; i>1; i-=4) ::scrc_move_display (d0, pb, 2, -4); - wait_next(); - - ::scrc_put_chars (d3, "Repaste display 2", NORMAL|GREEN, 1, 1, 1); - end_update (pb); - - ::scrc_begin_pasteboard_update (pb); - ::scrc_paste_display (d2, pb, 15, 15); - ::scrc_paste_display (d3, pb, 2, 20); - wait_next(); - - ::scrc_put_chars (d3, "And change it", NORMAL, 1, 1, 1); - end_update (pb); - - for (i=29; i>5; i -= 4) - ::scrc_change_display (d2, i, i); - wait_next(); - - ::scrc_begin_pasteboard_update (pb); - ::scrc_paste_display (d0, pb, 2, 2); - ::scrc_paste_display (d3, pb, 2, 20); - end_update (pb); - - ::scrc_put_chars (d3, "Delete lines in display 0", NORMAL, 1, 1, 1); - end_update (pb); - - ::scrc_delete_line (d0, 10); - ::scrc_delete_line (d0, 5); - ::scrc_delete_line (d0, 1); - wait_next(); - - ::scrc_put_chars(d3,"Insert lines in display 0 with scroll down",NORMAL,1,1,1); - end_update (pb); - - ::scrc_insert_line (d0, "new line 1 ", NORMAL, 1, MOVE_DOWN); - ::scrc_insert_line (d0, "new line 5 ", CYAN, 5, MOVE_DOWN); - ::scrc_insert_line (d0, "new line 10 ",CYAN, 10, MOVE_DOWN); - ::scrc_insert_line (d0, "new line 11 ",GREEN, 11, MOVE_DOWN); - wait_next(); - - ::scrc_put_chars(d3,"Insert lines in display 0 with scroll up",NORMAL,1,1,1); - end_update (pb); - - ::scrc_insert_line(d0,"new line 1 ", NORMAL, 1, MOVE_DOWN); - ::scrc_insert_line(d0,"new line 5 ", NORMAL|YELLOW|INVERSE, 5, MOVE_UP); - ::scrc_insert_line(d0,"new line 10 ",NORMAL|RED,10, MOVE_UP); - wait_next(); - - ::scrc_put_chars (d3, "Exit", NORMAL|BOLD|BLUE, 1, 1, 1); - wait_next(); - ::scrc_clear_screen(pb); - ::scrc_delete_pasteboard(pb); - ::scrc_resetANSI(); - ::printf("\n\n\n +---------------------------------------+\n"); - ::printf(" | It looks like SCR seems to work |\n"); - ::printf(" +---------------------------------------+\n\n\n"); - return 0; -} - -#include <csignal> -extern "C" int scr_qmtest(int /* argc */, char** /* argv */) { - struct sigaction act; - sigemptyset(&act.sa_mask); - act.sa_handler = SIG_IGN; - act.sa_sigaction = 0; - act.sa_flags = SA_SIGINFO; - ::sigaction(SIGPIPE, &act, nullptr); - - FILE* input = ::popen("test.exe scr_test -nomemory","w"); - for(size_t i=0; i<13; ++i) { - ::fwrite("\n",2,1,input); - ::fflush(input); - ::lib_rtl_sleep(500); - } - ::pclose(input); - return 0; -} diff --git a/Online/OnlineBase/src/SCR/scr_window.cpp b/Online/OnlineBase/src/SCR/scr_window.cpp index 372b27ff3..2812299ad 100644 --- a/Online/OnlineBase/src/SCR/scr_window.cpp +++ b/Online/OnlineBase/src/SCR/scr_window.cpp @@ -13,7 +13,8 @@ */ #include <cstring> -#include "SCR/scr.h" +#include <SCR/scr.h> + using namespace SCR; enum { diff --git a/Online/OnlineBase/src/SCR/scrcc.cpp b/Online/OnlineBase/src/SCR/scrcc.cpp index 5a0600b68..dbcc4fd3e 100644 --- a/Online/OnlineBase/src/SCR/scrcc.cpp +++ b/Online/OnlineBase/src/SCR/scrcc.cpp @@ -7,7 +7,7 @@ // For the licensing terms see OnlineSys/LICENSE. // //========================================================================== -#include "SCR/scrcc.h" +#include <SCR/scrcc.h> using namespace SCR; //--------------------------------------------------------------------------- diff --git a/Online/OnlineBase/src/TAN/TanDB.cpp b/Online/OnlineBase/src/TAN/TanDB.cpp index 1bcd40b2d..923ba8ba6 100755 --- a/Online/OnlineBase/src/TAN/TanDB.cpp +++ b/Online/OnlineBase/src/TAN/TanDB.cpp @@ -20,13 +20,13 @@ #include <cstring> #include <vector> -#include "NET/defs.h" -#include "CPP/PubArea.h" -#include "CPP/XMLStream.h" -#include "TAN/TanDB.h" -#include "TAN/TanErrno.h" -#include "RTL/rtl.h" -#include "RTL/Lock.h" +#include <NET/defs.h> +#include <CPP/PubArea.h> +#include <CPP/XMLStream.h> +#include <TAN/TanDB.h> +#include <TAN/TanErrno.h> +#include <RTL/rtl.h> +#include <RTL/Lock.h> #define NAMESERVICE_PUBAREA_SIZE ((int)(sizeof(TanPaSlot)+sizeof(TanPaSlot)/2)) diff --git a/Online/OnlineBase/src/TAN/TanDB_Dump.cpp b/Online/OnlineBase/src/TAN/TanDB_Dump.cpp index 6f9058e84..bea42e4f1 100755 --- a/Online/OnlineBase/src/TAN/TanDB_Dump.cpp +++ b/Online/OnlineBase/src/TAN/TanDB_Dump.cpp @@ -1,5 +1,22 @@ +//========================================================================== +// LHCb Online software suite +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see OnlineSys/LICENSE. +// +// Author : M.Frank +// +//========================================================================== + +// System include files #include <iostream> -#include "TAN/TanDB.h" + +// Framework include files +#include <TAN/TanDB.h> + + extern "C" int rtl_tandb_dump ( int /* argc */, char** /* argv */ ) { std::cout << "+------------------------------------------------------------------------------+" << std::endl; std::cout << "|||||||||||| T A N D A T A B A S E D U M P ||||||||||||" << std::endl; diff --git a/Online/OnlineBase/src/TAN/TanDB_tst.cpp b/Online/OnlineBase/src/TAN/TanDB_tst.cpp index 14dd70e33..13676be74 100755 --- a/Online/OnlineBase/src/TAN/TanDB_tst.cpp +++ b/Online/OnlineBase/src/TAN/TanDB_tst.cpp @@ -1,7 +1,23 @@ +//========================================================================== +// LHCb Online software suite +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see OnlineSys/LICENSE. +// +// Author : M.Frank +// +//========================================================================== + +// System include files #include <cstdio> #include <iostream> -#include "RTL/rtl.h" -#include "TAN/TanDB.h" + +// Framework include files +#include <RTL/rtl.h> +#include <TAN/TanDB.h> + #define LINE(ll,x) { \ for ( int i=0; i < ll; i++ ) std::cout << x; \ std::cout << std::endl; \ diff --git a/Online/OnlineBase/src/TAN/TanInterface.cpp b/Online/OnlineBase/src/TAN/TanInterface.cpp index 547ee15e5..47804b0ed 100755 --- a/Online/OnlineBase/src/TAN/TanInterface.cpp +++ b/Online/OnlineBase/src/TAN/TanInterface.cpp @@ -1,12 +1,24 @@ +//========================================================================== +// LHCb Online software suite +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see OnlineSys/LICENSE. +// +// Author : M.Frank +// +//========================================================================== + #define _TanInterface_C_ -#include "OnlineBase/RTL/rtl.h" -#include "OnlineBase/NET/defs.h" -#include "OnlineBase/TAN/TanInterface.h" -#include "OnlineBase/NET/UdpNetworkChannel.h" -#include "OnlineBase/NET/TcpNetworkChannel.h" +#include <RTL/rtl.h> +#include <NET/defs.h> +#include <TAN/TanInterface.h> +#include <NET/UdpNetworkChannel.h> +#include <NET/TcpNetworkChannel.h> -#include "AMS/amsdef.h" +#include <AMS/amsdef.h> #define SLEEP(x) lib_rtl_sleep(1000*x) #include <map> diff --git a/Online/OnlineBase/src/TAN/TanMon.cpp b/Online/OnlineBase/src/TAN/TanMon.cpp index 9072a8bd2..c49dd9767 100755 --- a/Online/OnlineBase/src/TAN/TanMon.cpp +++ b/Online/OnlineBase/src/TAN/TanMon.cpp @@ -1,9 +1,24 @@ +//========================================================================== +// LHCb Online software suite +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see OnlineSys/LICENSE. +// +// Author : M.Frank +// +//========================================================================== + +// System include files #include <ctime> #include <cstdio> #include <iostream> #include <sstream> -#include "RTL/rtl.h" -#include "TAN/TanDB.h" + +// Framework include files +#include <RTL/rtl.h> +#include <TAN/TanDB.h> #define dbl_hi_top printf("\033#3") #define dbl_hi_botm printf("\033#4") diff --git a/Online/OnlineBase/src/TAN/tan_alloc_tst.cpp b/Online/OnlineBase/src/TAN/tan_alloc_tst.cpp index bc5338593..d42360309 100755 --- a/Online/OnlineBase/src/TAN/tan_alloc_tst.cpp +++ b/Online/OnlineBase/src/TAN/tan_alloc_tst.cpp @@ -17,8 +17,8 @@ #include <cstdlib> // Framework include files -#include "TAN/TanDB.h" -#include "OnlineBase/TAN/TanInterface.h" +#include <TAN/TanDB.h> +#include <TAN/TanInterface.h> static void help() { printf("Usage : inquire -opt <opts>\n"); diff --git a/Online/OnlineBase/src/TAN/tan_inquire_tst.cpp b/Online/OnlineBase/src/TAN/tan_inquire_tst.cpp index d1d367b1f..5dd9adc67 100755 --- a/Online/OnlineBase/src/TAN/tan_inquire_tst.cpp +++ b/Online/OnlineBase/src/TAN/tan_inquire_tst.cpp @@ -1,13 +1,25 @@ -// ---------------------------------------------------------------------------- +//========================================================================== +// LHCb Online software suite +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. // -// M.Frank -// ---------------------------------------------------------------------------- +// For the licensing terms see OnlineSys/LICENSE. +// +// Author : M.Frank +// +//========================================================================== + +// System include files #include <cstdio> #include <cstdlib> #include <ctime> -#include "RTL/rtl.h" -#include "AMS/amsdef.h" -#include "TAN/TanInterface.h" + + +// Framework include files +#include <RTL/rtl.h> +#include <AMS/amsdef.h> +#include <TAN/TanInterface.h> #define MAXTASKS 20 #ifdef _VMS diff --git a/Online/OnlineBase/src/WT/wtlib.cpp b/Online/OnlineBase/src/WT/wtlib.cpp index 74c62e80e..790b906a4 100755 --- a/Online/OnlineBase/src/WT/wtlib.cpp +++ b/Online/OnlineBase/src/WT/wtlib.cpp @@ -9,10 +9,10 @@ // Author : M.Frank // //========================================================================== -#include "RTL/que.h" -#include "RTL/rtl.h" +#include <RTL/que.h> +#include <RTL/rtl.h> #define IMPLEMENTING -#include "WT/wtdef.h" +#include <WT/wtdef.h> #include <cstdlib> #include <cstdio> #include <cstring> diff --git a/Online/OnlineBase/src/WT/wttest.cpp b/Online/OnlineBase/src/WT/wttest.cpp index 858993145..0b88623e0 100755 --- a/Online/OnlineBase/src/WT/wttest.cpp +++ b/Online/OnlineBase/src/WT/wttest.cpp @@ -11,9 +11,9 @@ //========================================================================== // WAIT FACILITY TEST PROGRAM //---------------------------------------------------------------------- -#include "WT/wtdef.h" -#include "RTL/rtl.h" -#include "SCR/scr.h" +#include <WT/wtdef.h> +#include <RTL/rtl.h> +#include <SCR/scr.h> #include <ctime> #include <cstdlib> #include <cstdarg> diff --git a/Online/OnlineKernel/dict/PyInteractor.cpp b/Online/OnlineKernel/dict/PyInteractor.cpp index 003151a7b..dca0d20fc 100755 --- a/Online/OnlineKernel/dict/PyInteractor.cpp +++ b/Online/OnlineKernel/dict/PyInteractor.cpp @@ -95,7 +95,9 @@ static void s_init() { static bool first = true; if ( first ) { first = false; - ::PyEval_InitThreads(); +#if PY_MAJOR_VERSION <=2 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 7) + PyEval_InitThreads(); +#endif s_mainThreadState = PyThreadState_Get(); } } diff --git a/Online/PyDIM/src/dimcppmodule.cpp b/Online/PyDIM/src/dimcppmodule.cpp index f2b016e9d..f15b70349 100755 --- a/Online/PyDIM/src/dimcppmodule.cpp +++ b/Online/PyDIM/src/dimcppmodule.cpp @@ -872,7 +872,9 @@ initdimcpp() /* This is needed if the program is threaded. * Creates the global interpretor lock */ +#if PY_MAJOR_VERSION <=2 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 7) PyEval_InitThreads(); +#endif /// Initialize python module PyObject *module = nullptr; /* Initializing Python classes. diff --git a/Online/PyDIM/src/dimmodule.cpp b/Online/PyDIM/src/dimmodule.cpp index 9788d7ecf..134442cdd 100755 --- a/Online/PyDIM/src/dimmodule.cpp +++ b/Online/PyDIM/src/dimmodule.cpp @@ -1837,12 +1837,13 @@ PyInit_dimc() initdimc() #endif { - PyObject *m = nullptr; +#if PY_MAJOR_VERSION <=2 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 7) PyEval_InitThreads(); +#endif #if PY_MAJOR_VERSION >= 3 - m = ::PyModule_Create(&dim_module); + PyObject *m = ::PyModule_Create(&dim_module); #else - m = Py_InitModule3("dimc", DimMethods, "DIM methods"); + PyObject *m = Py_InitModule3("dimc", DimMethods, "DIM methods"); #endif if (m == NULL) { PyMODINIT_RETURN(m); diff --git a/Online/RawBankSizes/CMakeLists.txt b/Online/RawBankSizes/CMakeLists.txt index ba2b61373..892fac657 100644 --- a/Online/RawBankSizes/CMakeLists.txt +++ b/Online/RawBankSizes/CMakeLists.txt @@ -22,9 +22,6 @@ find_package(AIDA) find_package(Boost) include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) -# Only for testing: -# gau di_depends_on_subdirs(GaudiSvc Online/OnlineKernel Online/Gaucho Online/GaudiOnline) - gaudi_add_module(RawBankSizes RawBankSizes.cpp Structure.cpp EventSize.cpp RawEventRegister.cpp INCLUDE_DIRS Boost AIDA GaudiOnline LINK_LIBRARIES Tell1Data DAQEventLib) -- GitLab