-
-
Notifications
You must be signed in to change notification settings - Fork 86
Open
Description
Issue
I've noticed that this project misuses the PasMP library (which I am the author of) in parallel loop handling, which could lead to incorrect behavior in multithreaded operations. Specifically, the parallel loop wrappers are only processing the starting index (AFromIndex
) without iterating through the full range (AFromIndex
to AToIndex
). Here are the corrections:
Corrections
-
In
TBlake2BP.PasMPParallelComputationWrapper
:Current:
procedure TBlake2BP.PasMPParallelComputationWrapper(const AJob: PPasMPJob; const AThreadIndex: LongInt; const ADataContainer: Pointer; const AFromIndex, AToIndex: TPasMPNativeInt); begin ParallelComputation(AFromIndex, ADataContainer); end;
Corrected:
procedure TBlake2BP.PasMPParallelComputationWrapper(const AJob: PPasMPJob; const AThreadIndex: LongInt; const ADataContainer: Pointer; const AFromIndex, AToIndex: TPasMPNativeInt); var Index: TPasMPNativeInt; begin for Index := AFromIndex to AToIndex do ParallelComputation(Index, ADataContainer); end;
-
In
TPBKDF_ScryptNotBuildInAdapter.PasMPSMixWrapper
:Current:
class procedure TPBKDF_ScryptNotBuildInAdapter.PasMPSMixWrapper (const AJob: PPasMPJob; const AThreadIndex: LongInt; const ADataContainer: Pointer; const AFromIndex, AToIndex: TPasMPNativeInt); begin SMix(AFromIndex, ADataContainer); end;
Corrected:
class procedure TPBKDF_ScryptNotBuildInAdapter.PasMPSMixWrapper (const AJob: PPasMPJob; const AThreadIndex: LongInt; const ADataContainer: Pointer; const AFromIndex, AToIndex: TPasMPNativeInt); var Index: TPasMPNativeInt; begin for Index := AFromIndex to AToIndex do SMix(Index, ADataContainer); end;
-
In
TPBKDF_Argon2NotBuildInAdapter.PasMPFillMemoryBlocksWrapper
:Current:
procedure TPBKDF_Argon2NotBuildInAdapter.PasMPFillMemoryBlocksWrapper (const AJob: PPasMPJob; const AThreadIndex: LongInt; const ADataContainer: Pointer; const AFromIndex, AToIndex: TPasMPNativeInt); begin PDataContainer(ADataContainer)^.Position.FLane := AFromIndex; FillMemoryBlocks(AFromIndex, ADataContainer); end;
Corrected:
procedure TPBKDF_Argon2NotBuildInAdapter.PasMPFillMemoryBlocksWrapper (const AJob: PPasMPJob; const AThreadIndex: LongInt; const ADataContainer: Pointer; const AFromIndex, AToIndex: TPasMPNativeInt); var Index: TPasMPNativeInt; begin for Index := AFromIndex to AToIndex do begin PDataContainer(ADataContainer)^.Position.FLane := Index; FillMemoryBlocks(Index, ADataContainer); end; end;
Summary
These changes ensure that all indices within the given range are processed correctly, maintaining the intended parallelization behavior.
Metadata
Metadata
Assignees
Labels
No labels