From 70ff89de4b479d60ad98e4ea420d84f365034062 Mon Sep 17 00:00:00 2001 From: bruno Date: Fri, 12 Apr 2024 15:55:11 +0200 Subject: [PATCH] Add environment variable to launch a file server process on single host When the environment variable KhiopsFileServerActivated is set to true, an MPI file server process is launched on a single machine. These process are used on clusters to exchange temporary files. This feature allows to test the file server on a common laptop. --- src/Learning/KWDataUtils/PLUseMPI.h | 6 +++++- src/Learning/KWUtils/KWVersion.cpp | 27 +++++++++++++++++++++++++++ src/Learning/KWUtils/KWVersion.h | 4 ++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/Learning/KWDataUtils/PLUseMPI.h b/src/Learning/KWDataUtils/PLUseMPI.h index 576efe4f6..0aa4ce24e 100644 --- a/src/Learning/KWDataUtils/PLUseMPI.h +++ b/src/Learning/KWDataUtils/PLUseMPI.h @@ -21,9 +21,13 @@ inline void UseMPI() PLParallelTask::GetDriver()->InitializeResourceSystem(); // Chargement du driver pour l'acces aux fichiers distants (file://) - if (RMResourceManager::GetResourceSystem()->GetHostNumber() > 1 or PLTaskDriver::GetFileServerOnSingleHost()) + if (RMResourceManager::GetResourceSystem()->GetHostNumber() > 1 or GetFileServerActivated()) SystemFileDriverCreator::RegisterDriver(new PLMPISystemFileDriverRemote); + // Activation du serveure de fichier en mono-machine si necessaire + if (GetFileServerActivated()) + PLTaskDriver::SetFileServerOnSingleHost(true); + // Verification des versions de chaque processus PLParallelTask::SetVersion(GetLearningVersion()); PLMPITaskDriver::CheckVersion(); diff --git a/src/Learning/KWUtils/KWVersion.cpp b/src/Learning/KWUtils/KWVersion.cpp index b01b34d95..4795fe03c 100644 --- a/src/Learning/KWUtils/KWVersion.cpp +++ b/src/Learning/KWUtils/KWVersion.cpp @@ -602,6 +602,33 @@ int GetParallelTraceMode() return nParallelTraceMode; } +boolean GetFileServerActivated() +{ + static boolean bIsInitialized = false; + static boolean bFileServerActivated = false; + int nValue; + + // Determination du mode parallele au premier appel + if (not bIsInitialized) + { + ALString sFileServerActivated; + + // Recherche de la variable d'environnement + sFileServerActivated = p_getenv("KhiopsFileServerActivated"); + sFileServerActivated.MakeLower(); + + // Determination du mode parallele + if (sFileServerActivated == "true") + bFileServerActivated = true; + else if (sFileServerActivated == "false") + bFileServerActivated = false; + + // Memorisation du flag d'initialisation + bIsInitialized = true; + } + return bFileServerActivated; +} + boolean GetLearningPriorStudyMode() { static boolean bIsInitialized = false; diff --git a/src/Learning/KWUtils/KWVersion.h b/src/Learning/KWUtils/KWVersion.h index 685c52870..8f3dccdc3 100644 --- a/src/Learning/KWUtils/KWVersion.h +++ b/src/Learning/KWUtils/KWVersion.h @@ -153,6 +153,10 @@ boolean GetParallelExpertMode(); // aux methodes de PLParallelTask) int GetParallelTraceMode(); +// Indicateur du lancement d'un serveur de fichier sur un systeme mono-machine. Les serveurs sont normalement instancies sur +// un cluster de machine. Cet indicateur permet de tester le driver de fichier distant sans cluster. +boolean GetFileServerActivated(); + // Indicateur du mode d'etude des prior dans le cadre de la construction de variable (en mode expert uniquement) // Ce mode est controlable par la variable d'environnement KhiopsPriorStudyMode a true ou false boolean GetLearningPriorStudyMode();