Skip to content

Commit

Permalink
Upstream EVPath and SST updates to make the Visual Studio compiler ha…
Browse files Browse the repository at this point in the history
…ppy. (#4154)

 EVPath Upstream, SST changes to compile cleanly with visual studio
  • Loading branch information
eisenhauer authored May 4, 2024
1 parent da35b30 commit deb06eb
Show file tree
Hide file tree
Showing 44 changed files with 679 additions and 362 deletions.
2 changes: 1 addition & 1 deletion examples/hello/sstWriter/sstWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int main(int argc, char *argv[])
static_cast<float>(10.0 * rank + 6), static_cast<float>(10.0 * rank + 7),
static_cast<float>(10.0 * rank + 8), static_cast<float>(10.0 * rank + 9)};
const std::size_t Nx = myFloats.size();
const float increment = Nx * size * 1.0;
const float increment = (float)(Nx * size * 1.0);

try
{
Expand Down
3 changes: 3 additions & 0 deletions source/adios2/engine/sst/SstParamParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#include "adios2/helper/adiosFunctions.h"

#include "adios2/toolkit/sst/sst.h"
#ifdef _MSC_VER
#define strdup(x) _strdup(x)
#endif

using namespace adios2;
using namespace adios2::core;
Expand Down
2 changes: 2 additions & 0 deletions source/adios2/engine/sst/SstParamParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#include "adios2/common/ADIOSTypes.h"
#include "adios2/core/IO.h"
#include <iostream>
#ifndef _MSC_VER
#include <unistd.h>
#endif

#include "adios2/toolkit/sst/sst.h"

Expand Down
6 changes: 3 additions & 3 deletions source/adios2/engine/sst/SstReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ void SstReader::Init()
Count = variable.m_Count.data(); \
NeedSync = \
SstFFSGetLocalDeferred(m_Input, (void *)&variable, variable.m_Name.c_str(), \
DimCount, variable.m_BlockID, Count, data); \
DimCount, (int)variable.m_BlockID, Count, data); \
} \
if (NeedSync) \
{ \
Expand Down Expand Up @@ -595,7 +595,7 @@ void SstReader::Init()
DimCount = variable.m_Count.size(); \
Count = variable.m_Count.data(); \
SstFFSGetLocalDeferred(m_Input, (void *)&variable, variable.m_Name.c_str(), \
DimCount, variable.m_BlockID, Count, data); \
DimCount, (int)variable.m_BlockID, Count, data); \
} \
} \
if (m_WriterMarshalMethod == SstMarshalBP) \
Expand Down Expand Up @@ -681,7 +681,7 @@ void SstReader::BP5PerformGets()
{
dp_info = m_CurrentStepMetaData->DP_TimestepInfo[Req.WriterRank];
}
auto ret = SstReadRemoteMemory(m_Input, Req.WriterRank, Req.Timestep, Req.StartOffset,
auto ret = SstReadRemoteMemory(m_Input, (int)Req.WriterRank, Req.Timestep, Req.StartOffset,
Req.ReadLength, Req.DestinationAddr, dp_info);
sstReadHandlers.push_back(ret);
}
Expand Down
6 changes: 3 additions & 3 deletions source/adios2/engine/sst/SstReader.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void SstReader::ReadVariableBlocksRequests(Variable<T> &variable,
std::stringstream ss;
ss << "SST Bytes Read from remote rank " << rank;
PERFSTUBS_SAMPLE_COUNTER(ss.str().c_str(), payloadSize);
auto ret = SstReadRemoteMemory(m_Input, rank, CurrentStep(), payloadStart,
auto ret = SstReadRemoteMemory(m_Input, (int)rank, CurrentStep(), payloadStart,
payloadSize, buffer, dp_info);
sstReadHandlers.push_back(ret);
}
Expand All @@ -87,7 +87,7 @@ void SstReader::ReadVariableBlocksRequests(Variable<T> &variable,
subStreamInfo.IntersectionBox, m_BP3Deserializer->m_IsRowMajor,
elementOffset))
{
auto ret = SstReadRemoteMemory(m_Input, rank, CurrentStep(),
auto ret = SstReadRemoteMemory(m_Input, (int)rank, CurrentStep(),
writerBlockStart, writerBlockSize,
blockInfo.Data + elementOffset, dp_info);
sstReadHandlers.push_back(ret);
Expand All @@ -100,7 +100,7 @@ void SstReader::ReadVariableBlocksRequests(Variable<T> &variable,
buffers.emplace_back();
buffers.back().resize(writerBlockSize);
auto ret =
SstReadRemoteMemory(m_Input, rank, CurrentStep(), writerBlockStart,
SstReadRemoteMemory(m_Input, (int)rank, CurrentStep(), writerBlockStart,
writerBlockSize, buffers.back().data(), dp_info);
sstReadHandlers.push_back(ret);
}
Expand Down
2 changes: 1 addition & 1 deletion source/adios2/engine/sst/SstWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ void SstWriter::MarshalAttributes()
void *data_addr = &attribute.m_DataSingleValue; \
if (!attribute.m_IsSingleValue) \
{ \
element_count = attribute.m_Elements; \
element_count = (int)attribute.m_Elements; \
data_addr = attribute.m_DataArray.data(); \
} \
if (Params.MarshalMethod == SstMarshalFFS) \
Expand Down
5 changes: 4 additions & 1 deletion source/adios2/toolkit/remote/Remote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#include "adios2/helper/adiosLog.h"
#include "adios2/helper/adiosString.h"
#include "adios2/helper/adiosSystem.h"
#ifdef _MSC_VER
#define strdup(x) _strdup(x)
#endif

namespace adios2
{
Expand Down Expand Up @@ -160,7 +163,7 @@ Remote::GetHandle Remote::Get(char *VarName, size_t Step, size_t BlockID, Dims &
GetMsg.VarName = VarName;
GetMsg.Step = Step;
GetMsg.BlockID = BlockID;
GetMsg.DimCount = Count.size();
GetMsg.DimCount = (int)Count.size();
GetMsg.Count = Count.data();
GetMsg.Start = Start.data();
GetMsg.Dest = dest;
Expand Down
55 changes: 50 additions & 5 deletions source/adios2/toolkit/remote/remote_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,21 @@
#include <regex>
#include <sys/stat.h> // open, fstat
#include <sys/types.h> // open
#include <unistd.h> // write, close, ftruncate
#ifndef _MSC_VER
#include <unistd.h> // write, close, ftruncate
#else
#include <io.h>
#define strdup _strdup
#define strlen _strlen
#define fileno _fileno
#define getpid _getpid
#define unlink _unlink
#define close _close
#define sleep(x) Sleep(x * 1000);
#define read _read
#define lseek _lseek
#define open _open
#endif

#include "remote_common.h"

Expand Down Expand Up @@ -48,7 +62,7 @@ std::string readable_size(uint64_t size)
s = s / 1024;
idx++;
}
int point = r / 100;
int point = (int)(r / 100);
std::ostringstream out;
out << "" << s;
if (point != 0)
Expand Down Expand Up @@ -304,15 +318,15 @@ static void ReadRequestHandler(CManager cm, CMConnection conn, void *vevent, voi
last_service_time = std::chrono::steady_clock::now();
if (f->m_CurrentOffset != ReadMsg->Offset)
{
lseek(f->m_FileDescriptor, ReadMsg->Offset, SEEK_SET);
lseek(f->m_FileDescriptor, (long)ReadMsg->Offset, SEEK_SET);
f->m_CurrentOffset = ReadMsg->Offset;
}
char *tmp = (char *)malloc(ReadMsg->Size);
size_t remaining = ReadMsg->Size;
char *pointer = tmp;
while (remaining > 0)
{
ssize_t ret = read(f->m_FileDescriptor, pointer, remaining);
ssize_t ret = read(f->m_FileDescriptor, pointer, (int)remaining);
if (ret <= 0)
{
// EOF or error, should send a message back, but we haven't define error handling yet
Expand Down Expand Up @@ -502,7 +516,7 @@ static void timer_start(void *param, unsigned int interval)
auto secs =
std::chrono::duration_cast<std::chrono::seconds>(now - last_service_time).count();
auto x = now + std::chrono::milliseconds(interval);
if (server_timeout(param, secs))
if (server_timeout(param, (int)secs))
return;
std::this_thread::sleep_until(x);
}
Expand Down Expand Up @@ -570,6 +584,36 @@ int main(int argc, char **argv)
{
printf("Forking server to background\n");
}
#ifdef _MSC_VER
STARTUPINFO si;
PROCESS_INFORMATION pi;
char comm_line[8191];

ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
char module[MAX_PATH];
GetModuleFileName(NULL, &module[0], MAX_PATH);
int i = 1;
strcpy(comm_line, module);
strcat(comm_line, " ");
if (!CreateProcess(module, comm_line,
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi))
{
printf("CreateProcess failed (%d).\n", GetLastError());
// printf("Args were argv[0] = %s\n", args[0]);
// printf("Args were argv[1] = %s, argv[2] = %s\n", args[1], args[2]);
exit(1);
}
exit(0);
#else
if (fork() != 0)
{
/* I'm the parent, wait a sec to let the child start, then exit */
Expand All @@ -581,6 +625,7 @@ int main(int argc, char **argv)
close(0);
close(1);
close(2);
#endif
}

cm = CManager_create();
Expand Down
27 changes: 18 additions & 9 deletions source/adios2/toolkit/sst/cp/cp_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
#include "adios2/common/ADIOSConfig.h"
#include <atl.h>
#include <evpath.h>
#ifndef _MSC_VER
#include <pthread.h>
#include <sys/time.h>
#include <unistd.h>
#else
#include "../win_interface.h"
#endif

#include "sst.h"

Expand Down Expand Up @@ -443,7 +450,7 @@ static FMStructDescRec MetaDataPlusDPInfoStructs[] = {

static FMField TimestepMetadataList[] = {
{"RS_Stream", "integer", sizeof(void *), FMOffset(struct _TimestepMetadataMsg *, RS_Stream)},
{"timestep", "integer", sizeof(int), FMOffset(struct _TimestepMetadataMsg *, Timestep)},
{"timestep", "integer", sizeof(ssize_t), FMOffset(struct _TimestepMetadataMsg *, Timestep)},
{"cohort_size", "integer", sizeof(int), FMOffset(struct _TimestepMetadataMsg *, CohortSize)},
{"preload_mode", "integer", sizeof(int), FMOffset(struct _TimestepMetadataMsg *, PreloadMode)},
{"formats", "*FFSFormatBlock", sizeof(struct FFSFormatBlock),
Expand All @@ -470,7 +477,7 @@ static FMField TimestepMetadataDistributionList[] = {
{NULL, NULL, 0, 0}};

static FMField ReleaseRecList[] = {
{"Timestep", "integer", sizeof(long), FMOffset(struct _ReleaseRec *, Timestep)},
{"Timestep", "integer", sizeof(ssize_t), FMOffset(struct _ReleaseRec *, Timestep)},
{"Reader", "integer", sizeof(void *), FMOffset(struct _ReleaseRec *, Reader)},
{NULL, NULL, 0, 0}};

Expand Down Expand Up @@ -512,7 +519,7 @@ static FMStructDescRec ReturnMetadataInfoStructs[] = {

static FMField ReleaseTimestepList[] = {
{"WSR_Stream", "integer", sizeof(void *), FMOffset(struct _ReleaseTimestepMsg *, WSR_Stream)},
{"Timestep", "integer", sizeof(int), FMOffset(struct _ReleaseTimestepMsg *, Timestep)},
{"Timestep", "integer", sizeof(ssize_t), FMOffset(struct _ReleaseTimestepMsg *, Timestep)},
{NULL, NULL, 0, 0}};

static FMStructDescRec ReleaseTimestepStructs[] = {
Expand All @@ -522,7 +529,8 @@ static FMStructDescRec ReleaseTimestepStructs[] = {
static FMField LockReaderDefinitionsList[] = {
{"WSR_Stream", "integer", sizeof(void *),
FMOffset(struct _LockReaderDefinitionsMsg *, WSR_Stream)},
{"Timestep", "integer", sizeof(int), FMOffset(struct _LockReaderDefinitionsMsg *, Timestep)},
{"Timestep", "integer", sizeof(ssize_t),
FMOffset(struct _LockReaderDefinitionsMsg *, Timestep)},
{NULL, NULL, 0, 0}};

static FMStructDescRec LockReaderDefinitionsStructs[] = {
Expand All @@ -532,7 +540,7 @@ static FMStructDescRec LockReaderDefinitionsStructs[] = {

static FMField CommPatternLockedList[] = {
{"RS_Stream", "integer", sizeof(void *), FMOffset(struct _CommPatternLockedMsg *, RS_Stream)},
{"Timestep", "integer", sizeof(int), FMOffset(struct _CommPatternLockedMsg *, Timestep)},
{"Timestep", "integer", sizeof(ssize_t), FMOffset(struct _CommPatternLockedMsg *, Timestep)},
{NULL, NULL, 0, 0}};

static FMStructDescRec CommPatternLockedStructs[] = {
Expand Down Expand Up @@ -567,7 +575,8 @@ static FMStructDescRec ReaderRequestStepStructs[] = {

static FMField WriterCloseList[] = {
{"RS_Stream", "integer", sizeof(void *), FMOffset(struct _WriterCloseMsg *, RS_Stream)},
{"FinalTimestep", "integer", sizeof(int), FMOffset(struct _WriterCloseMsg *, FinalTimestep)},
{"FinalTimestep", "integer", sizeof(ssize_t),
FMOffset(struct _WriterCloseMsg *, FinalTimestep)},
{NULL, NULL, 0, 0}};

static FMStructDescRec WriterCloseStructs[] = {
Expand Down Expand Up @@ -729,7 +738,7 @@ void **CP_consolidateDataToRankZero(SstStream Stream, void *LocalInfo, FFSTypeHa
* can gather the data
*/

SMPI_Gatherv(Buffer, DataSize, SMPI_CHAR, RecvBuffer, RecvCounts, Displs, SMPI_CHAR, 0,
SMPI_Gatherv(Buffer, (int)DataSize, SMPI_CHAR, RecvBuffer, RecvCounts, Displs, SMPI_CHAR, 0,
Stream->mpiComm);
free_FFSBuffer(Buf);

Expand Down Expand Up @@ -836,7 +845,7 @@ void **CP_consolidateDataToAll(SstStream Stream, void *LocalInfo, FFSTypeHandle
* can gather the data
*/

SMPI_Allgatherv(Buffer, DataSize, SMPI_CHAR, RecvBuffer, RecvCounts, Displs, SMPI_CHAR,
SMPI_Allgatherv(Buffer, (int)DataSize, SMPI_CHAR, RecvBuffer, RecvCounts, Displs, SMPI_CHAR,
Stream->mpiComm);
free_FFSBuffer(Buf);

Expand Down Expand Up @@ -1025,7 +1034,7 @@ static void ReadableSizeString(size_t SizeInBytes, char *Output, size_t size)
}
else
{
snprintf(Output, size, "%ld %s", SizeInBytes, byteUnits[i]);
snprintf(Output, size, "%zd %s", SizeInBytes, byteUnits[i]);
}
};

Expand Down
Loading

0 comments on commit deb06eb

Please sign in to comment.