How to configure CPU affinity in HFT Antenna

Overview

FIX Antenna HFT provides the ability to configure CPU affinity programmatically.

Configuration

On initialization, each thread goes to the Engine::ThreadsPoolListener::onNewThreadCreated(ThreadAttrs& threadAttrs) callback, where the user is able to define the affinity for the thread. If the user doesn't specify the affinity for the thread, all CPUs will be used.

Affinity is specified as a bitmask where the serial number of the bit is the serial number of the core if read from the right to the left. The mask should be presented in the decimal system.

E.g. to specify the second, third, and fourth cores, the affinity in bytes will look like '1110'. It is '14' in the decimal system. So, for proper use, the affinity should be set to '14'.

In order Engine to know exactly what code to call, the user should register on the mentioned callback on HFT Antenna start. Below is the snippet from the 'Router' sample for reference:

Engine::FixEngine::InitParameters params;
params.threadPoolListener_ = listener;
FixEngine::init( params );

The way described above works for all the threads except the async logger thread.

Аsync logger thread affinity is configured in a different way by means of g_platformProps.logger_CPUMask, which is the parameter of the platformProps global settings object. Below is the snippet from the 'Router' sample for reference:

g_platformProps.logger_CPUMask = mask;
platform_initialize(...);
launch_logger_thread();