Skip to content

Commit df8f16d

Browse files
committed
Clean up CommMpi and CommSocket (useless Barrier) - The driver can now
automatically allocate and create a DSM buffer (server side) if the environment variable H5FD_DSM_SERVER_CONFIG_PATH is set to the path of the server config file - This mode is not fully tested yet
1 parent a7d2291 commit df8f16d

File tree

6 files changed

+36
-17
lines changed

6 files changed

+36
-17
lines changed

H5FDdsm.cxx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,13 @@ H5Pset_fapl_dsm(hid_t fapl_id, MPI_Comm dsmComm, void *dsmBuffer)
462462
dsmManagerSingleton->CreateDSM();
463463
if (dsmManagerSingleton->GetDsmIsServer()) {
464464
dsmManagerSingleton->PublishDSM();
465+
while (!dsmManagerSingleton->GetDSMHandle()->GetIsConnected()) {
466+
// Spin
467+
}
465468
} else {
466469
dsmManagerSingleton->ConnectDSM();
467470
}
471+
dsmManagerSingleton->GetDSMHandle()->SetIsAutoAllocated(true);
468472
}
469473
fa.buffer = dsmManagerSingleton->GetDSMHandle();
470474
}
@@ -626,6 +630,10 @@ H5FD_dsm_open(const char *name, unsigned UNUSED flags, hid_t fapl_id, haddr_t ma
626630
file->DsmBuffer->ClearStorage();
627631
file->DsmBuffer->GetComm()->Barrier();
628632
} else {
633+
// Check that the DSM ready for update flag is set
634+
while (!file->DsmBuffer->GetIsUpdateReady() && file->DsmBuffer->GetIsAutoAllocated()) {
635+
// Spin
636+
}
629637
// For now a file in a DSM Buffer which is not created is considered as open in read-only
630638
PRINT_INFO("SetIsReadOnly(true)");
631639
file->DsmBuffer->SetIsReadOnly(true);
@@ -787,6 +795,11 @@ H5FD_dsm_close(H5FD_t *_file)
787795
file->DsmBuffer->RequestPipelineUpdate();
788796
}
789797
} else {
798+
if (file->DsmBuffer->GetIsUpdateReady() && file->DsmBuffer->GetIsAutoAllocated()) {
799+
// file->DsmBuffer->GetComm()->Barrier();
800+
file->DsmBuffer->SetIsUpdateReady(false);
801+
file->DsmBuffer->RequestRemoteChannel();
802+
}
790803
PRINT_INFO("SetIsReadOnly(false)");
791804
file->DsmBuffer->SetIsReadOnly(false);
792805
}

H5FDdsmBuffer.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ H5FDdsmBuffer::H5FDdsmBuffer() {
7979
H5FDdsmInt64 i;
8080
this->ThreadDsmReady = 0;
8181
this->DataPointer = 0;
82+
this->IsAutoAllocated = false;
8283
this->IsServer = true;
8384
this->IsConnected = false;
8485
this->IsUpdateReady = false;
@@ -610,7 +611,6 @@ H5FDdsmBuffer::RequestPipelineUpdate() {
610611
H5FDdsmDebug("Send request pipeline update to " << i);
611612
this->SendCommandHeader(H5FD_DSM_PIPELINE_UPDATE, i, 0, 0);
612613
}
613-
614614
this->Comm->Barrier();
615615
return(H5FD_DSM_SUCCESS);
616616
}

H5FDdsmBuffer.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ class H5FDdsm_EXPORT H5FDdsmBuffer : public H5FDdsmDriver {
9292
H5FDdsmGetValueMacro(IsUpdateReady, H5FDdsmBoolean);
9393
H5FDdsmSetValueMacro(IsUpdateReady, H5FDdsmBoolean);
9494

95+
// Is the DSMBuffer auto allocated within the driver or not
96+
H5FDdsmGetValueMacro(IsAutoAllocated, bool);
97+
H5FDdsmSetValueMacro(IsAutoAllocated, bool);
98+
9599
// Is the DSMBuffer in server or client mode
96100
H5FDdsmGetValueMacro(IsServer, bool);
97101
H5FDdsmSetValueMacro(IsServer, bool);
@@ -132,6 +136,7 @@ class H5FDdsm_EXPORT H5FDdsmBuffer : public H5FDdsmDriver {
132136
volatile H5FDdsmInt32 ThreadDsmReady;
133137
volatile H5FDdsmBoolean IsConnected;
134138
volatile H5FDdsmBoolean IsUpdateReady;
139+
bool IsAutoAllocated;
135140
bool IsServer;
136141
bool IsReadOnly;
137142
H5FDdsmInt32 ServiceThreadUseCopy;

H5FDdsmCommMpi.cxx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ H5FDdsmCommMpi::OpenPort() {
192192
if (this->Id == 0) {
193193
MPI_Open_port(MPI_INFO_NULL, this->DsmMasterHostName);
194194
}
195-
this->Barrier();
196195
return(H5FD_DSM_SUCCESS);
197196
}
198197

@@ -203,7 +202,6 @@ H5FDdsmCommMpi::ClosePort() {
203202
if (this->Id == 0) {
204203
MPI_Close_port(this->DsmMasterHostName);
205204
}
206-
this->Barrier();
207205
return(H5FD_DSM_SUCCESS);
208206
}
209207

@@ -264,7 +262,7 @@ H5FDdsmInt32
264262
H5FDdsmCommMpi::RemoteCommDisconnect() {
265263

266264
if(H5FDdsmComm::RemoteCommDisconnect() != H5FD_DSM_SUCCESS) return(H5FD_DSM_FAIL);
267-
this->Barrier();
265+
268266
if (this->InterComm) {
269267
MPI_Comm_disconnect(&this->InterComm);
270268
this->InterComm = MPI_COMM_NULL;

H5FDdsmCommSocket.cxx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ H5FDdsmCommSocket::OpenPort()
233233
strcpy(this->DsmMasterHostName, this->DsmMasterSocket->GetHostName());
234234
this->DsmMasterSocket->Listen();
235235
}
236-
this->Barrier();
237236

238237
return(H5FD_DSM_SUCCESS);
239238
}
@@ -250,7 +249,6 @@ H5FDdsmCommSocket::ClosePort()
250249
return(H5FD_DSM_FAIL);
251250
}
252251
}
253-
this->Barrier();
254252

