Skip to content

Commit

Permalink
Fix compiler warnings in Parallel library
Browse files Browse the repository at this point in the history
Mainly:
- add variable initializasation in class constructors
- cast int operands in arithmetic operations when the result is a longint
- plus some minor formating errors detected during pre-commit
  • Loading branch information
marcboulle committed Mar 19, 2024
1 parent 0779790 commit 5148dd5
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 19 deletions.
20 changes: 15 additions & 5 deletions src/Parallel/PLMPI/PLMPIMaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,25 @@
PLMPIMaster::PLMPIMaster(PLParallelTask* t)
{
ALString sTmp;
bInterruptionRequested = false;
bIsMaxErrorReached = 0;
bIsMaxWarningReached = 0;
bIsMaxMessageReached = 0;
nWorkingSlaves = 0;
task = t;
bNewMessage = false;
bSpawnedDone = false;
bStopOrderDone = false;
bInterruptionRequested = false;
bSlaveError = false;
bMasterError = false;
bIsMaxErrorReached = false;
bIsMaxWarningReached = false;
bIsMaxMessageReached = false;
dGlobalProgression = 0;
nOldProgression = 0;
bIsProcessing = false;
nInitialisationCount = 0;
nFinalisationCount = 0;
nFirstSlaveInitializeMessageRank = -1;
nFirstSlaveFinalizeMessageRank = -1;
sBufferDischarge[0] = '\0';
}

PLMPIMaster::~PLMPIMaster()
Expand Down Expand Up @@ -223,7 +233,7 @@ boolean PLMPIMaster::Run()
slave->SetRank(context.GetRank());
slave->SetHostName(sHostName);
slave->SetProgression(0);
slave->SetTaskPercent(1 / task->nWorkingProcessNumber); // Pour l'initialisation
slave->SetTaskPercent(1.0 / task->nWorkingProcessNumber); // Pour l'initialisation
GetTask()->oaSlaves.Add(slave);

// Ajout de l'esclave dans le dictionaire hsostName / liste des esclaves
Expand Down
4 changes: 2 additions & 2 deletions src/Parallel/PLMPI/PLMPIMessageManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ int MessageWithTaskIndexCompare(const void* elem1, const void* elem2)
message2 = cast(MessageWithTaskIndex*, *(Object**)elem2);

// Comparaison sur le TaskIndex puis sur le numero de ligne, puis sur l'ordre de reception
lIndexComp = message1->GetTaskIndex() - message2->GetTaskIndex();
lIndexComp = (longint)message1->GetTaskIndex() - message2->GetTaskIndex();
if (lIndexComp == 0)
{
lIndexComp = message1->GetMessage()->GetIndex() - message2->GetMessage()->GetIndex();
if (lIndexComp == 0)
lIndexComp = message1->GetAddIndex() - message2->GetAddIndex();
lIndexComp = (longint)message1->GetAddIndex() - message2->GetAddIndex();
}
return (int)((lIndexComp > 0) - (lIndexComp < 0)); // 1 si > 0; -1 si >0; 0 sinon
}
Expand Down
2 changes: 2 additions & 0 deletions src/Parallel/PLMPI/PLMPISlaveProgressionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ PLMPISlaveProgressionManager::PLMPISlaveProgressionManager(void)
nOldProgression = 0;
sendRequest = MPI_REQUEST_NULL;
ivMaxErrorReached = NULL;
nSlaveState = State::VOID;
sBuffer[0] = '\0';
}

