Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass Array Order of reader to remote server for proper Get() operation #3810

Merged
merged 2 commits into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions source/adios2/engine/bp5/BP5Reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,13 +467,15 @@ void BP5Reader::Init()

// This isn't how we'll trigger remote ops in the end, but a temporary
// solution
bool RowMajorOrdering = (m_IO.m_ArrayOrder == ArrayOrdering::RowMajor);
if (!m_Parameters.RemoteDataPath.empty())
{
m_Remote.Open("localhost", 26200, m_Parameters.RemoteDataPath, m_OpenMode);
m_Remote.Open("localhost", 26200, m_Parameters.RemoteDataPath, m_OpenMode,
RowMajorOrdering);
}
else if (getenv("DoRemote"))
{
m_Remote.Open("localhost", 26200, m_Name, m_OpenMode);
m_Remote.Open("localhost", 26200, m_Name, m_OpenMode, RowMajorOrdering);
}
}

Expand Down
5 changes: 3 additions & 2 deletions source/adios2/toolkit/remote/Remote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void Remote::InitCMData()
}

void Remote::Open(const std::string hostname, const int32_t port, const std::string filename,
const Mode mode)
const Mode mode, bool RowMajorOrdering)
{

RemoteCommon::_OpenFileMsg open_msg;
Expand Down Expand Up @@ -102,6 +102,7 @@ void Remote::Open(const std::string hostname, const int32_t port, const std::str
break;
}
open_msg.OpenResponseCondition = CMCondition_get(ev_state.cm, m_conn);
open_msg.RowMajorOrder = RowMajorOrdering;
CMCondition_set_client_data(ev_state.cm, open_msg.OpenResponseCondition, (void *)this);
CMwrite(m_conn, ev_state.OpenFileFormat, &open_msg);
CMCondition_wait(ev_state.cm, open_msg.OpenResponseCondition);
Expand Down Expand Up @@ -171,7 +172,7 @@ bool Remote::WaitForGet(GetHandle handle) { return CMCondition_wait(ev_state.cm,
#else

void Remote::Open(const std::string hostname, const int32_t port, const std::string filename,
const Mode mode){};
const Mode mode, bool RowMajorOrdering){};

void Remote::OpenSimpleFile(const std::string hostname, const int32_t port,
const std::string filename){};
Expand Down
2 changes: 1 addition & 1 deletion source/adios2/toolkit/remote/Remote.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Remote
explicit operator bool() const { return m_Active; }

void Open(const std::string hostname, const int32_t port, const std::string filename,
const Mode mode);
const Mode mode, bool RowMajorOrdering);

void OpenSimpleFile(const std::string hostname, const int32_t port, const std::string filename);

Expand Down
12 changes: 7 additions & 5 deletions source/adios2/toolkit/remote/remote_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ namespace adios2
namespace RemoteCommon
{

FMField OpenFileList[] = {{"OpenResponseCondition", "integer", sizeof(long),
FMOffset(OpenFileMsg, OpenResponseCondition)},
{"FileName", "string", sizeof(char *), FMOffset(OpenFileMsg, FileName)},
{"Mode", "integer", sizeof(RemoteFileMode), FMOffset(OpenFileMsg, Mode)},
{NULL, NULL, 0, 0}};
FMField OpenFileList[] = {
{"OpenResponseCondition", "integer", sizeof(long),
FMOffset(OpenFileMsg, OpenResponseCondition)},
{"FileName", "string", sizeof(char *), FMOffset(OpenFileMsg, FileName)},
{"Mode", "integer", sizeof(RemoteFileMode), FMOffset(OpenFileMsg, Mode)},
{"RowMajorOrder", "integer", sizeof(RemoteFileMode), FMOffset(OpenFileMsg, RowMajorOrder)},
{NULL, NULL, 0, 0}};

FMStructDescRec OpenFileStructs[] = {{"OpenFile", OpenFileList, sizeof(struct _OpenFileMsg), NULL},
{NULL, NULL, 0, NULL}};
Expand Down
1 change: 1 addition & 0 deletions source/adios2/toolkit/remote/remote_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ typedef struct _OpenFileMsg
int OpenResponseCondition;
char *FileName;
RemoteFileMode Mode;
int RowMajorOrder;
} *OpenFileMsg;

typedef struct _OpenResponseMsg
Expand Down
9 changes: 6 additions & 3 deletions source/adios2/toolkit/remote/remote_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,14 @@ class AnonADIOSFile
size_t m_BytesSent = 0;
size_t m_OperationCount = 0;
RemoteFileMode m_mode = RemoteCommon::RemoteFileMode::RemoteOpen;
AnonADIOSFile(std::string FileName, RemoteCommon::RemoteFileMode mode)
AnonADIOSFile(std::string FileName, RemoteCommon::RemoteFileMode mode, bool RowMajorArrays)
{
Mode adios_read_mode = adios2::Mode::Read;
m_FileName = FileName;
m_IOname = lf_random_string();
m_io = &adios.DeclareIO(m_IOname);
ArrayOrdering ArrayOrder =
RowMajorArrays ? ArrayOrdering::RowMajor : ArrayOrdering::ColumnMajor;
m_io = &adios.DeclareIO(m_IOname, ArrayOrder);
m_mode = mode;
if (m_mode == RemoteOpenRandomAccess)
adios_read_mode = adios2::Mode::ReadRandomAccess;
Expand Down Expand Up @@ -163,7 +165,8 @@ static void OpenHandler(CManager cm, CMConnection conn, void *vevent, void *clie
struct Remote_evpath_state *ev_state = static_cast<struct Remote_evpath_state *>(client_data);
_OpenResponseMsg open_response_msg;
std::cout << "Got an open request for file " << open_msg->FileName << std::endl;
AnonADIOSFile *f = new AnonADIOSFile(open_msg->FileName, open_msg->Mode);
AnonADIOSFile *f =
new AnonADIOSFile(open_msg->FileName, open_msg->Mode, open_msg->RowMajorOrder);
memset(&open_response_msg, 0, sizeof(open_response_msg));
open_response_msg.FileHandle = f->m_ID;
open_response_msg.OpenResponseCondition = open_msg->OpenResponseCondition;
Expand Down