# They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
SET(_${PROJECT_NAME}_exposed_targets
- SALOMEBasics ArgvKeeper SALOMELocalTrace SalomeHDFPersist OpUtil)
+ SALOMELog SALOMEBasics ArgvKeeper SALOMELocalTrace SalomeHDFPersist OpUtil)
# CORBA specific targets:
IF(NOT SALOME_LIGHT_ONLY)
SET(KERNEL_OpUtil OpUtil)
SET(KERNEL_Registry Registry)
SET(KERNEL_ResourcesManager ResourcesManager)
+SET(KERNEL_SALOMELog SALOMELog)
SET(KERNEL_SALOMEBasics SALOMEBasics)
SET(KERNEL_SalomeCatalog SalomeCatalog)
SET(KERNEL_SalomeCommunication SalomeCommunication)
${CMAKE_CURRENT_SOURCE_DIR}
)
+SET(SALOMELog_SOURCES
+ libSALOMELog.cxx
+)
+
SET(SALOMEBasics_SOURCES
BasicsGenericDestructor.cxx
Basics_Utils.cxx
Basics_DirUtils.cxx
- SALOME_Basics.hxx
- BasicsGenericDestructor.hxx
- Basics_Utils.hxx
- Basics_DirUtils.hxx
KernelBasis.cxx
+ HeatMarcel.cxx
)
+ADD_LIBRARY(SALOMELog ${SALOMELog_SOURCES})
+TARGET_LINK_LIBRARIES(SALOMELog ${PLATFORM_LIBS} ${PTHREAD_LIBRARIES})
+INSTALL(TARGETS SALOMELog EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
+
ADD_LIBRARY(SALOMEBasics ${SALOMEBasics_SOURCES})
INSTALL(TARGETS SALOMEBasics EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
-TARGET_LINK_LIBRARIES(SALOMEBasics ${PLATFORM_LIBS} ${PTHREAD_LIBRARIES})
+TARGET_LINK_LIBRARIES(SALOMEBasics SALOMELog ${PLATFORM_LIBS} ${PTHREAD_LIBRARIES})
FILE(GLOB SALOMEBasics_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx")
INSTALL(FILES ${SALOMEBasics_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS})
-SET(KernelBasis_HEADERS KernelBasis.hxx KernelBasis.i)
+SET(KernelBasis_HEADERS baseutilities.h KernelBasis.hxx KernelBasis.i)
SET(KernelBasis_SOURCES ${KernelBasis_HEADERS})
SET_SOURCE_FILES_PROPERTIES(KernelBasis.i PROPERTIES CPLUSPLUS ON)
SET_SOURCE_FILES_PROPERTIES(KernelBasis.i PROPERTIES SWIG_FLAGS "-py3")
--- /dev/null
+// Copyright (C) 2023 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library 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
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HeatMarcel.hxx"
+
+#include "baseutilities.h"
+
+#include <thread>
+#include <cstdint>
+#include <cmath>
+#include <vector>
+#include <numeric>
+#include <chrono>
+
+#include <iostream>
+
+template<class T>
+static void GetSlice(T start, T stop, const unsigned int sliceId, const unsigned int nbOfSlices, T& startSlice, T& stopSlice)
+{
+ T nbElems=stop - start;
+ T minNbOfElemsPerSlice=nbElems/nbOfSlices;
+ startSlice=start+minNbOfElemsPerSlice*sliceId;
+ if(sliceId<nbOfSlices-1)
+ stopSlice=start+minNbOfElemsPerSlice*(sliceId+1);
+ else
+ stopSlice=stop;
+}
+
+/*!
+ * Compute integration of 1/(1+x^2) function (atan function) between start/nbTurn and end/nbTurn.
+ */
+static void SimulateOneCoreOfComputationNode(std::uint64_t start, std::uint64_t end, std::uint64_t nbTurn, long double* ret)
+{
+ long double retLoc = 0.0;
+ long double delta = 1.0 / ((long double) nbTurn);
+ for(std::uint64_t i = start ; i < end ; ++i)
+ {
+ long double x = i*delta;
+ retLoc += delta/(1+x*x);
+ }
+ *ret = retLoc;
+}
+
+static long double SimulateOnAllCoresOfComputationNodeInternal(std::uint64_t nbTurn, unsigned int nbThreads)
+{
+ SIMPLE_MESSAGE( "Number of turn = 10**" << std::log10((double)nbTurn) );
+ std::vector< std::thread > threads(nbThreads);
+ std::vector<long double> res(nbThreads);
+ for(auto iCore = 0 ; iCore < nbThreads ; ++iCore)
+ {
+ std::uint64_t startSlice,stopSlice;
+ GetSlice<std::uint64_t>(0,nbTurn,iCore,nbThreads,startSlice,stopSlice);
+ long double *resLoc = res.data()+iCore;
+ threads[iCore] = std::thread([nbTurn,startSlice,stopSlice,resLoc]{ SimulateOneCoreOfComputationNode(startSlice,stopSlice,nbTurn,resLoc);});
+ }
+ SIMPLE_MESSAGE( "Number of processors " << nbThreads );
+ for(auto& th : threads)
+ th.join();
+ long double ret = std::accumulate(res.begin(),res.end(),0.0);
+ return ret;
+}
+
+constexpr long double CST = 161000000; // CST - estabished with gcc8.5.0 in debug mode
+
+static std::uint64_t GetNbTurnFromTimeControler(double timeControler)
+{
+ return static_cast<std::uint64_t>( timeControler * CST );
+}
+
+/*!
+* long double& ret let it in output to force computation
+ */
+static std::int64_t GetNbOfNsFor(double timeControler, long double& ret)
+{
+ std::uint64_t nbTurn = GetNbTurnFromTimeControler( timeControler );
+ auto start = std::chrono::high_resolution_clock::now();
+ SimulateOneCoreOfComputationNode(0,nbTurn,nbTurn,&ret);
+ auto end = std::chrono::high_resolution_clock::now();
+ return std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count();
+}
+
+/*!
+* long double& ret let it in output to force computation
+ */
+static double FunctionToSolve(double timeControler, long double& fake)
+{
+ std::int64_t timeInNs = GetNbOfNsFor(timeControler,fake);
+ long double ret = (long double )timeInNs / ((long double) 1000000000);
+ return ret;
+}
+
+/*!
+* long double& ret let it in output to force computation
+ */
+static double Derivative(double timeControler, long double& fake)
+{
+ long double fake1,fake2;
+ double a = FunctionToSolve(timeControler,fake1);
+ double b = FunctionToSolve(2*timeControler,fake2);
+ fake = fake1 + fake2;
+ return (b-a)/(timeControler);
+}
+
+/*
+ * The returned value is those to pass to ActiveSleepOfComputationNode to
+ * have an active sleep of 1s on one core.
+ *
+ * Higher is the returned value most performant is your processor and/or the generated binary
+ *
+ * Some exemple on core i7-6700 of 2020 on gcc 6.3 and 8.5
+ * In debug mode : ~ 1
+ * In O2 mode : ~ 4.3
+ */
+double SALOME::GetTimeAdjustmentCst()
+{
+ long double fake;
+ double ret = Derivative(0.5,fake);
+ // Do not remove fake variable because if you do so compiler is too smart and stop computing :)
+ if(fake > 0.0)
+ return 1.0/ret;
+ return 1.0;
+}
+
+/*
+ * This method can be seen as a active sleep that occupies cores (piloted by \a nbThreads) of hosting computation node.
+ * Of course the time spend by this method cannot be controled finely due to dependancy of the activity on hosted machine / OS.
+ * This method only occupies cores without any stress of the memory.
+ * This method can be used to assess good usage of computation nodes on a massive YACS graph.
+ *
+ * /param [in] timeAjustment : pilot time spend for the active sleep. The duration is linearly controled by this input and inversly linearly to the \a nbThreads parameter.
+ * \param [out] timeInS : return the time in second of the active sleep
+ * \param [in] nbThreads : Specify the number of thread on which the computation will be launched. If 0 (the default) all cores of hosting machine will be used.
+ * \return is pi value computed in a naive way :) This return value is necessary to prevent aggressive compiler to not compute.
+ *
+ * \sa GetTimeAdjustmentCstOnYourSystem : to help you to fine tune \a timeAjustment parameter
+ */
+long double SALOME::HeatMarcel(double timeAjustment, double& timeInS, unsigned int nbThreads)
+{
+ std::uint64_t nbTurn = GetNbTurnFromTimeControler( timeAjustment );
+ unsigned int nbThreadsEff = nbThreads == 0?std::thread::hardware_concurrency():nbThreads;
+ auto start = std::chrono::high_resolution_clock::now();
+ long double ret = SimulateOnAllCoresOfComputationNodeInternal(nbTurn, nbThreadsEff);
+ auto end = std::chrono::high_resolution_clock::now();
+ timeInS = ((double)(std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count()))/1000000000.0;
+ return 4.0 * ret;
+}
--- /dev/null
+// Copyright (C) 2023 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library 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
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#pragma once
+
+#include "SALOME_Basics.hxx"
+
+namespace SALOME
+{
+ double BASICS_EXPORT GetTimeAdjustmentCst();
+
+ long double BASICS_EXPORT HeatMarcel(double timeAjustment, double& timeInS, unsigned int nbThreads = 0);
+}
%{
#include "KernelBasis.hxx"
+#include "HeatMarcel.hxx"
+using namespace SALOME;
%}
%include "std_string.i"
+%rename (HeatMarcel) HeatMarcelSwig;
+
bool getSSLMode();
void setSSLMode(bool sslMode);
std::string getIOROfEmbeddedNS();
void setIOROfEmbeddedNS(const std::string& ior);
+
+double GetTimeAdjustmentCst();
+
+%inline
+{
+PyObject *HeatMarcelSwig(double timeAjustment, unsigned int nbThreads = 0)
+{
+ double timeInS = 0.0;
+ long double piVal = HeatMarcel(timeAjustment,timeInS,nbThreads);
+ PyObject *ret(PyTuple_New(2));
+ PyTuple_SetItem(ret,0,SWIG_From_double((double)piVal));
+ PyTuple_SetItem(ret,1,SWIG_From_double(timeInS));
+ return ret;
+}
+}
--- /dev/null
+// Copyright (C) 2023 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library 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
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "libSALOMELog.hxx"
+#include <sstream>
+#include <iostream>
+
+#pragma once
+
+#define SIMPLE_MESS_END std::endl; std::cout << os.str() << std::flush;
+#define SIMPLE_MESS_INIT(deb) std::ostringstream os; os<< deb
+#define SIMPLE_MESS_BEGIN(deb) SIMPLE_MESS_INIT(deb)<<__FILE__ <<" ["<<__LINE__<<"] : "
+#define SIMPLE_MESSAGE(msg) { if (SALOME::VerbosityActivated()) {SIMPLE_MESS_BEGIN("- Trace ") << msg << SIMPLE_MESS_END}}
--- /dev/null
+// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library 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
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// Author : Konstantin Leontev (OpenCascade)
+// Module : KERNEL
+// $Header$
+//
+
+#include "libSALOMELog.hxx"
+
+#include <string>
+#include <iostream>
+
+namespace SALOME
+{
+
+// ============================================================================
+/*!
+ * Called by any log message macros to decide about log output in Release and
+ * Debug mode dynamically rely on SALOME_VERBOSE environment variable.
+ * Checks SALOME_VERBOSE only on the very first call and returns cached result
+ * for all followed calls.
+ * Returns true if SALOME_VERBOSE is positioned and not empty and if its
+ * numeric value greater than 0.
+ */
+// ============================================================================
+
+ bool VerbosityActivated()
+ {
+ auto isEnvVarSet = []() -> bool
+ {
+ const char* envVar = std::getenv("SALOME_VERBOSE");
+
+ if (envVar && (envVar[0] != '\0'))
+ {
+ try
+ {
+ const long long numValue = std::stoll(envVar);
+ return numValue > 0;
+ }
+ catch(const std::exception& e)
+ {
+ std::cerr << e.what() << '\n';
+ }
+ }
+
+ return false;
+ };
+
+ static const bool isActivated = isEnvVarSet();
+ return isActivated;
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library 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
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File : libSALOMELog.hxx
+// Author : Konstantin Leontev (OpenCascade)
+// Module : KERNEL
+// $Header$
+//
+#pragma once
+
+#include "SALOME_Basics.hxx"
+
+namespace SALOME
+{
+ bool BASICS_EXPORT VerbosityActivated();
+}
LocalTraceBufferPool.hxx
BaseTraceCollector.hxx
SALOME_LocalTrace.hxx
- libSALOMELog.hxx
)
SET(SALOMELocalTrace_SOURCES
LocalTraceBufferPool.cxx
LocalTraceBufferPool.hxx
SALOME_LocalTrace.hxx
- libSALOMELog.hxx
- libSALOMELog.cxx
)
ADD_LIBRARY(SALOMELocalTrace ${SALOMELocalTrace_SOURCES})
-TARGET_LINK_LIBRARIES(SALOMELocalTrace SALOMEBasics ${PLATFORM_LIBS} ${PTHREAD_LIBRARIES})
+TARGET_LINK_LIBRARIES(SALOMELocalTrace SALOMEBasics SALOMELog ${PLATFORM_LIBS} ${PTHREAD_LIBRARIES})
INSTALL(TARGETS SALOMELocalTrace EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
INSTALL(FILES ${COMMON_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS})
+++ /dev/null
-// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library 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
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-// Author : Konstantin Leontev (OpenCascade)
-// Module : KERNEL
-// $Header$
-//
-
-#include "libSALOMELog.hxx"
-
-#include <string>
-#include <iostream>
-
-namespace SALOME
-{
-
-// ============================================================================
-/*!
- * Called by any log message macros to decide about log output in Release and
- * Debug mode dynamically rely on SALOME_VERBOSE environment variable.
- * Checks SALOME_VERBOSE only on the very first call and returns cached result
- * for all followed calls.
- * Returns true if SALOME_VERBOSE is positioned and not empty and if its
- * numeric value greater than 0.
- */
-// ============================================================================
-
- bool VerbosityActivated()
- {
- auto isEnvVarSet = []() -> bool
- {
- const char* envVar = std::getenv("SALOME_VERBOSE");
-
- if (envVar && (envVar[0] != '\0'))
- {
- try
- {
- const long long numValue = std::stoll(envVar);
- return numValue > 0;
- }
- catch(const std::exception& e)
- {
- std::cerr << e.what() << '\n';
- }
- }
-
- return false;
- };
-
- static const bool isActivated = isEnvVarSet();
- return isActivated;
- }
-}
+++ /dev/null
-// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library 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
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-// File : libSALOMELog.hxx
-// Author : Konstantin Leontev (OpenCascade)
-// Module : KERNEL
-// $Header$
-//
-#ifndef _LIBSALOMELOG_HXX_
-#define _LIBSALOMELOG_HXX_
-
-#include "SALOME_LocalTrace.hxx"
-
-namespace SALOME
-{
- bool SALOMELOCALTRACE_EXPORT VerbosityActivated();
-}
-
-#endif