PLMPISlaveProgressionManager::~PLMPISlaveProgressionManager(void)
Expand Down
6 changes: 3 additions & 3 deletions src/Parallel/PLParallelTask/PLFileConcatenater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ boolean PLFileConcatenater::Concatenate(const StringVector* svChunkURIs, const O
nInputPreferredSize = SystemFile::nMinPreferredBufferSize;
nOutputPreferredSize = PLRemoteFileService::GetPreferredBufferSize(sOutputFileName);

if (lRemainingMemory >= nInputPreferredSize + nOutputPreferredSize)
if (lRemainingMemory >= (longint)nInputPreferredSize + nOutputPreferredSize)
{
nOutputBufferSize = nOutputPreferredSize;
lInputBufferSize = lRemainingMemory - nOutputBufferSize;
Expand All @@ -180,8 +180,8 @@ boolean PLFileConcatenater::Concatenate(const StringVector* svChunkURIs, const O
lInputBufferSize = (lInputBufferSize / nInputPreferredSize) * nInputPreferredSize;

// On n'utilise pas plus de 8 preferred size
if (lInputBufferSize > 8 * nOutputPreferredSize)
lInputBufferSize = 8 * nOutputPreferredSize;
if (lInputBufferSize > 8 * (longint)nOutputPreferredSize)
lInputBufferSize = 8 * (longint)nOutputPreferredSize;
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/Parallel/PLParallelTask/PLParallelTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2129,7 +2129,7 @@ int PLParallelTask::InternalComputeStairBufferSize(int nBufferSizeMin, int nBuff

// Fin de traitement : quand il n'y a du travail que pour la moitie des esclaves
lFileSizeRemaining = lFileSize - lFileProcessed;
if (lFileSizeRemaining < (nProcessNumber / 2) * nComputedBufferSizeMax)
if (lFileSizeRemaining < (nProcessNumber / 2) * (longint)nComputedBufferSizeMax)
{
bStop = true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Parallel/PLParallelTask/PLSharedVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,10 @@ void PLShared_LongintVector::Test()

// Initialisation d'une variable partagee en entree
for (i = 0; i < 5; i++)
ivInitialValue.Add(i + 1);
ivInitialValue.Add((longint)i + 1);
shared_valueIn.GetLongintVector()->CopyFrom(&ivInitialValue);
for (i = 0; i < 5; i++)
shared_valueIn.Add(101 + i);
shared_valueIn.Add(101 + (longint)i);

// Serialisation
serializer.OpenForWrite(NULL);
Expand Down
2 changes: 1 addition & 1 deletion src/Parallel/PLParallelTask/RMParallelResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2357,7 +2357,7 @@ boolean PLSolution::FitMinimalRequirements(int nRT, longint& lMissingResource, b
if (hostClassSolution->GetHostCountPerProcNumber()->GetAt(nProcNumber) != 0)
{
// Resources necessaires sur ce host
lUsedResource = lMasterSum + (nProcNumber - 1) * lSlaveMin;
lUsedResource = lMasterSum + ((longint)nProcNumber - 1) * lSlaveMin;

// Ressources disponibles sur le host
lLocalMissingResource = lUsedResource - lAvailableResource;
Expand Down
1 change: 1 addition & 0 deletions src/Parallel/PLSamples/PEFileSearchTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ PEFileSearchTask::PEFileSearchTask()
// Variables du maitre
lInputFileSize = 0;
lFoundLineNumber = 0;
lFilePos = 0;
}

PEFileSearchTask::~PEFileSearchTask() {}
Expand Down
1 change: 1 addition & 0 deletions src/Parallel/PLSamples/PEIOParallelTestTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ PEIOParallelTestTask::PEIOParallelTestTask()
lTotalFieldNumber = 0;
lTotalLineNumber = 0;
lTotalFileSizes = 0;
nFileIndex = 0;
}

PEIOParallelTestTask::~PEIOParallelTestTask() {}
Expand Down
6 changes: 5 additions & 1 deletion src/Parallel/PLSamples/PELullaby.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

#include "PELullabyTask.h"

PELullabyTask::PELullabyTask() {}
PELullabyTask::PELullabyTask()
{
nMyTaskIndex = 0;
nStepSize = 0;
}

PELullabyTask::~PELullabyTask() {}

Expand Down
3 changes: 2 additions & 1 deletion src/Parallel/PLSamples/PEProgressionTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ PEProgressionTask::PEProgressionTask()
{
nMethodToTest = 0;
bBoostMode = false;
nIterationNumber = 0;
DeclareTaskInput(&input_nIterationNumber);
}
PEProgressionTask::~PEProgressionTask() {}
Expand Down Expand Up @@ -74,7 +75,7 @@ boolean PEProgressionTask::Test(int nMethod, boolean bValue)
boolean PEProgressionTask::Test()
{
int nMethod;
int bOk;
boolean bOk;
bOk = true;
for (nMethod = MASTER_INITIALIZE; nMethod < END; nMethod++)
{
Expand Down
1 change: 1 addition & 0 deletions src/Parallel/PLSamples/PESerializerLongTestTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ PESerializerLongTestTask::PESerializerLongTestTask()
{
DeclareTaskInput(&input_sString);
DeclareTaskInput(&input_nStringLength);
nMaxStringSize = 0;
}

PESerializerLongTestTask::~PESerializerLongTestTask() {}
Expand Down
2 changes: 2 additions & 0 deletions src/Parallel/PLSamples/PESerializerTestTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ PESerializerTestTask::PESerializerTestTask()
DeclareSharedParameter(&shared_nLargeCharVectorSize);
DeclareSharedParameter(&shared_nLargeStringSize);

nLargeCharVectorSize = 0;
nLargeStringSize = 0;
sSimpleStringToSerialize = "A simple string";
sSimpleCharVectorToSerialize = "A simple CharVector !!";
}
Expand Down
4 changes: 1 addition & 3 deletions test/LearningTestTool/py/kht_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,7 @@ def export_learning_test_tree(
# Creation du repertoire de suite uniquement si necessaire
if not target_suite_dir_created:
utils.make_dir(target_suite_dir)
target_suite_dir_created = os.path.isdir(
target_suite_dir
)
target_suite_dir_created = os.path.isdir(target_suite_dir)
# Cas d'un repertoire
if os.path.isdir(source_test_dir):
# Copie du repertoire de test
Expand Down

0 comments on commit 5148dd5

Please sign in to comment.