How 1inch/profanity2 works
• Command‐Line Interface (CLI) & Argument Parsing:
– Files like ArgParser.hpp, help.hpp, and the usage information in the README indicate that the tool is driven by a CLI.
– Represent a “CLI / User Input” component which parses parameters such as the seed public key (-z) and mode flags like --leading, --benchmark, etc.
• Mode Selection and Core Logic:
– Files such as Mode.cpp/hpp and SpeedSample.cpp/hpp suggest that the core logic of selecting various scoring or matching modes is compartmentalized.
• GPU Compute Engine Using OpenCL:
– The presence of keccak.cl and profanity.cl files, along with CLMemory.hpp, emphasizes a dedicated kernel layer for GPU processing.
– Create a “GPU Compute Engine” block that highlights:
◦ OpenCL Kernel Management: Handles loading and executing kernels (e.g., keccak, the “profanity” kernel).
◦ Memory Management for OpenCL (managed by CLMemory.hpp, possibly interfacing with Dispatcher).
• Task Dispatch and Kernel Management:
– Dispatcher.cpp/hpp indicate a module responsible for dispatching tasks to GPU devices.
– Represent a “Dispatcher” or “Task Scheduler” that controls workload distribution across available GPU devices.
• Precomputation / Setup:
– Files like precomp.cpp/hpp suggest the presence of a module for precompiling or preparing certain computation aspects.
– Include a small block for any “Kernel Pre-compilation / Setup” that is necessary before the GPU workloads commence.
• Auxiliary and Utility Components:
– Utility headers such as lexical_cast.hpp, types.hpp, and possibly helper modules are supportive but contribute to overall system robustness.
– Optionally include a “Utilities” section that encapsulates these functions.
Relationship and Interactions
• The argument parser (via ArgParser.hpp) processes the input and sets appropriate flags, which determines the operational mode.
• The Core Mode Logic receives these parameters, invoking the correct mode (e.g., --leading, --benchmark).
• The Dispatcher then manages the distribution of computation tasks to appropriate GPU devices.
• The GPU Compute Engine (with its OpenCL kernels and memory management) performs high performance hash calculations.
• Data flow back from the GPU layer to the dispatcher for results, which then return output to the CLI.
Important Architectural Choices
• Separation between the user input / control layer and the performance-critical GPU computation layer.
• Point out the use of OpenCL as the technology that enables the performance boost on various hardware (as noted by benchmarks).
• That a dispatcher pattern is being used to handle parallel tasks on the GPU, ensuring both scalability and "safety by design".
Relevant Technologies and Frameworks
• OpenCL (for the GPU kernels in keccak.cl and profanity.cl).
• The use of C++ (given the .cpp and .hpp files) with a modular design separating modes, dispatching, precomputation, and input handling.
• Cite that performance tuning is a key aspect (e.g., work sizes and inverse calculations are configurable by parameters).