Configurable shmem segment size

This commit is contained in:
Alexey Rybalchenko 2017-04-06 14:18:30 +02:00 committed by Mohammad Al-Turany
parent ac7017deb5
commit 7caf0a6aae
2 changed files with 7 additions and 2 deletions

View File

@ -309,6 +309,7 @@ void FairMQProgOptions::InitOptionDescription()
("port-range-min", po::value<int >()->default_value(22000), "Start of the port range for dynamic initialization.") ("port-range-min", po::value<int >()->default_value(22000), "Start of the port range for dynamic initialization.")
("port-range-max", po::value<int >()->default_value(32000), "End of the port range for dynamic initialization.") ("port-range-max", po::value<int >()->default_value(32000), "End of the port range for dynamic initialization.")
("log-to-file", po::value<string>()->default_value(""), "Log output to a file.") ("log-to-file", po::value<string>()->default_value(""), "Log output to a file.")
("shm-segment-size", po::value<size_t>()->default_value(2000000000), "shmem transport: size of the shared memory segment (in bytes).")
; ;
fMQOptionsInCfg.add_options() fMQOptionsInCfg.add_options()
@ -324,6 +325,7 @@ void FairMQProgOptions::InitOptionDescription()
("port-range-min", po::value<int >()->default_value(22000), "Start of the port range for dynamic initialization.") ("port-range-min", po::value<int >()->default_value(22000), "Start of the port range for dynamic initialization.")
("port-range-max", po::value<int >()->default_value(32000), "End of the port range for dynamic initialization.") ("port-range-max", po::value<int >()->default_value(32000), "End of the port range for dynamic initialization.")
("log-to-file", po::value<string>()->default_value(""), "Log output to a file.") ("log-to-file", po::value<string>()->default_value(""), "Log output to a file.")
("shm-segment-size", po::value<size_t>()->default_value(2000000000), "shmem transport: size of the shared memory segment (in bytes).")
; ;
} }
else else
@ -341,6 +343,7 @@ void FairMQProgOptions::InitOptionDescription()
("port-range-min", po::value<int >()->default_value(22000), "Start of the port range for dynamic initialization.") ("port-range-min", po::value<int >()->default_value(22000), "Start of the port range for dynamic initialization.")
("port-range-max", po::value<int >()->default_value(32000), "End of the port range for dynamic initialization.") ("port-range-max", po::value<int >()->default_value(32000), "End of the port range for dynamic initialization.")
("log-to-file", po::value<string>()->default_value(""), "Log output to a file.") ("log-to-file", po::value<string>()->default_value(""), "Log output to a file.")
("shm-segment-size", po::value<size_t>()->default_value(2000000000), "shmem transport: size of the shared memory segment (in bytes).")
; ;
} }

View File

@ -38,9 +38,11 @@ FairMQTransportFactorySHM::FairMQTransportFactorySHM()
void FairMQTransportFactorySHM::Initialize(const FairMQProgOptions* config) void FairMQTransportFactorySHM::Initialize(const FairMQProgOptions* config)
{ {
int numIoThreads = 1; int numIoThreads = 1;
size_t segmentSize = 2000000000;
if (config) if (config)
{ {
numIoThreads = config->GetValue<int>("io-threads"); numIoThreads = config->GetValue<int>("io-threads");
segmentSize = config->GetValue<size_t>("shm-segment-size");
} }
else else
{ {
@ -58,8 +60,8 @@ void FairMQTransportFactorySHM::Initialize(const FairMQProgOptions* config)
LOG(ERROR) << "failed configuring context, reason: " << zmq_strerror(errno); LOG(ERROR) << "failed configuring context, reason: " << zmq_strerror(errno);
} }
Manager::Instance().InitializeSegment("open_or_create", "FairMQSharedMemory", 2000000000); Manager::Instance().InitializeSegment("open_or_create", "FairMQSharedMemory", segmentSize);
LOG(DEBUG) << "shmem: created/opened shared memory segment of 2000000000 bytes. Available are " << Manager::Instance().Segment()->get_free_memory() << " bytes."; LOG(DEBUG) << "shmem: created/opened shared memory segment of " << segmentSize << " bytes. Available are " << Manager::Instance().Segment()->get_free_memory() << " bytes.";
} }
FairMQMessagePtr FairMQTransportFactorySHM::CreateMessage() const FairMQMessagePtr FairMQTransportFactorySHM::CreateMessage() const