255253
return(H5FD_DSM_SUCCESS);
256254
}
@@ -326,7 +324,7 @@ H5FDdsmInt32
326324
H5FDdsmCommSocket::RemoteCommDisconnect()
327325
{
328326
if (H5FDdsmComm::RemoteCommDisconnect() != H5FD_DSM_SUCCESS) return(H5FD_DSM_FAIL);
329-
this->Barrier();
327+
330328
for (int i=0; i<H5FD_DSM_MAX_SOCKET; i++) {
331329
if (this->InterComm[i]) delete this->InterComm[i];
332330
this->InterComm[i] = NULL;

H5FDdsmManager.cxx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ int H5FDdsmManager::GetAcceptedConnection()
8585
{
8686
int ret = 0;
8787
if (this->DSMBuffer) {
88-
if (this->DSMBuffer->GetIsConnected()) return 1;
88+
if (this->DSMBuffer->GetIsConnected()) ret = 1;
8989
}
9090
return ret;
9191
}
@@ -94,7 +94,7 @@ int H5FDdsmManager::GetDsmUpdateReady()
9494
{
9595
int ret = 0;
9696
if (this->DSMBuffer) {
97-
if (this->DSMBuffer->GetIsUpdateReady()) return 1;
97+
if (this->DSMBuffer->GetIsUpdateReady()) ret = 1;
9898
}
9999
return ret;
100100
}
@@ -356,12 +356,12 @@ void H5FDdsmManager::PublishDSM()
356356
std::string fullDsmConfigFilePath;
357357
const char *dsmEnvPath = getenv("H5FD_DSM_CONFIG_PATH");
358358
if (!dsmEnvPath) dsmEnvPath = getenv("HOME");
359-
if (dsmEnvPath /*&& !this->GetDsmConfigFilePath()*/) {
359+
if (dsmEnvPath) {
360360
this->SetDsmConfigFilePath(dsmEnvPath);
361361
}
362362
if (this->GetDsmConfigFilePath()) {
363363
fullDsmConfigFilePath = std::string(this->GetDsmConfigFilePath()) +
364-
std::string("/.dsm_config");
364+
std::string("/.dsm_client_config");
365365
dsmConfigFile.Create(fullDsmConfigFilePath);
366366
dsmConfigFile.AddSection("Comm", fullDsmConfigFilePath);
367367

@@ -485,16 +485,21 @@ bool H5FDdsmManager::ReadDSMConfigFile()
485485
{
486486
H5FDdsmIniFile config;
487487
std::string configPath;
488+
std::string mode = "client";
488489
const char *dsmEnvPath = getenv("H5FD_DSM_CONFIG_PATH");
489-
if (!dsmEnvPath) dsmEnvPath = getenv("HOME");
490-
if (dsmEnvPath) {
491-
configPath = std::string(dsmEnvPath) + std::string("/.dsm_config");
490+
const char *dsmServerEnvPath = getenv("H5FD_DSM_SERVER_CONFIG_PATH");
491+
492+
if (dsmServerEnvPath) {
493+
mode = "server";
494+
configPath = std::string(dsmServerEnvPath) + std::string("/.dsm_server_config");
495+
} else {
496+
if (!dsmEnvPath) dsmEnvPath = getenv("HOME");
497+
configPath = std::string(dsmEnvPath) + std::string("/.dsm_client_config");
492498
}
493499
if (FileExists(configPath.c_str())) {
494500
if (this->UpdatePiece == 0) {
495501
std::cout << "Reading from " << configPath.c_str() << std::endl;
496502
}
497-
std::string mode = config.GetValue("DSM_INIT_MODE", "General", configPath);
498503
std::string size = config.GetValue("DSM_INIT_SIZE", "General", configPath);
499504

500505
std::string comm = config.GetValue("DSM_COMM_SYSTEM", "Comm", configPath);
@@ -512,11 +517,11 @@ bool H5FDdsmManager::ReadDSMConfigFile()
512517
// Comm settings
513518
if (comm == "socket") {
514519
this->SetDsmCommType(H5FD_DSM_COMM_SOCKET);
515-
if (mode != "server") this->SetServerPort(atoi(port.c_str()));
520+
this->SetServerPort(atoi(port.c_str()));
516521
} else if (comm == "mpi") {
517522
this->SetDsmCommType(H5FD_DSM_COMM_MPI);
518523
}
519-
if (mode != "server") this->SetServerHostName(host.c_str());
524+
this->SetServerHostName(host.c_str());
520525
return true;
521526
}
522527
return false;

0 commit comments

Comments
 (0)