From deb06eb79f8ac6976a80fc762b7b441073e2c052 Mon Sep 17 00:00:00 2001 From: Greg Eisenhauer Date: Sat, 4 May 2024 11:09:18 -0400 Subject: [PATCH] Upstream EVPath and SST updates to make the Visual Studio compiler happy. (#4154) EVPath Upstream, SST changes to compile cleanly with visual studio --- examples/hello/sstWriter/sstWriter.cpp | 2 +- source/adios2/engine/sst/SstParamParser.cpp | 3 + source/adios2/engine/sst/SstParamParser.h | 2 + source/adios2/engine/sst/SstReader.cpp | 6 +- source/adios2/engine/sst/SstReader.tcc | 6 +- source/adios2/engine/sst/SstWriter.cpp | 2 +- source/adios2/toolkit/remote/Remote.cpp | 5 +- .../adios2/toolkit/remote/remote_server.cpp | 55 +++++++- source/adios2/toolkit/sst/cp/cp_common.c | 27 ++-- source/adios2/toolkit/sst/cp/cp_internal.h | 53 ++++---- source/adios2/toolkit/sst/cp/cp_reader.c | 82 +++++++----- source/adios2/toolkit/sst/cp/cp_writer.c | 48 ++++--- source/adios2/toolkit/sst/cp/ffs_marshal.c | 117 +++++++++--------- source/adios2/toolkit/sst/dp/daos_dp.c | 6 +- source/adios2/toolkit/sst/dp/dp.c | 5 + source/adios2/toolkit/sst/dp/dummy_dp.c | 37 +++--- source/adios2/toolkit/sst/dp/evpath_dp.c | 85 +++++++------ source/adios2/toolkit/sst/dp/mpi_dp.c | 22 ++-- source/adios2/toolkit/sst/dp/rdma_dp.c | 20 +-- source/adios2/toolkit/sst/dp/ucx_dp.c | 8 +- source/adios2/toolkit/sst/dp_interface.h | 20 +-- source/adios2/toolkit/sst/sst.h | 12 +- .../adios2/toolkit/sst/util/sst_conn_tool.c | 14 ++- .../adios2/toolkit/sst/util/sst_conn_tool.cxx | 5 +- source/adios2/toolkit/sst/win_interface.h | 56 +++++++++ .../toolkit/transport/file/FileRemote.cpp | 5 +- .../toolkit/transportman/TransportMan.cpp | 3 + .../engine/staging-common/TestThreads.cpp | 13 +- thirdparty/EVPath/EVPath/cm.c | 9 +- thirdparty/EVPath/EVPath/cm_control.c | 4 +- thirdparty/EVPath/EVPath/cm_internal.h | 43 ++++--- thirdparty/EVPath/EVPath/cm_threadio.c | 2 +- thirdparty/EVPath/EVPath/cm_util.c | 54 +++++++- thirdparty/EVPath/EVPath/cmselect.c | 26 ++-- thirdparty/EVPath/EVPath/cmsockets.c | 23 +++- thirdparty/EVPath/EVPath/ev_internal.h | 2 +- thirdparty/EVPath/EVPath/evp.c | 4 +- thirdparty/EVPath/EVPath/mtests/cmconn.c | 3 +- thirdparty/EVPath/EVPath/mtests/support.c | 39 +++++- thirdparty/EVPath/EVPath/tests/auto_test.c | 8 +- thirdparty/EVPath/EVPath/tests/block_test.c | 24 ++-- thirdparty/EVPath/EVPath/tests/bulktest.c | 31 ++--- thirdparty/EVPath/EVPath/tests/evtest.c | 8 +- thirdparty/EVPath/EVPath/tests/support.c | 42 ++++++- 44 files changed, 679 insertions(+), 362 deletions(-) create mode 100644 source/adios2/toolkit/sst/win_interface.h diff --git a/examples/hello/sstWriter/sstWriter.cpp b/examples/hello/sstWriter/sstWriter.cpp index 47e8c1b447..4bb1b12988 100644 --- a/examples/hello/sstWriter/sstWriter.cpp +++ b/examples/hello/sstWriter/sstWriter.cpp @@ -53,7 +53,7 @@ int main(int argc, char *argv[]) static_cast(10.0 * rank + 6), static_cast(10.0 * rank + 7), static_cast(10.0 * rank + 8), static_cast(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 { diff --git a/source/adios2/engine/sst/SstParamParser.cpp b/source/adios2/engine/sst/SstParamParser.cpp index 2b7041afa6..8f0bc36fa9 100644 --- a/source/adios2/engine/sst/SstParamParser.cpp +++ b/source/adios2/engine/sst/SstParamParser.cpp @@ -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; diff --git a/source/adios2/engine/sst/SstParamParser.h b/source/adios2/engine/sst/SstParamParser.h index 251c74cfa9..30650defb6 100644 --- a/source/adios2/engine/sst/SstParamParser.h +++ b/source/adios2/engine/sst/SstParamParser.h @@ -5,7 +5,9 @@ #include "adios2/common/ADIOSTypes.h" #include "adios2/core/IO.h" #include +#ifndef _MSC_VER #include +#endif #include "adios2/toolkit/sst/sst.h" diff --git a/source/adios2/engine/sst/SstReader.cpp b/source/adios2/engine/sst/SstReader.cpp index 03bfced452..07faa491bb 100644 --- a/source/adios2/engine/sst/SstReader.cpp +++ b/source/adios2/engine/sst/SstReader.cpp @@ -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) \ { \ @@ -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) \ @@ -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); } diff --git a/source/adios2/engine/sst/SstReader.tcc b/source/adios2/engine/sst/SstReader.tcc index 05b4334fcd..39844b1c75 100644 --- a/source/adios2/engine/sst/SstReader.tcc +++ b/source/adios2/engine/sst/SstReader.tcc @@ -65,7 +65,7 @@ void SstReader::ReadVariableBlocksRequests(Variable &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); } @@ -87,7 +87,7 @@ void SstReader::ReadVariableBlocksRequests(Variable &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); @@ -100,7 +100,7 @@ void SstReader::ReadVariableBlocksRequests(Variable &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); } diff --git a/source/adios2/engine/sst/SstWriter.cpp b/source/adios2/engine/sst/SstWriter.cpp index 146ff0f735..de257b5e3a 100644 --- a/source/adios2/engine/sst/SstWriter.cpp +++ b/source/adios2/engine/sst/SstWriter.cpp @@ -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) \ diff --git a/source/adios2/toolkit/remote/Remote.cpp b/source/adios2/toolkit/remote/Remote.cpp index a48fa1610b..053925a0fa 100644 --- a/source/adios2/toolkit/remote/Remote.cpp +++ b/source/adios2/toolkit/remote/Remote.cpp @@ -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 { @@ -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; diff --git a/source/adios2/toolkit/remote/remote_server.cpp b/source/adios2/toolkit/remote/remote_server.cpp index 4b79d787e6..dfc5680a42 100644 --- a/source/adios2/toolkit/remote/remote_server.cpp +++ b/source/adios2/toolkit/remote/remote_server.cpp @@ -18,7 +18,21 @@ #include #include // open, fstat #include // open -#include // write, close, ftruncate +#ifndef _MSC_VER +#include // write, close, ftruncate +#else +#include +#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" @@ -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) @@ -304,7 +318,7 @@ 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); @@ -312,7 +326,7 @@ static void ReadRequestHandler(CManager cm, CMConnection conn, void *vevent, voi 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 @@ -502,7 +516,7 @@ static void timer_start(void *param, unsigned int interval) auto secs = std::chrono::duration_cast(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); } @@ -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 */ @@ -581,6 +625,7 @@ int main(int argc, char **argv) close(0); close(1); close(2); +#endif } cm = CManager_create(); diff --git a/source/adios2/toolkit/sst/cp/cp_common.c b/source/adios2/toolkit/sst/cp/cp_common.c index f37124f202..c7a779472f 100644 --- a/source/adios2/toolkit/sst/cp/cp_common.c +++ b/source/adios2/toolkit/sst/cp/cp_common.c @@ -8,6 +8,13 @@ #include "adios2/common/ADIOSConfig.h" #include #include +#ifndef _MSC_VER +#include +#include +#include +#else +#include "../win_interface.h" +#endif #include "sst.h" @@ -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), @@ -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}}; @@ -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[] = { @@ -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[] = { @@ -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[] = { @@ -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[] = { @@ -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); @@ -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); @@ -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]); } }; diff --git a/source/adios2/toolkit/sst/cp/cp_internal.h b/source/adios2/toolkit/sst/cp/cp_internal.h index aac69cd0d2..625166b3fb 100644 --- a/source/adios2/toolkit/sst/cp/cp_internal.h +++ b/source/adios2/toolkit/sst/cp/cp_internal.h @@ -1,5 +1,7 @@ #include "dp_interface.h" +#ifndef _MSC_VER #include +#endif #define SSTMAGICV0 "#ADIOS2-SST v0\n" @@ -83,7 +85,7 @@ extern char *SSTStreamStatusStr[]; struct _SentTimestepRec { - long Timestep; + ssize_t Timestep; struct _SentTimestepRec *Next; }; @@ -92,15 +94,15 @@ typedef struct _WS_ReaderInfo SstStream ParentStream; enum StreamStatus ReaderStatus; void *RankZeroID; - long StartingTimestep; - long LastSentTimestep; + ssize_t StartingTimestep; + ssize_t LastSentTimestep; int LocalReaderDefinitionsLocked; - int LastReleasedTimestep; + ssize_t LastReleasedTimestep; int FullCommPatternLocked; - int CommPatternLockTimestep; + ssize_t CommPatternLockTimestep; SstPreloadModeType PreloadMode; - long PreloadModeActiveTimestep; - long OldestUnreleasedTimestep; + ssize_t PreloadModeActiveTimestep; + ssize_t OldestUnreleasedTimestep; size_t FormatSentCount; struct _SentTimestepRec *SentTimestepList; void *DP_WSR_Stream; @@ -123,7 +125,7 @@ enum StreamRole typedef struct _CPTimestepEntry { - long Timestep; + ssize_t Timestep; struct _SstData Data; struct _TimestepMetadataMsg *Msg; int MetaDataSendCount; @@ -174,13 +176,13 @@ struct _SstStream SstParams ConfigParams; /* WRITER-SIDE FIELDS */ - int WriterTimestep; - int LastReleasedTimestep; + ssize_t WriterTimestep; + ssize_t LastReleasedTimestep; CPTimestepList QueuedTimesteps; int QueuedTimestepCount; int QueueLimit; SstQueueFullPolicy QueueFullPolicy; - int LastProvidedTimestep; + ssize_t LastProvidedTimestep; int WriterDefinitionsLocked; size_t NextRRDistribution; size_t LastDemandTimestep; @@ -216,11 +218,11 @@ struct _SstStream /* READER-SIDE FIELDS */ struct _TimestepMetadataList *Timesteps; int WriterCohortSize; - int ReaderTimestep; + ssize_t ReaderTimestep; int *Peers; CP_PeerConnection *ConnectionsToWriter; - int FinalTimestep; - int CurrentWorkingTimestep; + ssize_t FinalTimestep; + ssize_t CurrentWorkingTimestep; SstFullMetadata CurrentMetadata; struct _SstMetaMetaBlockInternal *InternalMetaMetaInfo; int InternalMetaMetaCount; @@ -230,10 +232,10 @@ struct _SstStream struct _SstParams *WriterConfigParams; void *ParamsBlock; int CommPatternLocked; - int CommPatternLockedTimestep; - long DiscardPriorTimestep; /* timesteps numerically less than this will be + ssize_t CommPatternLockedTimestep; + ssize_t DiscardPriorTimestep; /* timesteps numerically less than this will be discarded with prejudice */ - long LastDPNotifiedTimestep; + ssize_t LastDPNotifiedTimestep; int FailureContactRank; /* reader side marshal info */ @@ -409,7 +411,7 @@ struct _ReaderRequestStepMsg typedef struct _TimestepMetadataMsg { void *RS_Stream; - int Timestep; + ssize_t Timestep; int CohortSize; SstPreloadModeType PreloadMode; FFSFormatList Formats; @@ -426,7 +428,7 @@ typedef struct _TimestepMetadataDistributionMsg { int ReturnValue; TSMetadataMsg TSmsg; - int CommPatternLockedTimestep; + ssize_t CommPatternLockedTimestep; } *TSMetadataDistributionMsg; /* @@ -437,7 +439,7 @@ typedef struct _TimestepMetadataDistributionMsg typedef struct _ReleaseRec { - long Timestep; + ssize_t Timestep; void *Reader; } *ReleaseRecPtr; @@ -462,7 +464,7 @@ typedef struct _ReturnMetadataInfo struct _ReleaseTimestepMsg { void *WSR_Stream; - int Timestep; + ssize_t Timestep; }; /* @@ -472,7 +474,7 @@ struct _ReleaseTimestepMsg struct _LockReaderDefinitionsMsg { void *WSR_Stream; - int Timestep; + ssize_t Timestep; }; /* @@ -482,7 +484,7 @@ struct _LockReaderDefinitionsMsg typedef struct _CommPatternLockedMsg { void *RS_Stream; - int Timestep; + ssize_t Timestep; } *CommPatternLockedMsg; /* @@ -495,7 +497,7 @@ typedef struct _CommPatternLockedMsg typedef struct _WriterCloseMsg { void *RS_Stream; - int FinalTimestep; + ssize_t FinalTimestep; } *WriterCloseMsg; /* @@ -530,7 +532,7 @@ extern CP_Info CP_getCPInfo(char *ControlModule); extern char *CP_GetContactString(SstStream s, attr_list DPAttrs); extern SstStream CP_newStream(); extern void SstInternalProvideTimestep(SstStream s, SstData LocalMetadata, SstData Data, - long Timestep, FFSFormatList Formats, + ssize_t Timestep, FFSFormatList Formats, DataFreeFunc FreeTimestep, void *FreeClientData, SstData AttributeData, DataFreeFunc FreeAttributeData, void *FreeAttributeClientData); @@ -599,3 +601,4 @@ extern char *IPDiagString; extern CPNetworkInfoFunc globalNetinfoCallback; extern void SSTSetNetworkCallback(CPNetworkInfoFunc callback); extern void DoStreamSummary(SstStream Stream); +#define SSIZE_T_MAX (9223372036854775807) diff --git a/source/adios2/toolkit/sst/cp/cp_reader.c b/source/adios2/toolkit/sst/cp/cp_reader.c index 13a504f07b..1f0daef7fa 100644 --- a/source/adios2/toolkit/sst/cp/cp_reader.c +++ b/source/adios2/toolkit/sst/cp/cp_reader.c @@ -7,13 +7,17 @@ #include #include #include +#ifndef _MSC_VER +#include #include #include +#else +#include "../win_interface.h" +#endif #include "adios2/common/ADIOSConfig.h" #include #include -#include #include "sst.h" @@ -99,7 +103,11 @@ static char *readContactInfoFile(const char *Name, SstStream Stream, int Timeout while (!WriterInfo) { // CMusleep(Stream->CPInfo->cm, SleepInterval); +#ifdef _MSC_VER + Sleep(SleepInterval / 1000); +#else usleep(SleepInterval); +#endif TimeoutRemainingMsec -= (SleepInterval / 1000); WaitWarningRemainingMsec -= (SleepInterval / 1000); if (WaitWarningRemainingMsec == 0) @@ -138,14 +146,19 @@ static char *readContactInfoFile(const char *Name, SstStream Stream, int Timeout } else { - char Tmp[strlen(SSTMAGICV0)]; + char Tmp[40]; + if (sizeof(Tmp) < strlen(SSTMAGICV0)) + { + printf("SSTMAGIC too long\n"); + exit(1); + } if (fread(Tmp, strlen(SSTMAGICV0), 1, WriterInfo) != 1) { fprintf(stderr, "Filesystem read failed in SST Open, failing operation\n"); fclose(WriterInfo); Badfile++; } - Size -= strlen(SSTMAGICV0); + Size -= (int)strlen(SSTMAGICV0); if (strncmp(Tmp, SSTMAGICV0, strlen(SSTMAGICV0)) != 0) { Badfile++; @@ -297,9 +310,9 @@ extern void ReaderConnCloseHandler(CManager cm, CMConnection ClosedConn, void *c // SstCurrentStep is only called by the main program thread and // needs no locking as it only accesses data set by the main thread -extern long SstCurrentStep(SstStream Stream) { return Stream->ReaderTimestep; } +extern size_t SstCurrentStep(SstStream Stream) { return (size_t)Stream->ReaderTimestep; } -static void releasePriorTimesteps(SstStream Stream, long Latest); +static void releasePriorTimesteps(SstStream Stream, ssize_t Latest); static void sendOneToEachWriterRank(SstStream s, CMFormat f, void *Msg, void **WS_StreamPtr); static void **ParticipateInReaderInitDataExchange(SstStream Stream, void *dpInfo, @@ -389,7 +402,7 @@ attr_list ContactWriter(SstStream Stream, char *Filename, SstParams Params, SMPI } if (conn) { - DataSize = strlen(CMContactString) + 1; + DataSize = (int)strlen(CMContactString) + 1; *conn_p = conn; } else @@ -452,7 +465,7 @@ SstStream SstReaderOpen(const char *Name, SstParams Params, SMPI_Comm comm) Stream->CPInfo = CP_getCPInfo(Stream->ConfigParams->ControlModule); - Stream->FinalTimestep = INT_MAX; /* set this on close */ + Stream->FinalTimestep = SSIZE_T_MAX; /* set this on close */ Stream->LastDPNotifiedTimestep = -1; gettimeofday(&Start, NULL); @@ -580,7 +593,7 @@ SstStream SstReaderOpen(const char *Name, SstParams Params, SMPI_Comm comm) /* the response value is set in the handler */ volatile struct _WriterResponseMsg *response = NULL; CMCondition_set_client_data(Stream->CPInfo->SharedCM->cm, - ReaderRegister.WriterResponseCondition, &response); + ReaderRegister.WriterResponseCondition, (void *)&response); if (CMwrite(rank0_to_rank0_conn, Stream->CPInfo->SharedCM->ReaderRegisterFormat, &ReaderRegister) != 1) @@ -865,7 +878,7 @@ void queueTimestepMetadataMsgAndNotify(SstStream Stream, struct _TimestepMetadat struct _SstMetaMetaBlockInternal { - size_t TimestepAdded; + ssize_t TimestepAdded; char *BlockData; size_t BlockSize; char *ID; @@ -1102,10 +1115,10 @@ extern void CP_CommPatternLockedHandler(CManager cm, CMConnection conn, void *Ms STREAM_MUTEX_UNLOCK(Stream); } -static long MaxQueuedMetadata(SstStream Stream) +static ssize_t MaxQueuedMetadata(SstStream Stream) { struct _TimestepMetadataList *Next; - long MaxTimestep = -1; + ssize_t MaxTimestep = -1; STREAM_ASSERT_LOCKED(Stream); Next = Stream->Timesteps; if (Next == NULL) @@ -1125,10 +1138,10 @@ static long MaxQueuedMetadata(SstStream Stream) return MaxTimestep; } -static long NextQueuedMetadata(SstStream Stream) +static ssize_t NextQueuedMetadata(SstStream Stream) { struct _TimestepMetadataList *Next; - long MinTimestep = LONG_MAX; + ssize_t MinTimestep = SSIZE_T_MAX; STREAM_ASSERT_LOCKED(Stream); Next = Stream->Timesteps; if (Next == NULL) @@ -1163,8 +1176,8 @@ static void waitForMetadataWithTimeout(SstStream Stream, float timeout_secs) { struct _TimestepMetadataList *Next; struct timeval start, now, end; - int timeout_int_sec = floor(timeout_secs); - int timeout_int_usec = ((timeout_secs - floorf(timeout_secs)) * 1000000); + int timeout_int_sec = (int)floor(timeout_secs); + int timeout_int_usec = (int)((timeout_secs - floorf(timeout_secs)) * 1000000); CMTaskHandle TimeoutTask = NULL; STREAM_ASSERT_LOCKED(Stream); @@ -1230,7 +1243,7 @@ static void waitForMetadataWithTimeout(SstStream Stream, float timeout_secs) /* NOTREACHED */ } -static void releasePriorTimesteps(SstStream Stream, long Latest) +static void releasePriorTimesteps(SstStream Stream, ssize_t Latest) { struct _TimestepMetadataList *Next, *Last; STREAM_ASSERT_LOCKED(Stream); @@ -1299,7 +1312,7 @@ static void releasePriorTimesteps(SstStream Stream, long Latest) } } -static void FreeTimestep(SstStream Stream, long Timestep) +static void FreeTimestep(SstStream Stream, ssize_t Timestep) { /* * remove local metadata for that timestep @@ -1341,7 +1354,7 @@ static void FreeTimestep(SstStream Stream, long Timestep) } } -static TSMetadataList waitForNextMetadata(SstStream Stream, long LastTimestep) +static TSMetadataList waitForNextMetadata(SstStream Stream, ssize_t LastTimestep) { TSMetadataList FoundTS = NULL; CP_verbose(Stream, PerRankVerbose, "Wait for next metadata after last timestep %d\n", @@ -1409,7 +1422,7 @@ static TSMetadataList waitForNextMetadata(SstStream Stream, long LastTimestep) } /* didn't find a good next timestep, check Stream status */ if ((Stream->Status != Established) || - ((Stream->FinalTimestep != INT_MAX) && (Stream->FinalTimestep >= LastTimestep))) + ((Stream->FinalTimestep != SSIZE_T_MAX) && (Stream->FinalTimestep >= LastTimestep))) { CP_verbose(Stream, TraceVerbose, "Stream Final Timestep is %d, last timestep was %d\n", Stream->FinalTimestep, LastTimestep); @@ -1451,11 +1464,12 @@ static TSMetadataList waitForNextMetadata(SstStream Stream, long LastTimestep) // thread, it needs no locking. extern SstFullMetadata SstGetCurMetadata(SstStream Stream) { return Stream->CurrentMetadata; } -extern SstMetaMetaList SstGetNewMetaMetaData(SstStream Stream, long Timestep) +extern SstMetaMetaList SstGetNewMetaMetaData(SstStream Stream, size_t UTimestep) { + ssize_t Timestep = (ssize_t)UTimestep; int RetCount = 0; STREAM_MUTEX_LOCK(Stream); - int64_t LastRetTimestep = -1; + ssize_t LastRetTimestep = -1; int i; for (i = 0; i < Stream->InternalMetaMetaCount; i++) { @@ -1489,7 +1503,7 @@ extern SstMetaMetaList SstGetNewMetaMetaData(SstStream Stream, long Timestep) return ret; } -extern SstBlock SstGetAttributeData(SstStream Stream, long Timestep) +extern SstBlock SstGetAttributeData(SstStream Stream, size_t Timestep) { STREAM_MUTEX_LOCK(Stream); struct _SstBlock *InternalAttrDataInfo = Stream->InternalAttrDataInfo; @@ -1498,7 +1512,7 @@ extern SstBlock SstGetAttributeData(SstStream Stream, long Timestep) return InternalAttrDataInfo; } -static void AddToReadStats(SstStream Stream, int Rank, long Timestep, size_t Length) +static void AddToReadStats(SstStream Stream, int Rank, size_t Timestep, size_t Length) { if (!Stream->RanksRead) Stream->RanksRead = calloc(1, Stream->WriterCohortSize); @@ -1510,7 +1524,7 @@ static void AddToReadStats(SstStream Stream, int Rank, long Timestep, size_t Len #define min(a, b) (((a) < (b)) ? (a) : (b)) #endif -static void ReleaseTSReadStats(SstStream Stream, long Timestep) +static void ReleaseTSReadStats(SstStream Stream, ssize_t Timestep) { int ThisFanIn = 0; if (Stream->RanksRead) @@ -1536,9 +1550,10 @@ static void ReleaseTSReadStats(SstStream Stream, long Timestep) // SstReadRemotememory is only called by the main // program thread. -extern void *SstReadRemoteMemory(SstStream Stream, int Rank, long Timestep, size_t Offset, +extern void *SstReadRemoteMemory(SstStream Stream, int Rank, size_t UTimestep, size_t Offset, size_t Length, void *Buffer, void *DP_TimestepInfo) { + ssize_t Timestep = (ssize_t)UTimestep; // internal uses of Timestep are signed if (Stream->ConfigParams->ReaderShortCircuitReads) return NULL; Stream->Stats.BytesTransferred += Length; @@ -1613,8 +1628,9 @@ static void sendOneToEachWriterRank(SstStream Stream, CMFormat f, void *Msg, voi // SstReaderDefinitionLock is only called by the main // program thread. -extern void SstReaderDefinitionLock(SstStream Stream, long EffectiveTimestep) +extern void SstReaderDefinitionLock(SstStream Stream, size_t UEffectiveTimestep) { + ssize_t EffectiveTimestep = (ssize_t)UEffectiveTimestep; // internal uses of Timestep are signed struct _LockReaderDefinitionsMsg Msg; memset(&Msg, 0, sizeof(Msg)); @@ -1629,7 +1645,7 @@ extern void SstReaderDefinitionLock(SstStream Stream, long EffectiveTimestep) // representation of the resleased timestep. extern void SstReleaseStep(SstStream Stream) { - long Timestep = Stream->ReaderTimestep; + ssize_t Timestep = Stream->ReaderTimestep; struct _ReleaseTimestepMsg Msg; PERFSTUBS_TIMER_START_FUNC(timer); @@ -1700,11 +1716,11 @@ static SstStatusValue SstAdvanceStepPeer(SstStream Stream, SstStepMode mode, { float timeout_sec; int mode; - long LatestTimestep; + ssize_t LatestTimestep; }; struct _GlobalOpInfo my_info; struct _GlobalOpInfo *global_info = NULL; - long NextTimestep; + ssize_t NextTimestep; if (Stream->Rank == 0) { @@ -1721,8 +1737,8 @@ static SstStatusValue SstAdvanceStepPeer(SstStream Stream, SstStepMode mode, 0, Stream->mpiComm); if (Stream->Rank == 0) { - long Biggest = -1; - long Smallest = LONG_MAX; + ssize_t Biggest = -1; + ssize_t Smallest = SSIZE_T_MAX; for (int i = 0; i < Stream->CohortSize; i++) { if (global_info[i].LatestTimestep > Biggest) @@ -1937,8 +1953,8 @@ static SstStatusValue SstAdvanceStepMin(SstStream Stream, SstStepMode mode, cons } if ((timeout_sec >= 0.0) || (mode == SstLatestAvailable)) { - long NextTimestep = -1; - long LatestTimestep = MaxQueuedMetadata(Stream); + ssize_t NextTimestep = -1; + ssize_t LatestTimestep = MaxQueuedMetadata(Stream); /* * Several situations are possible here, depending upon * whether or not a timeout is specified and/or diff --git a/source/adios2/toolkit/sst/cp/cp_writer.c b/source/adios2/toolkit/sst/cp/cp_writer.c index 21ffb76fac..5c60d10e40 100644 --- a/source/adios2/toolkit/sst/cp/cp_writer.c +++ b/source/adios2/toolkit/sst/cp/cp_writer.c @@ -6,13 +6,17 @@ #include #include #include +#ifndef _MSC_VER +#include #include #include +#else +#include "../win_interface.h" +#endif #include "adios2/common/ADIOSConfig.h" #include #include -#include #include "sst.h" @@ -102,7 +106,7 @@ struct NameListEntry struct NameListEntry *FileNameList = NULL; -static void RemoveAllFilesInList() +static void RemoveAllFilesInList(void) { while (FileNameList) { @@ -126,14 +130,16 @@ static void AddNameToExitList(const char *FileName) static int First = 1; if (First) { - struct sigaction sa; First = 0; atexit(RemoveAllFilesInList); +#ifndef _MSC_VER + struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = ExitAndRemoveFiles; sigemptyset(&sa.sa_mask); sigaction(SIGINT, &sa, NULL); +#endif } struct NameListEntry *NewHead = malloc(sizeof(*NewHead)); @@ -324,7 +330,7 @@ registered with DP deregister that timestep with DP CallRemoveQueueEntries static void QueueMaintenance(SstStream Stream) { STREAM_ASSERT_LOCKED(Stream); - long SmallestLastReleasedTimestep = LONG_MAX; + ssize_t SmallestLastReleasedTimestep = SSIZE_T_MAX; long ReserveCount; int SomeReaderIsOpening = 0; @@ -342,14 +348,16 @@ static void QueueMaintenance(SstStream Stream) if (Stream->Readers[i]->ReaderStatus == Established) { if (Stream->Readers[i]->LastReleasedTimestep < SmallestLastReleasedTimestep) + { SmallestLastReleasedTimestep = Stream->Readers[i]->LastReleasedTimestep; + } } else if (Stream->Readers[i]->ReaderStatus == Opening) { SomeReaderIsOpening++; } } - if (SmallestLastReleasedTimestep != LONG_MAX) + if (SmallestLastReleasedTimestep != SSIZE_T_MAX) { CP_verbose(Stream, TraceVerbose, "QueueMaintenance, smallest last released = %ld, count = %d\n", @@ -677,9 +685,9 @@ static int initWSReader(WS_ReaderInfo reader, int ReaderSize, CP_ReaderInitInfo return 1; } -static long earliestAvailableTimestepNumber(SstStream Stream, long CurrentTimestep) +static ssize_t earliestAvailableTimestepNumber(SstStream Stream, ssize_t CurrentTimestep) { - long Ret = CurrentTimestep; + ssize_t Ret = CurrentTimestep; CPTimestepList List = Stream->QueuedTimesteps; STREAM_MUTEX_LOCK(Stream); while (List) @@ -717,7 +725,7 @@ static void UntagPreciousTimesteps(SstStream Stream) } } -static void SubRefTimestep(SstStream Stream, long Timestep, int SetLast) +static void SubRefTimestep(SstStream Stream, ssize_t Timestep, int SetLast) { CPTimestepList List; List = Stream->QueuedTimesteps; @@ -743,7 +751,7 @@ WS_ReaderInfo WriterParticipateInReaderOpen(SstStream Stream) void *free_block = NULL; int WriterResponseCondition = -1; CMConnection conn = NULL; - long MyStartingTimestep, GlobalStartingTimestep; + ssize_t MyStartingTimestep, GlobalStartingTimestep; WS_ReaderInfo CP_WSR_Stream = malloc(sizeof(*CP_WSR_Stream)); CP_verbose(Stream, PerRankVerbose, "Beginning writer-side reader open protocol\n"); @@ -976,7 +984,7 @@ void sendOneToWSRCohort(WS_ReaderInfo CP_WSR_Stream, CMFormat f, void *Msg, void } } -static void AddTSToSentList(SstStream Stream, WS_ReaderInfo Reader, long Timestep) +static void AddTSToSentList(SstStream Stream, WS_ReaderInfo Reader, ssize_t Timestep) { struct _SentTimestepRec *Item = malloc(sizeof(*Item)), *List = Reader->SentTimestepList; Item->Timestep = Timestep; @@ -995,10 +1003,10 @@ static void AddTSToSentList(SstStream Stream, WS_ReaderInfo Reader, long Timeste } } -static void DerefSentTimestep(SstStream Stream, WS_ReaderInfo Reader, long Timestep) +static void DerefSentTimestep(SstStream Stream, WS_ReaderInfo Reader, ssize_t Timestep) { struct _SentTimestepRec *List = Reader->SentTimestepList, *Last = NULL; - CP_verbose(Stream, PerRankVerbose, "Reader sent timestep list %p, trying to release %ld\n", + CP_verbose(Stream, PerRankVerbose, "Reader sent timestep list %p, trying to release %zd\n", Reader->SentTimestepList, Timestep); while (List) @@ -1007,7 +1015,7 @@ static void DerefSentTimestep(SstStream Stream, WS_ReaderInfo Reader, long Times int Freed = 0; struct _SentTimestepRec *Next = List->Next; CP_verbose(Stream, TraceVerbose, - "Reader considering sent timestep %ld,trying to release %ld\n", List->Timestep, + "Reader considering sent timestep %ld,trying to release %zd\n", List->Timestep, Timestep); if (List->Timestep == Timestep) { @@ -1134,7 +1142,8 @@ static void SendTimestepEntryToReaders(SstStream Stream, CPTimestepList Entry) CP_verbose(Stream, PerRankVerbose, "Round Robin Distribution, step sent to reader %d\n", Stream->NextRRDistribution); WS_ReaderInfo CP_WSR_Stream = Stream->Readers[Stream->NextRRDistribution]; - SendTimestepEntryToSingleReader(Stream, Entry, CP_WSR_Stream, Stream->NextRRDistribution); + SendTimestepEntryToSingleReader(Stream, Entry, CP_WSR_Stream, + (int)Stream->NextRRDistribution); Stream->NextRRDistribution++; } case StepsOnDemand: { @@ -1210,7 +1219,7 @@ static void waitForReaderResponseAndSendQueued(WS_ReaderInfo Reader) Reader, Reader->StartingTimestep, Stream->LastProvidedTimestep); if (Stream->ConfigParams->StepDistributionMode == StepsAllToAll) { - for (long TS = Reader->StartingTimestep; TS <= Stream->LastProvidedTimestep; TS++) + for (ssize_t TS = Reader->StartingTimestep; TS <= Stream->LastProvidedTimestep; TS++) { CPTimestepList List = Stream->QueuedTimesteps; while (List) @@ -1536,13 +1545,13 @@ void SstWriterClose(SstStream Stream) while (List) { - char tmp[20]; + char tmp[30]; CP_verbose(Stream, TraceVerbose, "IN TS WAIT, ENTRIES are Timestep %ld (exp %d, " "Prec %d, Ref %d), Count now %d\n", List->Timestep, List->Expired, List->PreciousTimestep, List->ReferenceCount, Stream->QueuedTimestepCount); - snprintf(tmp, sizeof(tmp), "%ld ", List->Timestep); + snprintf(tmp, sizeof(tmp), "%zd ", List->Timestep); StringList = realloc(StringList, strlen(StringList) + strlen(tmp) + 1); strcat(StringList, tmp); List = List->Next; @@ -1797,7 +1806,7 @@ static void ProcessReaderStatusList(SstStream Stream, ReturnMetadataInfo Metadat STREAM_MUTEX_UNLOCK(Stream); } -static void ActOnTSLockStatus(SstStream Stream, long Timestep) +static void ActOnTSLockStatus(SstStream Stream, ssize_t Timestep) { int SomethingSent = 0; STREAM_MUTEX_LOCK(Stream); @@ -2040,7 +2049,7 @@ on reader close: */ extern void SstInternalProvideTimestep(SstStream Stream, SstData LocalMetadata, SstData Data, - long Timestep, FFSFormatList Formats, + ssize_t Timestep, FFSFormatList Formats, DataFreeFunc FreeTimestep, void *FreeClientData, SstData AttributeData, DataFreeFunc FreeAttributeData, void *FreeAttributelientData) @@ -2104,6 +2113,7 @@ extern void SstInternalProvideTimestep(SstStream Stream, SstData LocalMetadata, Entry->FreeClientData = FreeClientData; Entry->Next = Stream->QueuedTimesteps; Entry->InProgressFlag = 1; + Stream->QueuedTimesteps = Entry; Stream->QueuedTimestepCount++; Stream->Stats.TimestepsCreated++; diff --git a/source/adios2/toolkit/sst/cp/ffs_marshal.c b/source/adios2/toolkit/sst/cp/ffs_marshal.c index eeeed2db20..45d6135f43 100644 --- a/source/adios2/toolkit/sst/cp/ffs_marshal.c +++ b/source/adios2/toolkit/sst/cp/ffs_marshal.c @@ -6,7 +6,11 @@ #include "adios2/common/ADIOSConfig.h" #include #include +#ifndef _MSC_VER #include +#else +#include "../win_interface.h" +#endif #include "adios2/common/ADIOSConfig.h" @@ -49,7 +53,7 @@ static char *ConcatName(const char *base_name, const char *postfix) static char *BuildVarName(const char *base_name, const int type, const int element_size) { - int Len = strlen(base_name) + 2 + strlen("SST_") + 16; + size_t Len = strlen(base_name) + 2 + strlen("SST_") + 16; char *Ret = malloc(Len); snprintf(Ret, Len, "SST%d_%d_", element_size, type); strcat(Ret, base_name); @@ -69,7 +73,7 @@ static void BreakdownVarName(const char *Name, char **base_name_p, int *type_p, static char *BuildArrayDimsName(const char *base_name, const int type, const int element_size) { - int Len = strlen(base_name) + 3 + strlen("SST_") + 16; + size_t Len = strlen(base_name) + 3 + strlen("SST_") + 16; char *Ret = malloc(Len); snprintf(Ret, Len, "SST%d_%d_", element_size, type); strcat(Ret, base_name); @@ -79,7 +83,7 @@ static char *BuildArrayDimsName(const char *base_name, const int type, const int static char *BuildArrayDBCountName(const char *base_name, const int type, const int element_size) { - int Len = strlen(base_name) + 3 + strlen("SST_") + 16; + size_t Len = strlen(base_name) + 3 + strlen("SST_") + 16; char *Ret = malloc(Len); snprintf(Ret, Len, "SST%d_%d_", element_size, type); strcat(Ret, base_name); @@ -231,7 +235,7 @@ static void RecalcAttributeStorageSize(SstStream Stream) Info->AttributeData = realloc(Info->AttributeData, NewAttributeSize + 8); memset((char *)(Info->AttributeData) + Info->AttributeSize, 0, NewAttributeSize - Info->AttributeSize); - Info->AttributeSize = NewAttributeSize; + Info->AttributeSize = (int)NewAttributeSize; } } @@ -436,13 +440,13 @@ static FFSWriterRec CreateWriterRec(SstStream Stream, void *Variable, const char FFSWriterRec Rec = &Info->RecList[Info->RecCount]; Rec->Key = Variable; Rec->FieldID = Info->RecCount; - Rec->DimCount = DimCount; + Rec->DimCount = (int)DimCount; Rec->Type = Type; if (DimCount == 0) { // simple field, only add base value FMField to metadata char *SstName = ConcatName(Name, ""); - AddField(&Info->MetaFields, &Info->MetaFieldCount, SstName, Type, ElemSize); + AddField(&Info->MetaFields, &Info->MetaFieldCount, SstName, Type, (int)ElemSize); free(SstName); RecalcMarshalStorageSize(Stream); Rec->MetaOffset = Info->MetaFields[Info->MetaFieldCount - 1].field_offset; @@ -454,8 +458,8 @@ static FFSWriterRec CreateWriterRec(SstStream Stream, void *Variable, const char { // Array field. To Metadata, add FMFields for DimCount, Shape, Count // and Offsets matching _MetaArrayRec - char *ArrayName = BuildArrayDimsName(Name, Type, ElemSize); - char *ArrayDBCount = BuildArrayDBCountName(Name, Type, ElemSize); + char *ArrayName = BuildArrayDimsName(Name, Type, (int)ElemSize); + char *ArrayDBCount = BuildArrayDBCountName(Name, Type, (int)ElemSize); AddField(&Info->MetaFields, &Info->MetaFieldCount, ArrayName, Int64, sizeof(size_t)); free(ArrayName); Rec->MetaOffset = Info->MetaFields[Info->MetaFieldCount - 1].field_offset; @@ -464,7 +468,7 @@ static FFSWriterRec CreateWriterRec(SstStream Stream, void *Variable, const char char *OffsetsName = ConcatName(Name, "Offsets"); AddField(&Info->MetaFields, &Info->MetaFieldCount, ArrayDBCount, Int64, sizeof(size_t)); AddFixedArrayField(&Info->MetaFields, &Info->MetaFieldCount, ShapeName, Int64, - sizeof(size_t), DimCount); + sizeof(size_t), (int)DimCount); AddVarArrayField(&Info->MetaFields, &Info->MetaFieldCount, CountName, Int64, sizeof(size_t), ArrayDBCount); AddVarArrayField(&Info->MetaFields, &Info->MetaFieldCount, OffsetsName, Int64, @@ -486,7 +490,7 @@ static FFSWriterRec CreateWriterRec(SstStream Stream, void *Variable, const char AddField(&Info->DataFields, &Info->DataFieldCount, ElemCountName, Int64, sizeof(size_t)); Rec->DataOffset = Info->DataFields[Info->DataFieldCount - 1].field_offset; char *SstName = ConcatName(Name, ""); - AddVarArrayField(&Info->DataFields, &Info->DataFieldCount, SstName, Type, ElemSize, + AddVarArrayField(&Info->DataFields, &Info->DataFieldCount, SstName, Type, (int)ElemSize, ElemCountName); free(SstName); free(ElemCountName); @@ -712,8 +716,8 @@ extern void *SstFFSGetBlocksInfo(SstStream Stream, void *Variable) if (!Stream->MinArraySetupUpcall) return NULL; - void *Ret = - Stream->MinArraySetupUpcall(Stream->SetupUpcallReader, meta_base->Dims, meta_base->Shape); + void *Ret = Stream->MinArraySetupUpcall(Stream->SetupUpcallReader, (int)meta_base->Dims, + meta_base->Shape); for (int WriterRank = 0; WriterRank < Stream->WriterCohortSize; WriterRank++) { meta_base = (MetaArrayRec *)(((char *)Info->MetadataBaseAddrs[WriterRank]) + @@ -725,7 +729,7 @@ extern void *SstFFSGetBlocksInfo(SstStream Stream, void *Variable) if (meta_base->Offsets) Offsets = meta_base->Offsets + (i * meta_base->Dims); Stream->ArrayBlocksInfoUpcall(Stream->SetupUpcallReader, Ret, VarRec->Type, WriterRank, - meta_base->Dims, meta_base->Shape, Offsets, + (int)meta_base->Dims, meta_base->Shape, Offsets, meta_base->Count); } } @@ -891,7 +895,7 @@ static void DecodeAndPrepareData(SstStream Stream, int Writer) { size_t DataSize = ((struct FFSMetadataInfoStruct *)Info->MetadataBaseAddrs[Writer])->DataBlockSize; - int DecodedLength = + size_t DecodedLength = FFS_est_decode_length(Stream->ReaderFFSContext, WriterInfo->RawBuffer, DataSize); BaseData = malloc(DecodedLength); FFSBuffer decode_buf = create_fixed_FFSBuffer(BaseData, DecodedLength); @@ -980,7 +984,7 @@ static int FindOffset(size_t Dims, const size_t *Size, const size_t *Index) int Offset = 0; for (int i = 0; i < Dims; i++) { - Offset = Index[i] + (Size[i] * Offset); + Offset = (int)(Index[i] + (Size[i] * Offset)); } return Offset; } @@ -988,9 +992,9 @@ static int FindOffset(size_t Dims, const size_t *Size, const size_t *Index) static int FindOffsetCM(size_t Dims, const size_t *Size, const size_t *Index) { int Offset = 0; - for (int i = Dims - 1; i >= 0; i--) + for (int i = (int)Dims - 1; i >= 0; i--) { - Offset = Index[i] + (Size[i] * Offset); + Offset = (int)(Index[i] + (Size[i] * Offset)); } return Offset; } @@ -1033,7 +1037,7 @@ void ExtractSelectionFromPartialRM(int ElementSize, size_t Dims, const size_t *G OperantDims = Dims; OperantElementSize = ElementSize; int Dim; - for (Dim = Dims - 1; Dim >= 0; Dim--) + for (Dim = (int)Dims - 1; Dim >= 0; Dim--) { if ((GlobalDims[Dim] == PartialCounts[Dim]) && (SelectionCounts[Dim] == PartialCounts[Dim])) { @@ -1111,13 +1115,13 @@ void ExtractSelectionFromPartialCM(int ElementSize, size_t Dims, const size_t *G const size_t *SelectionOffsets, const size_t *SelectionCounts, const char *InData, char *OutData) { - int BlockSize; - int SourceBlockStride = 0; - int DestBlockStride = 0; - int SourceBlockStartOffset; - int DestBlockStartOffset; - int BlockCount; - int OperantElementSize; + size_t BlockSize; + size_t SourceBlockStride = 0; + size_t DestBlockStride = 0; + size_t SourceBlockStartOffset; + size_t DestBlockStartOffset; + size_t BlockCount; + size_t OperantElementSize; BlockSize = 1; OperantElementSize = ElementSize; @@ -1141,9 +1145,9 @@ void ExtractSelectionFromPartialCM(int ElementSize, size_t Dims, const size_t *G } else { - int Left = MAX(PartialOffsets[Dim], SelectionOffsets[Dim]); - int Right = MIN(PartialOffsets[Dim] + PartialCounts[Dim], - SelectionOffsets[Dim] + SelectionCounts[Dim]); + size_t Left = MAX(PartialOffsets[Dim], SelectionOffsets[Dim]); + size_t Right = MIN(PartialOffsets[Dim] + PartialCounts[Dim], + SelectionOffsets[Dim] + SelectionCounts[Dim]); BlockSize *= (Right - Left); break; } @@ -1159,9 +1163,9 @@ void ExtractSelectionFromPartialCM(int ElementSize, size_t Dims, const size_t *G size_t *FirstIndex = malloc(Dims * sizeof(FirstIndex[0])); for (Dim = 0; Dim < Dims; Dim++) { - int Left = MAX(PartialOffsets[Dim], SelectionOffsets[Dim]); - int Right = MIN(PartialOffsets[Dim] + PartialCounts[Dim], - SelectionOffsets[Dim] + SelectionCounts[Dim]); + size_t Left = MAX(PartialOffsets[Dim], SelectionOffsets[Dim]); + size_t Right = MIN(PartialOffsets[Dim] + PartialCounts[Dim], + SelectionOffsets[Dim] + SelectionCounts[Dim]); if (Dim > 0) { BlockCount *= (Right - Left); @@ -1251,7 +1255,7 @@ static void DumpCoverageList(range_list list) { if (!list) return; - printf("%ld - %ld", list->start, list->end); + printf("%zd - %zd", list->start, list->end); if (list->next != NULL) { printf(", "); @@ -1283,10 +1287,9 @@ static void ImplementGapWarning(SstStream Stream, FFSArrayRequest Req) } if (Required != NULL) { - printf("WARNING: Reader Rank %d requested elements %lu - %lu,\n\tbut " + printf("WARNING: Reader Rank %d requested elements %zu - %zu,\n\tbut " "these elements were not written by any writer rank: \n", - Stream->Rank, (unsigned long)Req->Start[0], - (unsigned long)Req->Start[0] + Req->Count[0] - 1); + Stream->Rank, Req->Start[0], Req->Start[0] + Req->Count[0] - 1); DumpCoverageList(Required); } } @@ -1301,8 +1304,8 @@ static void FillReadRequests(SstStream Stream, FFSArrayRequest Reqs) if (NeedWriter(Reqs, WriterRank)) { /* if needed this writer fill destination with acquired data */ - int ElementSize = Reqs->VarRec->ElementSize; - int DimCount = Reqs->VarRec->DimCount; + size_t ElementSize = Reqs->VarRec->ElementSize; + int DimCount = (int)Reqs->VarRec->DimCount; size_t *GlobalDimensions = Reqs->VarRec->GlobalDims; size_t *GlobalDimensionsFree = NULL; size_t *RankOffset = Reqs->VarRec->PerWriterStart[WriterRank]; @@ -1317,13 +1320,13 @@ static void FillReadRequests(SstStream Stream, FFSArrayRequest Reqs) if (Reqs->RequestType == Local) { - int LocalBlockID = + size_t LocalBlockID = Reqs->BlockID - Reqs->VarRec->PerWriterBlockStart[WriterRank]; size_t DataOffset = 0; int i; for (i = 0; i < LocalBlockID; i++) { - int BlockElemCount = 1; + size_t BlockElemCount = 1; for (int j = 0; j < DimCount; j++) { BlockElemCount *= RankSize[j]; @@ -1362,13 +1365,13 @@ static void FillReadRequests(SstStream Stream, FFSArrayRequest Reqs) } if (Stream->ConfigParams->IsRowMajor) { - ExtractSelectionFromPartialRM(ElementSize, DimCount, GlobalDimensions, + ExtractSelectionFromPartialRM((int)ElementSize, DimCount, GlobalDimensions, RankOffset, RankSize, SelOffset, SelSize, IncomingData, Reqs->Data); } else { - ExtractSelectionFromPartialCM(ElementSize, DimCount, GlobalDimensions, + ExtractSelectionFromPartialCM((int)ElementSize, DimCount, GlobalDimensions, RankOffset, RankSize, SelOffset, SelSize, IncomingData, Reqs->Data); } @@ -1631,9 +1634,9 @@ static void LoadAttributes(SstStream Stream, TSMetadataMsg MetaData) } else { - int DecodedLength = FFS_est_decode_length(Stream->ReaderFFSContext, - MetaData->AttributeData[WriterRank].block, - MetaData->AttributeData[WriterRank].DataSize); + size_t DecodedLength = FFS_est_decode_length( + Stream->ReaderFFSContext, MetaData->AttributeData[WriterRank].block, + MetaData->AttributeData[WriterRank].DataSize); BaseData = malloc(DecodedLength); FFSBuffer decode_buf = create_fixed_FFSBuffer(BaseData, DecodedLength); FFSdecode_to_buffer(Stream->ReaderFFSContext, MetaData->AttributeData[WriterRank].block, @@ -1678,7 +1681,7 @@ static void LoadFormats(SstStream Stream, FFSFormatList Formats) memcpy(FormatID, Entry->FormatIDRep, Entry->FormatIDRepLen); memcpy(FormatServerRep, Entry->FormatServerRep, Entry->FormatServerRepLen); load_external_format_FMcontext(FMContext_from_FFS(Stream->ReaderFFSContext), FormatID, - Entry->FormatIDRepLen, FormatServerRep); + (int)Entry->FormatIDRepLen, FormatServerRep); free(FormatID); Entry = Entry->Next; } @@ -1686,7 +1689,7 @@ static void LoadFormats(SstStream Stream, FFSFormatList Formats) static int NameIndicatesArray(const char *Name) { - int Len = strlen(Name); + size_t Len = strlen(Name); return (strcmp("Dims", Name + Len - 4) == 0); } @@ -1867,7 +1870,7 @@ static void BuildVarList(SstStream Stream, TSMetadataMsg MetaData, int WriterRan } else { - int DecodedLength = + size_t DecodedLength = FFS_est_decode_length(Stream->ReaderFFSContext, MetaData->Metadata[WriterRank].block, MetaData->Metadata[WriterRank].DataSize); BaseData = malloc(DecodedLength); @@ -1911,9 +1914,9 @@ static void BuildVarList(SstStream Stream, TSMetadataMsg MetaData, int WriterRan { /* if we're getting data from someone of the other array gender, * switcheroo */ - ReverseDimensions(meta_base->Shape, meta_base->Dims); - ReverseDimensions(meta_base->Count, meta_base->Dims); - ReverseDimensions(meta_base->Offsets, meta_base->Dims); + ReverseDimensions(meta_base->Shape, (int)meta_base->Dims); + ReverseDimensions(meta_base->Count, (int)meta_base->Dims); + ReverseDimensions(meta_base->Offsets, (int)meta_base->Dims); } if (WriterRank == 0) { @@ -1922,7 +1925,7 @@ static void BuildVarList(SstStream Stream, TSMetadataMsg MetaData, int WriterRan if (!VarRec->Variable) { VarRec->Variable = Stream->ArraySetupUpcall( - Stream->SetupUpcallReader, VarRec->VarName, VarRec->Type, meta_base->Dims, + Stream->SetupUpcallReader, VarRec->VarName, VarRec->Type, (int)meta_base->Dims, meta_base->Shape, meta_base->Offsets, meta_base->Count); } VarRec->DimCount = meta_base->Dims; @@ -1961,8 +1964,8 @@ static void BuildVarList(SstStream Stream, TSMetadataMsg MetaData, int WriterRan Offsets = meta_base->Offsets + (i * meta_base->Dims); void *Variable = VarRec->Variable; Stream->ArrayBlocksInfoUpcall(Stream->SetupUpcallReader, Variable, VarRec->Type, - WriterRank, meta_base->Dims, meta_base->Shape, - Offsets, meta_base->Count); + WriterRank, (int)meta_base->Dims, + meta_base->Shape, Offsets, meta_base->Count); } } } @@ -2013,7 +2016,7 @@ static void FFSBitfieldSet(struct FFSMetadataInfoStruct *MBase, int Bit) (Element - MBase->BitFieldCount + 1) * sizeof(size_t)); MBase->BitFieldCount = Element + 1; } - MBase->BitField[Element] |= (1 << ElementBit); + MBase->BitField[Element] |= ((size_t)1 << ElementBit); } static int FFSBitfieldTest(struct FFSMetadataInfoStruct *MBase, int Bit) @@ -2027,7 +2030,7 @@ static int FFSBitfieldTest(struct FFSMetadataInfoStruct *MBase, int Bit) (Element - MBase->BitFieldCount + 1) * sizeof(size_t)); MBase->BitFieldCount = Element + 1; } - return ((MBase->BitField[Element] & (1 << ElementBit)) == (1 << ElementBit)); + return ((MBase->BitField[Element] & ((size_t)1 << ElementBit)) == ((size_t)1 << ElementBit)); } extern void SstFFSSetZFPParams(SstStream Stream, attr_list Attrs) @@ -2154,8 +2157,8 @@ extern void SstFFSMarshalAttribute(SstStream Stream, const char *Name, const int if (ElemCount == (size_t)(-1)) { // simple field, only simple attribute name and value - char *SstName = BuildVarName(Name, Type, ElemSize); - AddField(&Info->AttributeFields, &Info->AttributeFieldCount, SstName, Type, ElemSize); + char *SstName = BuildVarName(Name, Type, (int)ElemSize); + AddField(&Info->AttributeFields, &Info->AttributeFieldCount, SstName, Type, (int)ElemSize); free(SstName); RecalcAttributeStorageSize(Stream); int DataOffset = Info->AttributeFields[Info->AttributeFieldCount - 1].field_offset; diff --git a/source/adios2/toolkit/sst/dp/daos_dp.c b/source/adios2/toolkit/sst/dp/daos_dp.c index 6478093f7a..9131225f99 100644 --- a/source/adios2/toolkit/sst/dp/daos_dp.c +++ b/source/adios2/toolkit/sst/dp/daos_dp.c @@ -764,11 +764,11 @@ extern CP_DP_Interface LoadDaosDP() daosDPInterface.initWriter = DaosInitWriter; daosDPInterface.initWriterPerReader = DaosInitWriterPerReader; daosDPInterface.provideWriterDataToReader = DaosProvideWriterDataToReader; - daosDPInterface.readRemoteMemory = DaosReadRemoteMemory; + daosDPInterface.readRemoteMemory = (CP_DP_ReadRemoteMemoryFunc)DaosReadRemoteMemory; daosDPInterface.waitForCompletion = DaosWaitForCompletion; daosDPInterface.notifyConnFailure = DaosNotifyConnFailure; - daosDPInterface.provideTimestep = DaosProvideTimestep; - daosDPInterface.releaseTimestep = DaosReleaseTimestep; + daosDPInterface.provideTimestep = (CP_DP_ProvideTimestepFunc)DaosProvideTimestep; + daosDPInterface.releaseTimestep = (CP_DP_ReleaseTimestepFunc)DaosReleaseTimestep; daosDPInterface.readerRegisterTimestep = NULL; daosDPInterface.readerReleaseTimestep = NULL; daosDPInterface.destroyReader = DaosDestroyReader; diff --git a/source/adios2/toolkit/sst/dp/dp.c b/source/adios2/toolkit/sst/dp/dp.c index 0884709a67..2071ee18a1 100644 --- a/source/adios2/toolkit/sst/dp/dp.c +++ b/source/adios2/toolkit/sst/dp/dp.c @@ -9,6 +9,11 @@ #include "dp_interface.h" #include "sst.h" #include "sst_data.h" +#ifdef _MSC_VER +#define strncasecmp _strnicmp +#define strcasecmp _stricmp +#define strdup _strdup +#endif #ifdef SST_HAVE_LIBFABRIC extern CP_DP_Interface LoadRdmaDP(); diff --git a/source/adios2/toolkit/sst/dp/dummy_dp.c b/source/adios2/toolkit/sst/dp/dummy_dp.c index 223403fcda..6cd29cb3cc 100644 --- a/source/adios2/toolkit/sst/dp/dummy_dp.c +++ b/source/adios2/toolkit/sst/dp/dummy_dp.c @@ -10,6 +10,9 @@ #include "dp_interface.h" #include +#ifdef _MSC_VER +#define strdup _strdup +#endif /* * Some conventions: @@ -70,7 +73,7 @@ typedef struct _Dummy_WSR_Stream typedef struct _TimestepEntry { - long Timestep; + size_t Timestep; struct _SstData *Data; struct _DummyPerTimestepInfo *DP_TimestepInfo; struct _TimestepEntry *Next; @@ -104,7 +107,7 @@ typedef struct _DummyWriterContactInfo typedef struct _DummyReadRequestMsg { - long Timestep; + size_t Timestep; size_t Offset; size_t Length; void *WS_Stream; @@ -114,7 +117,7 @@ typedef struct _DummyReadRequestMsg } *DummyReadRequestMsg; static FMField DummyReadRequestList[] = { - {"Timestep", "integer", sizeof(long), FMOffset(DummyReadRequestMsg, Timestep)}, + {"Timestep", "integer", sizeof(size_t), FMOffset(DummyReadRequestMsg, Timestep)}, {"Offset", "integer", sizeof(size_t), FMOffset(DummyReadRequestMsg, Offset)}, {"Length", "integer", sizeof(size_t), FMOffset(DummyReadRequestMsg, Length)}, {"WS_Stream", "integer", sizeof(void *), FMOffset(DummyReadRequestMsg, WS_Stream)}, @@ -129,7 +132,7 @@ static FMStructDescRec DummyReadRequestStructs[] = { typedef struct _DummyReadReplyMsg { - long Timestep; + size_t Timestep; size_t DataLength; void *RS_Stream; char *Data; @@ -137,7 +140,7 @@ typedef struct _DummyReadReplyMsg } *DummyReadReplyMsg; static FMField DummyReadReplyList[] = { - {"Timestep", "integer", sizeof(long), FMOffset(DummyReadReplyMsg, Timestep)}, + {"Timestep", "integer", sizeof(size_t), FMOffset(DummyReadReplyMsg, Timestep)}, {"RS_Stream", "integer", sizeof(void *), FMOffset(DummyReadReplyMsg, RS_Stream)}, {"DataLength", "integer", sizeof(size_t), FMOffset(DummyReadReplyMsg, DataLength)}, {"Data", "char[DataLength]", sizeof(char), FMOffset(DummyReadReplyMsg, Data)}, @@ -244,7 +247,7 @@ static void DummyReadRequestHandler(CManager cm, CMConnection conn, void *msg_v, * Shouldn't ever get here because we should never get a request for a * timestep that we don't have. */ - fprintf(stderr, "Failed to read Timestep %ld, not found\n", ReadRequestMsg->Timestep); + fprintf(stderr, "Failed to read Timestep %zd, not found\n", ReadRequestMsg->Timestep); /* * in the interest of not failing a writer on a reader failure, don't * assert(0) here. Probably this sort of error should close the link to @@ -440,8 +443,8 @@ typedef struct _DummyPerTimestepInfo * handle. * */ -static void *DummyReadRemoteMemory(CP_Services Svcs, DP_RS_Stream Stream_v, int Rank, long Timestep, - size_t Offset, size_t Length, void *Buffer, +static void *DummyReadRemoteMemory(CP_Services Svcs, DP_RS_Stream Stream_v, int Rank, + size_t Timestep, size_t Offset, size_t Length, void *Buffer, void *DP_TimestepInfo) { Dummy_RS_Stream Stream = @@ -537,7 +540,7 @@ static int DummyWaitForCompletion(CP_Services Svcs, void *Handle_v) * */ static void DummyProvideTimestep(CP_Services Svcs, DP_WS_Stream Stream_v, struct _SstData *Data, - struct _SstData *LocalMetadata, long Timestep, + struct _SstData *LocalMetadata, size_t Timestep, void **TimestepInfoPtr) { Dummy_WS_Stream Stream = (Dummy_WS_Stream)Stream_v; @@ -545,9 +548,9 @@ static void DummyProvideTimestep(CP_Services Svcs, DP_WS_Stream Stream_v, struct struct _DummyPerTimestepInfo *Info = malloc(sizeof(struct _DummyPerTimestepInfo)); Info->CheckString = malloc(64); - snprintf(Info->CheckString, 64, "Dummy info for timestep %ld from rank %d", Timestep, + snprintf(Info->CheckString, 64, "Dummy info for timestep %zd from rank %d", Timestep, Stream->Rank); - Info->CheckInt = Stream->Rank * 1000 + Timestep; + Info->CheckInt = Stream->Rank * 1000 + (int)Timestep; Entry->Data = Data; Entry->Timestep = Timestep; Entry->DP_TimestepInfo = Info; @@ -565,12 +568,12 @@ static void DummyProvideTimestep(CP_Services Svcs, DP_WS_Stream Stream_v, struct * */ -static void DummyReleaseTimestep(CP_Services Svcs, DP_WS_Stream Stream_v, long Timestep) +static void DummyReleaseTimestep(CP_Services Svcs, DP_WS_Stream Stream_v, size_t Timestep) { Dummy_WS_Stream Stream = (Dummy_WS_Stream)Stream_v; TimestepList List = Stream->Timesteps; - Svcs->verbose(Stream->CP_Stream, DPTraceVerbose, "Releasing timestep %ld\n", Timestep); + Svcs->verbose(Stream->CP_Stream, DPTraceVerbose, "Releasing timestep %zd\n", Timestep); if (Stream->Timesteps->Timestep == Timestep) { Stream->Timesteps = List->Next; @@ -595,7 +598,7 @@ static void DummyReleaseTimestep(CP_Services Svcs, DP_WS_Stream Stream_v, long T * Shouldn't ever get here because we should never release a * timestep that we don't have. */ - fprintf(stderr, "Failed to release Timestep %ld, not found\n", Timestep); + fprintf(stderr, "Failed to release Timestep %zd, not found\n", Timestep); assert(0); } } @@ -646,10 +649,10 @@ extern CP_DP_Interface LoadDummyDP() dummyDPInterface.initWriter = DummyInitWriter; dummyDPInterface.initWriterPerReader = DummyInitWriterPerReader; dummyDPInterface.provideWriterDataToReader = DummyProvideWriterDataToReader; - dummyDPInterface.readRemoteMemory = DummyReadRemoteMemory; + dummyDPInterface.readRemoteMemory = (CP_DP_ReadRemoteMemoryFunc)DummyReadRemoteMemory; dummyDPInterface.waitForCompletion = DummyWaitForCompletion; - dummyDPInterface.provideTimestep = DummyProvideTimestep; - dummyDPInterface.releaseTimestep = DummyReleaseTimestep; + dummyDPInterface.provideTimestep = (CP_DP_ProvideTimestepFunc)DummyProvideTimestep; + dummyDPInterface.releaseTimestep = (CP_DP_ReleaseTimestepFunc)DummyReleaseTimestep; // See dp_interface.h for more routines in the interface, but the basic // necessities to get started are above. The remainder allow for locking diff --git a/source/adios2/toolkit/sst/dp/evpath_dp.c b/source/adios2/toolkit/sst/dp/evpath_dp.c index 9d418ac287..82af8ee952 100644 --- a/source/adios2/toolkit/sst/dp/evpath_dp.c +++ b/source/adios2/toolkit/sst/dp/evpath_dp.c @@ -1,6 +1,11 @@ #include #include +#ifndef _MSC_VER #include +#else +#include "../win_interface.h" +#endif +#include #include #include #include @@ -78,11 +83,11 @@ typedef struct _Evpath_RS_Stream struct _EvpathReaderContactInfo *MyContactInfo; SstPreloadModeType CurPreloadMode; - long PreloadActiveTimestep; + size_t PreloadActiveTimestep; long TotalReadRequests; long ReadRequestsFromPreload; SstStats Stats; - long LastPreloadTimestep; + size_t LastPreloadTimestep; } *Evpath_RS_Stream; typedef struct _Evpath_WSR_Stream @@ -90,7 +95,7 @@ typedef struct _Evpath_WSR_Stream struct _Evpath_WS_Stream *WS_Stream; CP_PeerCohort PeerCohort; int ReaderCohortSize; - int ReadPatternLockTimestep; + size_t ReadPatternLockTimestep; char *ReaderRequestArray; SstPreloadModeType CurPreloadMode; struct _EvpathReaderContactInfo *ReaderContactInfo; @@ -99,7 +104,7 @@ typedef struct _Evpath_WSR_Stream typedef struct _TimestepEntry { - long Timestep; + size_t Timestep; struct _SstData Data; struct _EvpathPerTimestepInfo *DP_TimestepInfo; struct _ReaderRequestTrackRec *ReaderRequests; @@ -108,11 +113,11 @@ typedef struct _TimestepEntry typedef struct _RSTimestepEntry { - long Timestep; + size_t Timestep; int WriterRank; char *Data; - long DataSize; - long DataStart; + size_t DataSize; + size_t DataStart; struct _RSTimestepEntry *Next; } *RSTimestepList; @@ -154,7 +159,7 @@ typedef struct _EvpathWriterContactInfo typedef struct _EvpathReadRequestMsg { - long Timestep; + size_t Timestep; size_t Offset; size_t Length; void *WS_Stream; @@ -164,7 +169,7 @@ typedef struct _EvpathReadRequestMsg } *EvpathReadRequestMsg; static FMField EvpathReadRequestList[] = { - {"Timestep", "integer", sizeof(long), FMOffset(EvpathReadRequestMsg, Timestep)}, + {"Timestep", "integer", sizeof(size_t), FMOffset(EvpathReadRequestMsg, Timestep)}, {"Offset", "integer", sizeof(size_t), FMOffset(EvpathReadRequestMsg, Offset)}, {"Length", "integer", sizeof(size_t), FMOffset(EvpathReadRequestMsg, Length)}, {"WS_Stream", "integer", sizeof(void *), FMOffset(EvpathReadRequestMsg, WS_Stream)}, @@ -179,7 +184,7 @@ static FMStructDescRec EvpathReadRequestStructs[] = { typedef struct _EvpathReadReplyMsg { - long Timestep; + size_t Timestep; size_t DataLength; void *RS_Stream; char *Data; @@ -187,7 +192,7 @@ typedef struct _EvpathReadReplyMsg } *EvpathReadReplyMsg; static FMField EvpathReadReplyList[] = { - {"Timestep", "integer", sizeof(long), FMOffset(EvpathReadReplyMsg, Timestep)}, + {"Timestep", "integer", sizeof(size_t), FMOffset(EvpathReadReplyMsg, Timestep)}, {"RS_Stream", "integer", sizeof(void *), FMOffset(EvpathReadReplyMsg, RS_Stream)}, {"DataLength", "integer", sizeof(size_t), FMOffset(EvpathReadReplyMsg, DataLength)}, {"Data", "char[DataLength]", sizeof(char), FMOffset(EvpathReadReplyMsg, Data)}, @@ -203,7 +208,7 @@ static void EvpathReadReplyHandler(CManager cm, CMConnection conn, void *msg_v, typedef struct _EvpathPreloadMsg { - long Timestep; + size_t Timestep; size_t DataLength; int WriterRank; void *RS_Stream; @@ -211,7 +216,7 @@ typedef struct _EvpathPreloadMsg } *EvpathPreloadMsg; static FMField EvpathPreloadList[] = { - {"Timestep", "integer", sizeof(long), FMOffset(EvpathPreloadMsg, Timestep)}, + {"Timestep", "integer", sizeof(size_t), FMOffset(EvpathPreloadMsg, Timestep)}, {"DataLength", "integer", sizeof(size_t), FMOffset(EvpathPreloadMsg, DataLength)}, {"WriterRank", "integer", sizeof(size_t), FMOffset(EvpathPreloadMsg, WriterRank)}, {"RS_Stream", "integer", sizeof(void *), FMOffset(EvpathPreloadMsg, RS_Stream)}, @@ -224,7 +229,7 @@ static FMStructDescRec EvpathPreloadStructs[] = { static void EvpathPreloadHandler(CManager cm, CMConnection conn, void *msg_v, void *client_Data, attr_list attrs); -static void DiscardPriorPreloaded(CP_Services Svcs, Evpath_RS_Stream RS_Stream, long Timestep); +static void DiscardPriorPreloaded(CP_Services Svcs, Evpath_RS_Stream RS_Stream, size_t Timestep); static void SendPreloadMsgs(CP_Services Svcs, Evpath_WSR_Stream WSR_Stream, TimestepList TS); static void SendSpeculativePreloadMsgs(CP_Services Svcs, Evpath_WSR_Stream WSR_Stream, TimestepList TS); @@ -423,7 +428,7 @@ static void EvpathReadRequestHandler(CManager cm, CMConnection incoming_conn, vo */ fprintf(stderr, "\n\n\n\n"); fprintf(stderr, - "Writer rank %d - Failed to read Timestep %ld, not found. This is " + "Writer rank %d - Failed to read Timestep %zd, not found. This is " "an internal inconsistency\n", WSR_Stream->WS_Stream->Rank, ReadRequestMsg->Timestep); fprintf(stderr, @@ -449,8 +454,8 @@ typedef struct _EvpathCompletionHandle void *Buffer; int Failed; int Rank; - long Offset; - long Length; + size_t Offset; + size_t Length; struct _EvpathCompletionHandle *Next; } *EvpathCompletionHandle; @@ -504,36 +509,36 @@ static void EvpathReadReplyHandler(CManager cm, CMConnection conn, void *msg_v, /* * To "fingerprint" a data block, take 8 sample bytes in it and put - * them in a long. If a sample point is zero, use the next non-zero + * them in an int64_t. If a sample point is zero, use the next non-zero * byte. This is only used in verbose mode as an indication that * we're dealing with a copy of the memory region between reader and * writer, so we're not being pedantic about anything here. */ -static unsigned long writeBlockFingerprint(char *Page, size_t Size) +static uint64_t writeBlockFingerprint(char *block, size_t psize) { - size_t Start = Size / 16; - size_t Stride = Size / 8; - unsigned long Print = 0; - if (!Page) + size_t Start = psize / 16; + size_t Stride = psize / 8; + size_t print = 0; + if (!block) return 0; - for (int i = 0; i < 8; i++) + for (size_t i = 0; i < 8; i++) { size_t Index = Start + Stride * i; unsigned char Component = 0; - while ((Page[Index] == 0) && (Index < (Size - 1))) + while ((block[Index] == 0) && (Index < (psize - 1))) { Component++; Index++; } - Component += (unsigned char)Page[Index]; - Print |= (((unsigned long)Component) << (8 * i)); + Component += (unsigned char)block[Index]; + print |= (((size_t)Component) << (8 * i)); } - return Print; + return print; } // reader-side routine, called from the main program static int HandleRequestWithPreloaded(CP_Services Svcs, Evpath_RS_Stream RS_Stream, int Rank, - long Timestep, size_t Offset, size_t Length, void *Buffer) + size_t Timestep, size_t Offset, size_t Length, void *Buffer) { RSTimestepList Entry = NULL; Entry = RS_Stream->QueuedTimesteps; @@ -554,7 +559,7 @@ static int HandleRequestWithPreloaded(CP_Services Svcs, Evpath_RS_Stream RS_Stre } // reader-side routine, called from the main program -static void DiscardPriorPreloaded(CP_Services Svcs, Evpath_RS_Stream RS_Stream, long Timestep) +static void DiscardPriorPreloaded(CP_Services Svcs, Evpath_RS_Stream RS_Stream, size_t Timestep) { RSTimestepList Entry, Last = NULL; Entry = RS_Stream->QueuedTimesteps; @@ -924,7 +929,7 @@ typedef struct _EvpathPerTimestepInfo // reader-side routine, called from the main program static void *EvpathReadRemoteMemory(CP_Services Svcs, DP_RS_Stream Stream_v, int Rank, - long Timestep, size_t Offset, size_t Length, void *Buffer, + size_t Timestep, size_t Offset, size_t Length, void *Buffer, void *DP_TimestepInfo) { Evpath_RS_Stream Stream = @@ -936,7 +941,7 @@ static void *EvpathReadRemoteMemory(CP_Services Svcs, DP_RS_Stream Stream_v, int struct _EvpathReadRequestMsg ReadRequestMsg; int HadPreload; - static long LastRequestedTimestep = -1; + static size_t LastRequestedTimestep = -1; pthread_mutex_lock(&Stream->DataLock); if ((LastRequestedTimestep != -1) && (LastRequestedTimestep != Timestep)) @@ -1082,7 +1087,7 @@ static void EvpathNotifyConnFailure(CP_Services Svcs, DP_RS_Stream Stream_v, int // writer-side routine, called from the main program static void EvpathWSReaderRegisterTimestep(CP_Services Svcs, DP_WSR_Stream WSRStream_v, - long Timestep, SstPreloadModeType PreloadMode) + size_t Timestep, SstPreloadModeType PreloadMode) { Evpath_WSR_Stream WSR_Stream = (Evpath_WSR_Stream)WSRStream_v; Evpath_WS_Stream WS_Stream = WSR_Stream->WS_Stream; /* pointer to writer struct */ @@ -1144,7 +1149,7 @@ static void EvpathWSReaderRegisterTimestep(CP_Services Svcs, DP_WSR_Stream WSRSt } // reader-side routine, called from the network handler thread -static void EvpathRSTimestepArrived(CP_Services Svcs, DP_RS_Stream RS_Stream_v, long Timestep, +static void EvpathRSTimestepArrived(CP_Services Svcs, DP_RS_Stream RS_Stream_v, size_t Timestep, SstPreloadModeType PreloadMode) { Evpath_RS_Stream RS_Stream = (Evpath_RS_Stream)RS_Stream_v; @@ -1219,7 +1224,7 @@ static void SendSpeculativePreloadMsgs(CP_Services Svcs, Evpath_WSR_Stream WSR_S } } -static void EvpathReaderReleaseTimestep(CP_Services Svcs, DP_WSR_Stream Stream_v, long Timestep) +static void EvpathReaderReleaseTimestep(CP_Services Svcs, DP_WSR_Stream Stream_v, size_t Timestep) { Evpath_WSR_Stream WSR_Stream = (Evpath_WSR_Stream)Stream_v; Evpath_WS_Stream WS_Stream = WSR_Stream->WS_Stream; /* pointer to writer struct */ @@ -1269,7 +1274,7 @@ static void EvpathReaderReleaseTimestep(CP_Services Svcs, DP_WSR_Stream Stream_v } static void EvpathProvideTimestep(CP_Services Svcs, DP_WS_Stream Stream_v, struct _SstData *Data, - struct _SstData *LocalMetadata, long Timestep, + struct _SstData *LocalMetadata, size_t Timestep, void **TimestepInfoPtr) { Evpath_WS_Stream WS_Stream = (Evpath_WS_Stream)Stream_v; @@ -1312,7 +1317,7 @@ static void EvpathProvideTimestep(CP_Services Svcs, DP_WS_Stream Stream_v, struc *TimestepInfoPtr = NULL; } -static void EvpathReleaseTimestep(CP_Services Svcs, DP_WS_Stream Stream_v, long Timestep) +static void EvpathReleaseTimestep(CP_Services Svcs, DP_WS_Stream Stream_v, size_t Timestep) { Evpath_WS_Stream WS_Stream = (Evpath_WS_Stream)Stream_v; TimestepList List; @@ -1379,7 +1384,7 @@ static void EvpathReleaseTimestep(CP_Services Svcs, DP_WS_Stream Stream_v, long * Shouldn't ever get here because we should never release a * timestep that we don't have. */ - fprintf(stderr, "Failed to release Timestep %ld, not found\n", Timestep); + fprintf(stderr, "Failed to release Timestep %zd, not found\n", Timestep); assert(0); } pthread_mutex_unlock(&WS_Stream->DataLock); @@ -1443,8 +1448,8 @@ extern NO_SANITIZE_THREAD CP_DP_Interface LoadEVpathDP() evpathDPInterface.readRemoteMemory = EvpathReadRemoteMemory; evpathDPInterface.waitForCompletion = EvpathWaitForCompletion; evpathDPInterface.notifyConnFailure = EvpathNotifyConnFailure; - evpathDPInterface.provideTimestep = EvpathProvideTimestep; - evpathDPInterface.releaseTimestep = EvpathReleaseTimestep; + evpathDPInterface.provideTimestep = (CP_DP_ProvideTimestepFunc)EvpathProvideTimestep; + evpathDPInterface.releaseTimestep = (CP_DP_ReleaseTimestepFunc)EvpathReleaseTimestep; evpathDPInterface.readerRegisterTimestep = EvpathWSReaderRegisterTimestep; evpathDPInterface.readerReleaseTimestep = EvpathReaderReleaseTimestep; evpathDPInterface.WSRreadPatternLocked = NULL; diff --git a/source/adios2/toolkit/sst/dp/mpi_dp.c b/source/adios2/toolkit/sst/dp/mpi_dp.c index 1be46913dc..a90e0da02a 100644 --- a/source/adios2/toolkit/sst/dp/mpi_dp.c +++ b/source/adios2/toolkit/sst/dp/mpi_dp.c @@ -129,7 +129,7 @@ typedef struct _MpiStreamWPR typedef struct _TimeStepsEntry { - long TimeStep; + size_t TimeStep; struct _SstData *Data; STAILQ_ENTRY(_TimeStepsEntry) entries; } *TimeStepsEntry; @@ -150,7 +150,7 @@ typedef struct _MpiReadRequestMsg { int NotifyCondition; int RequestingRank; - long TimeStep; + size_t TimeStep; size_t Length; size_t Offset; void *StreamRS; @@ -162,7 +162,7 @@ typedef struct _MpiReadReplyMsg char *Data; char *MpiPortName; int NotifyCondition; - long TimeStep; + size_t TimeStep; size_t DataLength; void *StreamRS; } *MpiReadReplyMsg; @@ -179,7 +179,7 @@ typedef struct _MpiCompletionHandle } *MpiCompletionHandle; static FMField MpiReadRequestList[] = { - {"TimeStep", "integer", sizeof(long), FMOffset(MpiReadRequestMsg, TimeStep)}, + {"TimeStep", "integer", sizeof(size_t), FMOffset(MpiReadRequestMsg, TimeStep)}, {"Offset", "integer", sizeof(size_t), FMOffset(MpiReadRequestMsg, Offset)}, {"Length", "integer", sizeof(size_t), FMOffset(MpiReadRequestMsg, Length)}, {"StreamWPR", "integer", sizeof(void *), FMOffset(MpiReadRequestMsg, StreamWPR)}, @@ -193,7 +193,7 @@ static FMStructDescRec MpiReadRequestStructs[] = { {NULL, NULL, 0, NULL}}; static FMField MpiReadReplyList[] = { - {"TimeStep", "integer", sizeof(long), FMOffset(MpiReadReplyMsg, TimeStep)}, + {"TimeStep", "integer", sizeof(size_t), FMOffset(MpiReadReplyMsg, TimeStep)}, {"StreamRS", "integer", sizeof(void *), FMOffset(MpiReadReplyMsg, StreamRS)}, {"DataLength", "integer", sizeof(size_t), FMOffset(MpiReadReplyMsg, DataLength)}, {"NotifyCondition", "integer", sizeof(int), FMOffset(MpiReadReplyMsg, NotifyCondition)}, @@ -418,7 +418,7 @@ static void MpiProvideWriterDataToReader(CP_Services Svcs, DP_RS_Stream RS_Strea /** * LoadTimeStep */ -static char *LoadTimeStep(MpiStreamWR Stream, long TimeStep) +static char *LoadTimeStep(MpiStreamWR Stream, size_t TimeStep) { TimeStepsEntry Entry = NULL; char *Data = NULL; @@ -453,7 +453,7 @@ static char *LoadTimeStep(MpiStreamWR Stream, long TimeStep) * call returns. The void* return value will later be passed to a * WaitForCompletion call and should represent a completion handle. */ -static void *MpiReadRemoteMemory(CP_Services Svcs, DP_RS_Stream Stream_v, int Rank, long TimeStep, +static void *MpiReadRemoteMemory(CP_Services Svcs, DP_RS_Stream Stream_v, int Rank, size_t TimeStep, size_t Offset, size_t Length, void *Buffer, void *DP_TimeStepInfo) { /* DP_RS_Stream is the return from InitReader */ @@ -691,7 +691,7 @@ static void MpiReadReplyHandler(CManager cm, CMConnection conn, void *msg_v, voi * */ static void MpiProvideTimeStep(CP_Services Svcs, DP_WS_Stream Stream_v, struct _SstData *Data, - struct _SstData *LocalMetadata, long TimeStep, + struct _SstData *LocalMetadata, size_t TimeStep, void **TimeStepInfoPtr) { MpiStreamWR Stream = (MpiStreamWR)Stream_v; @@ -713,7 +713,7 @@ static void MpiProvideTimeStep(CP_Services Svcs, DP_WS_Stream Stream_v, struct _ * plane that a particular timestep is no longer required and any resources * devoted to serving it can be released. */ -static void MpiReleaseTimeStep(CP_Services Svcs, DP_WS_Stream Stream_v, long TimeStep) +static void MpiReleaseTimeStep(CP_Services Svcs, DP_WS_Stream Stream_v, size_t TimeStep) { MpiStreamWR Stream = (MpiStreamWR)Stream_v; @@ -939,9 +939,9 @@ extern CP_DP_Interface LoadMpiDP() .initWriter = MpiInitWriter, .initWriterPerReader = MpiInitWriterPerReader, .provideWriterDataToReader = MpiProvideWriterDataToReader, - .readRemoteMemory = MpiReadRemoteMemory, + .readRemoteMemory = (CP_DP_ReadRemoteMemoryFunc)MpiReadRemoteMemory, .waitForCompletion = MpiWaitForCompletion, - .provideTimestep = MpiProvideTimeStep, + .provideTimestep = (CP_DP_ProvideTimestepFunc)MpiProvideTimeStep, .releaseTimestep = MpiReleaseTimeStep, .getPriority = MpiGetPriority, .destroyReader = MpiDestroyReader, diff --git a/source/adios2/toolkit/sst/dp/rdma_dp.c b/source/adios2/toolkit/sst/dp/rdma_dp.c index e3800f4ff0..311e79a7f5 100644 --- a/source/adios2/toolkit/sst/dp/rdma_dp.c +++ b/source/adios2/toolkit/sst/dp/rdma_dp.c @@ -2716,17 +2716,19 @@ extern NO_SANITIZE_THREAD CP_DP_Interface LoadRdmaDP() RdmaDPInterface.initWriter = RdmaInitWriter; RdmaDPInterface.initWriterPerReader = RdmaInitWriterPerReader; RdmaDPInterface.provideWriterDataToReader = RdmaProvideWriterDataToReader; - RdmaDPInterface.readRemoteMemory = RdmaReadRemoteMemory; + RdmaDPInterface.readRemoteMemory = (CP_DP_ReadRemoteMemoryFunc)RdmaReadRemoteMemory; RdmaDPInterface.waitForCompletion = RdmaWaitForCompletion; RdmaDPInterface.notifyConnFailure = RdmaNotifyConnFailure; - RdmaDPInterface.provideTimestep = RdmaProvideTimestep; - RdmaDPInterface.readerRegisterTimestep = RdmaReaderRegisterTimestep; - RdmaDPInterface.releaseTimestep = RdmaReleaseTimestep; - RdmaDPInterface.readerReleaseTimestep = RdmaReleaseTimestepPerReader; - RdmaDPInterface.WSRreadPatternLocked = RdmaReadPatternLocked; - RdmaDPInterface.RSreadPatternLocked = RdmaWritePatternLocked; - RdmaDPInterface.RSReleaseTimestep = RdmaReaderReleaseTimestep; - RdmaDPInterface.timestepArrived = RdmaTimestepArrived; + RdmaDPInterface.provideTimestep = (CP_DP_ProvideTimestepFunc)RdmaProvideTimestep; + RdmaDPInterface.readerRegisterTimestep = + (CP_DP_PerReaderTimestepRegFunc)RdmaReaderRegisterTimestep; + RdmaDPInterface.releaseTimestep = (CP_DP_ReleaseTimestepFunc)RdmaReleaseTimestep; + RdmaDPInterface.readerReleaseTimestep = + (CP_DP_PerReaderReleaseTimestepFunc)RdmaReleaseTimestepPerReader; + RdmaDPInterface.WSRreadPatternLocked = (CP_DP_WSR_ReadPatternLockedFunc)RdmaReadPatternLocked; + RdmaDPInterface.RSreadPatternLocked = (CP_DP_WSR_ReadPatternLockedFunc)RdmaWritePatternLocked; + RdmaDPInterface.RSReleaseTimestep = (CP_DP_RSReleaseTimestepFunc)RdmaReaderReleaseTimestep; + RdmaDPInterface.timestepArrived = (CP_DP_ReaderTimestepArrivalFunc)RdmaTimestepArrived; RdmaDPInterface.destroyReader = RdmaDestroyReader; RdmaDPInterface.destroyWriter = RdmaDestroyWriter; RdmaDPInterface.destroyWriterPerReader = RdmaDestroyWriterPerReader; diff --git a/source/adios2/toolkit/sst/dp/ucx_dp.c b/source/adios2/toolkit/sst/dp/ucx_dp.c index 1b33c5c4c5..dc51937a50 100644 --- a/source/adios2/toolkit/sst/dp/ucx_dp.c +++ b/source/adios2/toolkit/sst/dp/ucx_dp.c @@ -758,17 +758,17 @@ extern NO_SANITIZE_THREAD CP_DP_Interface LoadUcxDP() UcxDPInterface.initWriter = UcxInitWriter; UcxDPInterface.initWriterPerReader = UcxInitWriterPerReader; UcxDPInterface.provideWriterDataToReader = UcxProvideWriterDataToReader; - UcxDPInterface.readRemoteMemory = UcxReadRemoteMemory; + UcxDPInterface.readRemoteMemory = (CP_DP_ReadRemoteMemoryFunc)UcxReadRemoteMemory; UcxDPInterface.waitForCompletion = UcxWaitForCompletion; UcxDPInterface.notifyConnFailure = UcxNotifyConnFailure; - UcxDPInterface.provideTimestep = UcxProvideTimestep; + UcxDPInterface.provideTimestep = (CP_DP_ProvideTimestepFunc)UcxProvideTimestep; UcxDPInterface.readerRegisterTimestep = NULL; - UcxDPInterface.releaseTimestep = UcxReleaseTimestep; + UcxDPInterface.releaseTimestep = (CP_DP_ReleaseTimestepFunc)UcxReleaseTimestep; UcxDPInterface.readerReleaseTimestep = NULL; UcxDPInterface.WSRreadPatternLocked = NULL; UcxDPInterface.RSreadPatternLocked = NULL; UcxDPInterface.RSReleaseTimestep = NULL; - UcxDPInterface.timestepArrived = UcxTimestepArrived; + UcxDPInterface.timestepArrived = (CP_DP_ReaderTimestepArrivalFunc)UcxTimestepArrived; UcxDPInterface.destroyReader = UcxDestroyReader; UcxDPInterface.destroyWriter = UcxDestroyWriter; UcxDPInterface.destroyWriterPerReader = UcxDestroyWriterPerReader; diff --git a/source/adios2/toolkit/sst/dp_interface.h b/source/adios2/toolkit/sst/dp_interface.h index 6608211bf8..bd2ea276ed 100644 --- a/source/adios2/toolkit/sst/dp_interface.h +++ b/source/adios2/toolkit/sst/dp_interface.h @@ -178,7 +178,7 @@ typedef void *DP_CompletionHandle; * the writer side in ProvideTimestepFunc. */ typedef DP_CompletionHandle (*CP_DP_ReadRemoteMemoryFunc)(CP_Services Svcs, DP_RS_Stream RS_Stream, - int Rank, long Timestep, size_t Offset, + int Rank, size_t Timestep, size_t Offset, size_t Length, void *Buffer, void *DP_TimestepInfo); @@ -217,7 +217,7 @@ typedef void (*CP_DP_NotifyConnFailureFunc)(CP_Services Svcs, DP_RS_Stream RS_St */ typedef void (*CP_DP_ProvideTimestepFunc)(CP_Services Svcs, DP_WS_Stream Stream, struct _SstData *Data, struct _SstData *LocalMetadata, - long Timestep, void **TimestepInfoPtr); + size_t Timestep, void **TimestepInfoPtr); typedef enum { @@ -233,7 +233,7 @@ typedef enum * specific reader. */ typedef void (*CP_DP_PerReaderTimestepRegFunc)(CP_Services Svcs, DP_WSR_Stream Stream, - long Timestep, SstPreloadModeType PreloadMode); + size_t Timestep, SstPreloadModeType PreloadMode); /*! * CP_DP_ReaderTimestepArrivalFunc is the type of a dataplane function that @@ -241,7 +241,7 @@ typedef void (*CP_DP_PerReaderTimestepRegFunc)(CP_Services Svcs, DP_WSR_Stream S * the reader side.. */ typedef void (*CP_DP_ReaderTimestepArrivalFunc)(CP_Services Svcs, DP_RS_Stream Stream, - long Timestep, SstPreloadModeType PreloadMode); + size_t Timestep, SstPreloadModeType PreloadMode); /*! * CP_DP_ReadPatternLockedFunc is the type of a dataplane function @@ -250,7 +250,7 @@ typedef void (*CP_DP_ReaderTimestepArrivalFunc)(CP_Services Svcs, DP_RS_Stream S * writer has also specified that his write geometry will not change. */ typedef void (*CP_DP_ReadPatternLockedFunc)(CP_Services Svcs, DP_WSR_Stream Stream, - long EffectiveTimestep); + size_t EffectiveTimestep); /*! * CP_DP_WSR_ReadPatternLockedFunc is the type of a dataplane function @@ -258,7 +258,7 @@ typedef void (*CP_DP_ReadPatternLockedFunc)(CP_Services Svcs, DP_WSR_Stream Stre * have agreed that the read geometry will not change. */ typedef void (*CP_DP_WSR_ReadPatternLockedFunc)(CP_Services Svcs, DP_WSR_Stream Stream, - long EffectiveTimestep); + size_t EffectiveTimestep); /*! * CP_DP_RS_ReadPatternLockedFunc is the type of a dataplane function @@ -266,7 +266,7 @@ typedef void (*CP_DP_WSR_ReadPatternLockedFunc)(CP_Services Svcs, DP_WSR_Stream * have agreed that the read geometry will not change. */ typedef void (*CP_DP_RS_ReadPatternLockedFunc)(CP_Services Svcs, DP_RS_Stream Stream, - long EffectiveTimestep); + size_t EffectiveTimestep); /*! * CP_DP_ReleaseTimestepFunc is the type of a dataplane function that @@ -274,7 +274,7 @@ typedef void (*CP_DP_RS_ReadPatternLockedFunc)(CP_Services Svcs, DP_RS_Stream St * will no longer be the subject of remote read requests, so its resources * may be released. */ -typedef void (*CP_DP_ReleaseTimestepFunc)(CP_Services Svcs, DP_WS_Stream Stream, long Timestep); +typedef void (*CP_DP_ReleaseTimestepFunc)(CP_Services Svcs, DP_WS_Stream Stream, size_t Timestep); /*! * CP_DP_PerReaderReleaseTimestepFunc is the type of a dataplane function @@ -286,7 +286,7 @@ typedef void (*CP_DP_ReleaseTimestepFunc)(CP_Services Svcs, DP_WS_Stream Stream, * ReleaseTimestepFunc. */ typedef void (*CP_DP_PerReaderReleaseTimestepFunc)(CP_Services Svcs, DP_WSR_Stream Stream, - long Timestep); + size_t Timestep); /*! * CP_DP_RSReleaseTimestepFunc is the type of a READER-SIDE dataplane function @@ -294,7 +294,7 @@ typedef void (*CP_DP_PerReaderReleaseTimestepFunc)(CP_Services Svcs, DP_WSR_Stre * will no longer be the subject of remote read requests, so its resources * may be released. */ -typedef void (*CP_DP_RSReleaseTimestepFunc)(CP_Services Svcs, DP_RS_Stream Stream, long Timestep); +typedef void (*CP_DP_RSReleaseTimestepFunc)(CP_Services Svcs, DP_RS_Stream Stream, size_t Timestep); /*! * CP_DP_GetPriorityFunc is the type of a dataplane initialization diff --git a/source/adios2/toolkit/sst/sst.h b/source/adios2/toolkit/sst/sst.h index 4099f014ff..0ede2fcb9e 100644 --- a/source/adios2/toolkit/sst/sst.h +++ b/source/adios2/toolkit/sst/sst.h @@ -103,18 +103,18 @@ extern SstStream SstReaderOpen(const char *filename, SstParams Params, SMPI_Comm extern void SstReaderGetParams(SstStream stream, SstMarshalMethod *WriterMarshalMethod, int *WriterIsRowMajor); extern SstFullMetadata SstGetCurMetadata(SstStream stream); -extern SstMetaMetaList SstGetNewMetaMetaData(SstStream stream, long timestep); -extern SstBlock SstGetAttributeData(SstStream stream, long timestep); -extern void *SstReadRemoteMemory(SstStream s, int rank, long timestep, size_t offset, size_t length, - void *buffer, void *DP_TimestepInfo); +extern SstMetaMetaList SstGetNewMetaMetaData(SstStream stream, size_t timestep); +extern SstBlock SstGetAttributeData(SstStream stream, size_t timestep); +extern void *SstReadRemoteMemory(SstStream s, int rank, size_t timestep, size_t offset, + size_t length, void *buffer, void *DP_TimestepInfo); extern SstStatusValue SstWaitForCompletion(SstStream stream, void *completion); extern void SstReleaseStep(SstStream stream); extern SstStatusValue SstAdvanceStep(SstStream stream, const float timeout_sec); extern void SstReaderClose(SstStream stream); -extern long SstCurrentStep(SstStream s); +extern size_t SstCurrentStep(SstStream s); /* SstReaderDefinitionLock is called once only, on transition from unlock to * locked definitions */ -extern void SstReaderDefinitionLock(SstStream stream, long EffectiveTimestep); +extern void SstReaderDefinitionLock(SstStream stream, size_t EffectiveTimestep); /* * Calls that support FFS-based marshaling, source code in cp/ffs_marshal.c diff --git a/source/adios2/toolkit/sst/util/sst_conn_tool.c b/source/adios2/toolkit/sst/util/sst_conn_tool.c index f775c53f5e..289e151c65 100644 --- a/source/adios2/toolkit/sst/util/sst_conn_tool.c +++ b/source/adios2/toolkit/sst/util/sst_conn_tool.c @@ -23,7 +23,16 @@ a hostname is identified using gethostname and getdomainname and it translates to any interfaces. */ +#ifdef _MSC_VER +#include "win_interface.h" +#else #include +#include +#include +#include +#include +#include +#endif #include #include #include @@ -31,14 +40,10 @@ to any interfaces. #include #include #include -#include #include #include #include -#include #include -#include -#include #ifdef HAVE_SYS_SOCKIO_H #include #endif @@ -46,7 +51,6 @@ to any interfaces. #include "adios2/common/ADIOSConfig.h" #include #include -#include #include "sst.h" diff --git a/source/adios2/toolkit/sst/util/sst_conn_tool.cxx b/source/adios2/toolkit/sst/util/sst_conn_tool.cxx index 3fa9051c47..9c6d8fcb00 100644 --- a/source/adios2/toolkit/sst/util/sst_conn_tool.cxx +++ b/source/adios2/toolkit/sst/util/sst_conn_tool.cxx @@ -6,16 +6,15 @@ #if ADIOS2_USE_MPI #include "adios2/helper/adiosCommMPI.h" -static adios2::helper::Comm CommWorld = - adios2::helper::CommWithMPI(MPI_COMM_WORLD); +static adios2::helper::Comm CommWorld = adios2::helper::CommWithMPI(MPI_COMM_WORLD); #else #include "adios2/helper/adiosCommDummy.h" static adios2::helper::Comm CommWorld = adios2::helper::CommDummy(); #endif +extern "C" { SMPI_Comm SMPI_COMM_WORLD = &CommWorld; -extern "C" { int SMPI_Init(int *argc, char ***argv) { #if ADIOS2_USE_MPI diff --git a/source/adios2/toolkit/sst/win_interface.h b/source/adios2/toolkit/sst/win_interface.h new file mode 100644 index 0000000000..b609a02f5a --- /dev/null +++ b/source/adios2/toolkit/sst/win_interface.h @@ -0,0 +1,56 @@ +#define FD_SETSIZE 1024 +#include "winsock2.h" +#include +#include +#include +#include +#include +#include +#define pthread_mutex_t SRWLOCK +#define pthread_thread_t HANDLE +#define pthread_thread_id DWORD +#define pthread_cond_t CONDITION_VARIABLE +#define pthread_self() GetCurrentThreadId() +#define pthread_mutex_init(m, x) InitializeSRWLock(m) +#define pthread_mutex_lock(m) AcquireSRWLockExclusive(m) +#define pthread_mutex_unlock(m) ReleaseSRWLockExclusive(m) +#define pthread_cond_init(c, x) InitializeConditionVariable(c) +#define pthread_cond_signal(c) WakeConditionVariable(c) +#define pthread_cond_wait(c, m) SleepConditionVariableSRW(c, m, INFINITE, 0) +#define PTHREAD_MUTEX_INITIALIZER SRWLOCK_INIT + +#define strdup _strdup +#define fileno _fileno +#define getpid _getpid +#define unlink _unlink +#ifndef PATH_MAX +#define PATH_MAX 400 +#endif +#define realpath(N, R) _fullpath((R), (N), PATH_MAX) +#define close _close +#define sleep(x) Sleep((x)*1000) +#define usleep(x) Sleep((x) >> 10) +#define read _read +#define lseek _lseek +#define open _open +static void gettimeofday(struct timeval *now, void *tz) +{ + /* GSE... No gettimeofday on windows. + * Must use _ftime, get millisec time, convert to usec. Bleh. + */ + struct _timeb nowb; + _ftime(&nowb); + now->tv_sec = (long)nowb.time; + now->tv_usec = nowb.millitm * 1000; +} +#define timersub(a, b, result) \ + do \ + { \ + (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ + (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ + if ((result)->tv_usec < 0) \ + { \ + --(result)->tv_sec; \ + (result)->tv_usec += 1000000; \ + } \ + } while (0) diff --git a/source/adios2/toolkit/transport/file/FileRemote.cpp b/source/adios2/toolkit/transport/file/FileRemote.cpp index 24dd61d8c5..28477c58d4 100644 --- a/source/adios2/toolkit/transport/file/FileRemote.cpp +++ b/source/adios2/toolkit/transport/file/FileRemote.cpp @@ -16,7 +16,10 @@ #include #include // open, fstat #include // open -#include // write, close, ftruncate +#ifdef _MSC_VER +#else +#include // write, close, ftruncate +#endif namespace adios2 { diff --git a/source/adios2/toolkit/transportman/TransportMan.cpp b/source/adios2/toolkit/transportman/TransportMan.cpp index 4d646d8879..7c51d6a9fd 100644 --- a/source/adios2/toolkit/transportman/TransportMan.cpp +++ b/source/adios2/toolkit/transportman/TransportMan.cpp @@ -82,6 +82,9 @@ void TransportMan::MkDirsBarrier(const std::vector &fileNames, } else { +#ifdef CreateDirectory +#undef CreateDirectory +#endif helper::CreateDirectory(path); } } diff --git a/testing/adios2/engine/staging-common/TestThreads.cpp b/testing/adios2/engine/staging-common/TestThreads.cpp index 6884d88210..47b86f1a98 100644 --- a/testing/adios2/engine/staging-common/TestThreads.cpp +++ b/testing/adios2/engine/staging-common/TestThreads.cpp @@ -10,7 +10,7 @@ #include "ParseArgs.h" -using dt = long long; +using dt = int64_t; int value_errors = 0; @@ -41,7 +41,7 @@ int Read(std::string BaseName, int ID) std::lock_guard guard(StdOutMtx); std::cout << "Reader: passed Open" << std::endl; } - std::array ar; + dt ar[1000]; auto status = Reader.BeginStep(); { @@ -62,7 +62,7 @@ int Read(std::string BaseName, int ID) } adios2::Variable
var = io.InquireVariable
("data"); - Reader.Get(var, ar.begin()); + Reader.Get(var, &ar[0]); Reader.EndStep(); dt expect = 0; for (auto &val : ar) @@ -118,7 +118,8 @@ bool Write(std::string BaseName, int ID) std::cout << "Writer completed Open() " << std::endl; } Writer.BeginStep(); - Writer.Put
(var, ar.begin()); + dt *tmp = &ar.front(); + Writer.Put
(var, tmp); Writer.EndStep(); Writer.Close(); { @@ -143,6 +144,10 @@ class TestThreads : public ::testing::Test TestThreads() = default; }; +#ifdef _MSC_VER +#define getpid _getpid +#endif + TEST_F(TestThreads, Basic) { using namespace std; diff --git a/thirdparty/EVPath/EVPath/cm.c b/thirdparty/EVPath/EVPath/cm.c index e1bb4fdc9e..bb33a45f23 100644 --- a/thirdparty/EVPath/EVPath/cm.c +++ b/thirdparty/EVPath/EVPath/cm.c @@ -232,7 +232,7 @@ static thr_thread_t thr_fork(void*(*func)(void*), void *arg) { thr_thread_t new_thread = 0; - int err = thr_thread_create(&new_thread, NULL, (void*(*)(void*))func, arg); + int err = thr_thread_create(&new_thread, NULL, (void*)func, arg); if (err != 0) { return (thr_thread_t) (intptr_t)NULL; } else { @@ -258,7 +258,7 @@ INT_CMfork_comm_thread(CManager cm) if (server_thread == (thr_thread_t)(intptr_t) NULL) { return 0; } - cm->control_list->server_thread = server_thread; + cm->control_list->server_thread = thr_get_thread_id(server_thread); cm->control_list->has_thread = 1; cm->reference_count++; CMtrace_out(cm, CMFreeVerbose, "Forked - CManager %p ref count now %d\n", @@ -1053,7 +1053,7 @@ CManager_free(CManager cm) new_list->select_data = NULL; new_list->add_select = NULL; new_list->remove_select = NULL; - new_list->server_thread = (thr_thread_t)(intptr_t) NULL; + new_list->server_thread = (thr_thread_id)0; new_list->network_blocking_function.func = NULL; new_list->network_polling_function.func = NULL; new_list->polling_function_list = NULL; @@ -2088,6 +2088,7 @@ timeout_conn(CManager cm, void *client_data) if (cm_preread_hook) { do_read = cm_preread_hook(buffer_full_point - buffer_data_end, tmp_message_buffer); } + CMtrace_out(cm, CMLowLevelVerbose, "P5\n"); if (do_read) { if (trans->read_to_buffer_func) { /* @@ -3851,7 +3852,7 @@ CM_init_select(CMControlList cl, CManager cm) } CMtrace_out(cm, CMLowLevelVerbose, "CM - Forked comm thread %p\n", (void*)(intptr_t)server_thread); - cm->control_list->server_thread = server_thread; + cm->control_list->server_thread = thr_get_thread_id(server_thread); cm->control_list->cl_reference_count++; cm->control_list->free_reference_count++; cl->has_thread = 1; diff --git a/thirdparty/EVPath/EVPath/cm_control.c b/thirdparty/EVPath/EVPath/cm_control.c index 4344aedf6c..63862ea49a 100644 --- a/thirdparty/EVPath/EVPath/cm_control.c +++ b/thirdparty/EVPath/EVPath/cm_control.c @@ -242,7 +242,7 @@ INT_CMCondition_wait(CManager cm, int condition) (void*)(intptr_t)cl->server_thread); } if (!cl->has_thread) { - if ((cl->server_thread == (thr_thread_t) (intptr_t) NULL) || (cl->server_thread == thr_thread_self())) { + if ((cl->server_thread == (thr_thread_id) 0) || (cl->server_thread == thr_thread_self())) { cl->cond_polling = 1; while (!(cond->signaled || cond->failed)) { if (cm_control_debug_flag) { @@ -255,7 +255,7 @@ INT_CMCondition_wait(CManager cm, int condition) fprintf(cm->CMTrace_file, "CMLowLevel after Polling for CMcondition %d\n", condition); } /* the poll and handle will set cl->server_thread, restore it */ - cl->server_thread = (thr_thread_t) (intptr_t)NULL; + cl->server_thread = (thr_thread_id) (intptr_t)NULL; if (cm_control_debug_flag) { fprintf(cm->CMTrace_file, "CMLowLevel In condition wait, reset server thread = %lx\n", (long)cl->server_thread); diff --git a/thirdparty/EVPath/EVPath/cm_internal.h b/thirdparty/EVPath/EVPath/cm_internal.h index 173a1ce366..22477c5717 100644 --- a/thirdparty/EVPath/EVPath/cm_internal.h +++ b/thirdparty/EVPath/EVPath/cm_internal.h @@ -15,6 +15,8 @@ #include #define thr_mutex_t pthread_mutex_t #define thr_thread_t pthread_t +#define thr_thread_id thr_thread_t +#define thr_get_thread_id(t) (t) #define thr_condition_t pthread_cond_t #define thr_thread_self() pthread_self() #define thr_thread_exit(status) pthread_exit(status); @@ -34,24 +36,35 @@ #else //#include #include -#define thr_mutex_t HANDLE -#define thr_thread_t DWORD -#define thr_condition_t HANDLE -#define thr_thread_create(w,x,y,z) 0 +extern int win_thread_create(HANDLE* w, void* x, void* y, void* z); +extern void win_mutex_init(SRWLOCK *m); +extern void win_mutex_lock(SRWLOCK* m); +extern void win_mutex_unlock(SRWLOCK* m); +extern void win_mutex_free(SRWLOCK* m); +extern void win_condition_init(CONDITION_VARIABLE *c); +extern void win_condition_wait(CONDITION_VARIABLE *c, SRWLOCK *m); +extern void win_condition_signal(CONDITION_VARIABLE *c); +extern void win_condition_free(CONDITION_VARIABLE *c); +#define thr_mutex_t SRWLOCK +#define thr_thread_t HANDLE +#define thr_thread_id DWORD +#define thr_condition_t CONDITION_VARIABLE +#define thr_thread_create(w,x,y,z) win_thread_create(w,x,y,z) #define thr_thread_self() GetCurrentThreadId() -#define thr_thread_exit(status) +#define thr_thread_exit(status) ExitThread((DWORD)(intptr_t)status) +#define thr_get_thread_id(t) GetThreadId(t) #define thr_thread_detach(thread) #define thr_thread_yield() #define thr_thread_join(t, s) (void)s -#define thr_mutex_init(m) -#define thr_mutex_lock(m) -#define thr_mutex_unlock(m) -#define thr_mutex_free(m) -#define thr_condition_init(c) -#define thr_condition_wait(c, m) -#define thr_condition_signal(c) -#define thr_condition_broadcast(c) -#define thr_condition_free(c) +#define thr_mutex_init(m) win_mutex_init(&m) +#define thr_mutex_lock(m) win_mutex_lock(&m) +#define thr_mutex_unlock(m) win_mutex_unlock(&m) +#define thr_mutex_free(m) win_mutex_free(&m) +#define thr_condition_init(c) win_condition_init(&c) +#define thr_condition_wait(c, m) win_condition_wait(&c, &m) +#define thr_condition_signal(c) win_condition_signal(&c) +#define thr_condition_broadcast(c) error +#define thr_condition_free(c) win_condition_free(&c) #endif #include @@ -240,7 +253,7 @@ typedef struct _CMControlList { int closed; int has_thread; int cond_polling; - thr_thread_t server_thread; + thr_thread_id server_thread; } CMControlList_s; struct queued_data_rec { diff --git a/thirdparty/EVPath/EVPath/cm_threadio.c b/thirdparty/EVPath/EVPath/cm_threadio.c index 08441bbd12..ba64380d44 100644 --- a/thirdparty/EVPath/EVPath/cm_threadio.c +++ b/thirdparty/EVPath/EVPath/cm_threadio.c @@ -46,7 +46,7 @@ static thr_thread_t thr_fork(void*(*func)(void*), void *arg) { thr_thread_t new_thread = 0; - int err = thr_thread_create(&new_thread, NULL, (void*(*)(void*))func, arg); + int err = thr_thread_create(&new_thread, 0, (void*)func, arg); if (err != 0) { return (thr_thread_t) (intptr_t) NULL; } else { diff --git a/thirdparty/EVPath/EVPath/cm_util.c b/thirdparty/EVPath/EVPath/cm_util.c index d6509555db..082f1f0e31 100644 --- a/thirdparty/EVPath/EVPath/cm_util.c +++ b/thirdparty/EVPath/EVPath/cm_util.c @@ -1,5 +1,4 @@ #include "config.h" -#ifndef MODULE #include #ifdef HAVE_UNISTD_H @@ -12,11 +11,7 @@ #include #endif #include -#else -#include "kernel/kcm.h" -#include "kernel/cm_kernel.h" -#include "kernel/library.h" -#endif + #include "atl.h" #include "evpath.h" #include "chr_time.h" @@ -297,3 +292,50 @@ INT_CMfree(void *ptr) free(ptr); } +#ifdef _MSC_VER +#include +#include +#include +int +win_thread_create(HANDLE *threadp, void *attr, void *startfunc, void *arg) +{ + HANDLE h = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)startfunc, arg, 0, attr); + (*threadp) = h; + return 0; +} +void win_mutex_init(SRWLOCK *m) +{ + InitializeSRWLock(m); +} + + +void win_mutex_lock(SRWLOCK *m) +{ + AcquireSRWLockExclusive(m); +} +void win_mutex_unlock(SRWLOCK *m) +{ + ReleaseSRWLockExclusive(m); +} +void win_mutex_free(SRWLOCK *m) +{ + // nothing necessary +} +extern void win_condition_init(CONDITION_VARIABLE *c) +{ + InitializeConditionVariable(c); +} +extern void win_condition_wait(CONDITION_VARIABLE *c, SRWLOCK* m) +{ + SleepConditionVariableSRW(c, m, INFINITE, 0); +} + +extern void win_condition_signal(CONDITION_VARIABLE *c) +{ + WakeConditionVariable(c); +} +extern void win_condition_free(CONDITION_VARIABLE *c) +{ + // nothing necessary +} +#endif diff --git a/thirdparty/EVPath/EVPath/cmselect.c b/thirdparty/EVPath/EVPath/cmselect.c index ab0ad46a19..866cd9c925 100644 --- a/thirdparty/EVPath/EVPath/cmselect.c +++ b/thirdparty/EVPath/EVPath/cmselect.c @@ -109,7 +109,7 @@ typedef struct func_list_item { } FunctionListElement; typedef struct select_data { - thr_thread_t server_thread; + thr_thread_id server_thread; void *fdset; /* bitmap of the fds for read select */ void *write_set; /* bitmap of the fds for write select */ @@ -153,7 +153,7 @@ init_select_data(CMtrans_services svc, select_data_ptr *sdp, CManager cm) EVPATH_FD_ZERO((fd_set *) sd->fdset); sd->write_set = svc->malloc_func(sizeof(fd_set)); EVPATH_FD_ZERO((fd_set *) sd->write_set); - sd->server_thread = (thr_thread_t)(intptr_t) NULL; + sd->server_thread = (thr_thread_id)(intptr_t) NULL; sd->closed = 0; sd->sel_item_max = 0; sd->select_items = (FunctionListElement *) svc->malloc_func(sizeof(FunctionListElement)); @@ -179,7 +179,7 @@ init_select_data(CMtrans_services svc, select_data_ptr *sdp, CManager cm) typedef struct _periodic_task { int period_sec; int period_usec; - thr_thread_t executing; + thr_thread_id executing; struct timeval next_time; select_list_func func; void *arg1; @@ -221,7 +221,7 @@ set_soonest_timeout(struct timeval *timeout, periodic_task_handle task_list, str if (task_list == NULL) return; this_delay.tv_sec = task_list->next_time.tv_sec - now.tv_sec; this_delay.tv_usec = task_list->next_time.tv_usec - now.tv_usec; - if (task_list->executing == (thr_thread_t)-1) { + if (task_list->executing == (thr_thread_id)-1) { /* this task not executing already, see when it needs to run */ if (this_delay.tv_usec < 0) { this_delay.tv_sec--; @@ -260,7 +260,7 @@ socket_select(CMtrans_services svc, select_data_ptr sd, int timeout_sec, int tim int tmp_select_consistency_number = sd->select_consistency_number; if (sd->closed) { - sd->server_thread = (thr_thread_t)(intptr_t) NULL; + sd->server_thread = (thr_thread_id)(intptr_t) NULL; return; } @@ -268,7 +268,7 @@ socket_select(CMtrans_services svc, select_data_ptr sd, int timeout_sec, int tim /* assert CM is locked */ assert(CM_LOCKED(svc, sd->cm)); } - if (sd->server_thread == (thr_thread_t)(intptr_t) NULL) { + if (sd->server_thread == (thr_thread_id)(intptr_t) NULL) { /* no server thread set, must be this one */ sd->server_thread = thr_thread_self(); } @@ -321,7 +321,7 @@ socket_select(CMtrans_services svc, select_data_ptr sd, int timeout_sec, int tim ACQUIRE_CM_LOCK(svc, sd->cm); } if (sd->closed) { - sd->server_thread = (thr_thread_t)(intptr_t) NULL; + sd->server_thread = (thr_thread_id)(intptr_t) NULL; return; } #ifndef HAVE_WINDOWS_H @@ -440,7 +440,7 @@ socket_select(CMtrans_services svc, select_data_ptr sd, int timeout_sec, int tim if (res != 0) { for (i = 0; i <= sd->sel_item_max; i++) { if (sd->closed) { - sd->server_thread = (thr_thread_t)(intptr_t) NULL; + sd->server_thread = (thr_thread_id)(intptr_t) NULL; return; } if (FD_ISSET(i, &wr_set)) { @@ -496,14 +496,14 @@ socket_select(CMtrans_services svc, select_data_ptr sd, int timeout_sec, int tim increment_time(&this_periodic_task->next_time, this_periodic_task->period_sec, this_periodic_task->period_usec); - if (this_periodic_task->executing == (thr_thread_t)-1) { + if (this_periodic_task->executing == (thr_thread_id)-1) { this_periodic_task->executing = thr_thread_self(); DROP_CM_LOCK(svc, sd->cm); this_periodic_task->func(this_periodic_task->arg1, this_periodic_task->arg2); ACQUIRE_CM_LOCK(svc, sd->cm); next = this_periodic_task->next; - this_periodic_task->executing = (thr_thread_t) -1; + this_periodic_task->executing = (thr_thread_id) -1; if ((this_periodic_task->period_sec == 0) && (this_periodic_task->period_usec == 0)) { remove_periodic_task(sd, this_periodic_task); @@ -652,7 +652,7 @@ libcmselect_LTX_add_periodic(CMtrans_services svc, select_data_ptr *sdp, int int } handle->period_sec = interval_sec; handle->period_usec = interval_usec; - handle->executing = (thr_thread_t) -1; + handle->executing = (thr_thread_id) -1; #ifndef HAVE_WINDOWS_H gettimeofday(&handle->next_time, NULL); #else @@ -699,7 +699,7 @@ libcmselect_LTX_add_delayed_task(CMtrans_services svc, select_data_ptr *sdp, int } handle->period_sec = 0; handle->period_usec = 0; - handle->executing = (thr_thread_t) -1; + handle->executing = (thr_thread_id) -1; #ifndef HAVE_WINDOWS_H gettimeofday(&handle->next_time, NULL); #else @@ -751,7 +751,7 @@ remove_periodic_task(select_data_ptr sd, periodic_task_handle handle) if (handle->executing != thr_thread_self()) { /* someone besides us executing this ? */ int i = 0; - while (handle->executing != (thr_thread_t)-1) { + while (handle->executing != (thr_thread_id)-1) { /* wait until they're done */ thr_thread_yield(); i++; diff --git a/thirdparty/EVPath/EVPath/cmsockets.c b/thirdparty/EVPath/EVPath/cmsockets.c index a054fd452d..3cc819a9d4 100644 --- a/thirdparty/EVPath/EVPath/cmsockets.c +++ b/thirdparty/EVPath/EVPath/cmsockets.c @@ -879,6 +879,26 @@ set_block_state(CMtrans_services svc, socket_conn_data_ptr scd, scd->fd); } #else + if ((needed_block_state == Block) && (scd->block_state == Non_Block)) { + u_long mode = 0; // 0 to enable blocking socket + int ret = ioctlsocket(scd->fd, FIONBIO, &mode); + scd->block_state = Block; + if (ret != NO_ERROR) + printf("ioctlsocket failed with error: %ld\n", ret); + + svc->trace_out(scd->sd->cm, "CMSocket switch fd %d to blocking WIN properly", + scd->fd); + } else if ((needed_block_state == Non_Block) && + (scd->block_state == Block)) { + u_long mode = 1; // 1 to enable non-blocking socket + int ret = ioctlsocket(scd->fd, FIONBIO, &mode); + if (ret != NO_ERROR) + printf("ioctlsocket failed with error: %ld\n", ret); + + scd->block_state = Non_Block; + svc->trace_out(scd->sd->cm, "CMSocket switch fd %d to nonblocking WIN properly", + scd->fd); + } #endif } @@ -909,7 +929,8 @@ libcmsockets_LTX_read_to_buffer_func(CMtrans_services svc, socket_conn_data_ptr iget = read(scd->fd, (char *) buffer, (int)requested_len); if ((iget == -1) || (iget == 0)) { int lerrno = errno; - if ((lerrno != EWOULDBLOCK) && + if ((lerrno != 0) && + (lerrno != EWOULDBLOCK) && (lerrno != EAGAIN) && (lerrno != EINTR)) { /* serious error */ diff --git a/thirdparty/EVPath/EVPath/ev_internal.h b/thirdparty/EVPath/EVPath/ev_internal.h index f787a372b9..62ed43696e 100644 --- a/thirdparty/EVPath/EVPath/ev_internal.h +++ b/thirdparty/EVPath/EVPath/ev_internal.h @@ -234,7 +234,7 @@ typedef struct _EVclient_sources { typedef struct _ev_handler_activation_rec { struct _ev_handler_activation_rec *prev; - thr_thread_t thread_id; + thr_thread_id thread_id; EVstone stone_id; struct _ev_handler_activation_rec *next; } ev_handler_activation_rec, *ev_handler_activation_ptr; diff --git a/thirdparty/EVPath/EVPath/evp.c b/thirdparty/EVPath/EVPath/evp.c index d38ae3cc7c..77a10ff357 100644 --- a/thirdparty/EVPath/EVPath/evp.c +++ b/thirdparty/EVPath/EVPath/evp.c @@ -1632,7 +1632,7 @@ pop_activation_record_from_stack(CManager cm, ev_handler_activation_ptr rec) { event_path_data evp = cm->evp; ev_handler_activation_ptr tmp; - thr_thread_t self = thr_thread_self(); + thr_thread_id self = thr_thread_self(); if (!evp->activation_stack) { printf("Activation stack inconsistency! No records!\n"); return; @@ -1663,7 +1663,7 @@ find_activation_record_from_stack(CManager cm) { event_path_data evp = cm->evp; ev_handler_activation_ptr tmp; - thr_thread_t self = thr_thread_self(); + thr_thread_id self = thr_thread_self(); tmp = evp->activation_stack; while(tmp) { if (tmp->thread_id == self) { diff --git a/thirdparty/EVPath/EVPath/mtests/cmconn.c b/thirdparty/EVPath/EVPath/mtests/cmconn.c index 6b723b4fda..1513792c90 100644 --- a/thirdparty/EVPath/EVPath/mtests/cmconn.c +++ b/thirdparty/EVPath/EVPath/mtests/cmconn.c @@ -26,13 +26,14 @@ #include #endif #include "evpath.h" -#include #ifdef _MSC_VER #define drand48() (((double)rand())/((double)RAND_MAX)) #define lrand48() rand() #define srand48(x) #define kill(x,y) TerminateProcess(OpenProcess(0,0,(DWORD)x),y) +#else +#include #endif typedef struct _msg_rec { char *contact_list; diff --git a/thirdparty/EVPath/EVPath/mtests/support.c b/thirdparty/EVPath/EVPath/mtests/support.c index 01bb680382..5d9eb0b415 100644 --- a/thirdparty/EVPath/EVPath/mtests/support.c +++ b/thirdparty/EVPath/EVPath/mtests/support.c @@ -96,13 +96,40 @@ run_subprocess(char **args) { char **run_args = args; #ifdef HAVE_WINDOWS_H - intptr_t child; - child = _spawnv(_P_NOWAIT, "./evtest.exe", args); - if (child == -1) { - printf("failed for evtest\n"); - perror("spawnv"); + 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, " "); + while (args[i] != NULL) { + strcat(comm_line, args[i]); + strcat(comm_line, " "); + i++; + } - return child; + 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() ); + return 0; + } + return (intptr_t) pi.hProcess; #else pid_t child; if (quiet <=0) {printf("Forking subprocess\n");} diff --git a/thirdparty/EVPath/EVPath/tests/auto_test.c b/thirdparty/EVPath/EVPath/tests/auto_test.c index aeba229bf0..7d7046db26 100644 --- a/thirdparty/EVPath/EVPath/tests/auto_test.c +++ b/thirdparty/EVPath/EVPath/tests/auto_test.c @@ -345,11 +345,11 @@ do_regression_master_test() printf("Waiting for remote....\n"); } #ifdef HAVE_WINDOWS_H - if (_cwait(&exit_state, subproc_proc, 0) == -1) { - perror("cwait"); - } + WaitForSingleObject((HANDLE)subproc_proc, INFINITE ); + DWORD exitCode = 0; + GetExitCodeProcess((HANDLE)subproc_proc, &exitCode); + exit_state = exitCode; if (exit_state == 0) { - if (quiet <= 0) printf("Passed single remote subproc test\n"); } else { printf("Single remote subproc exit with status %d\n", diff --git a/thirdparty/EVPath/EVPath/tests/block_test.c b/thirdparty/EVPath/EVPath/tests/block_test.c index 4e64d7db0f..c5bb25e8a1 100644 --- a/thirdparty/EVPath/EVPath/tests/block_test.c +++ b/thirdparty/EVPath/EVPath/tests/block_test.c @@ -444,18 +444,6 @@ do_regression_master_test() printf("Waiting for remote....\n"); } while (!done) { -#ifdef HAVE_WINDOWS_H - if (_cwait(&exit_state, subproc_proc, 0) == -1) { - perror("cwait"); - } - if (exit_state == 0) { - if (quiet <= 0) - printf("Subproc exitted\n"); - } else { - printf("Single remote subproc exit with status %d\n", - exit_state); - } -#else int result, j; if (quiet <= 0) { printf(","); @@ -467,6 +455,18 @@ do_regression_master_test() } done++; /* CMsleep(cm, 50); done++;*/ +#ifdef HAVE_WINDOWS_H + WaitForSingleObject((HANDLE)subproc_proc, INFINITE ); + DWORD exitCode = 0; + GetExitCodeProcess((HANDLE)subproc_proc, &exitCode); + exit_state = exitCode; + if (exit_state == 0) { + printf("Passed single remote subproc test\n"); + } else { + printf("Single remote subproc exit with status %d\n", + exit_state); + } +#else result = waitpid(subproc_proc, &exit_state, WNOHANG); if (result == -1) { perror("waitpid"); diff --git a/thirdparty/EVPath/EVPath/tests/bulktest.c b/thirdparty/EVPath/EVPath/tests/bulktest.c index 9068ffd1f7..ada01bb033 100644 --- a/thirdparty/EVPath/EVPath/tests/bulktest.c +++ b/thirdparty/EVPath/EVPath/tests/bulktest.c @@ -263,7 +263,7 @@ main(int argc, char **argv) int regression_master = 1; int forked = 0; - argv0 = argv[0];\ + argv0 = argv[0]; while (argv[1] && (argv[1][0] == '-')) { if (strcmp(&argv[1][1], "size") == 0) { if (sscanf(argv[2], "%d", &size) != 1) { @@ -600,25 +600,28 @@ do_regression_master_test() printf("Waiting for remote....\n"); } while (!done) { -#ifdef HAVE_WINDOWS_H - if (_cwait(&exit_state, subproc_proc, 0) == -1) { - perror("cwait"); - } - if (exit_state == 0) { - if (quiet <= 0) - printf("Subproc exitted\n"); - } else { - printf("Single remote subproc exit with status %d\n", - exit_state); - } -#else - int result; if (quiet <= 0) { printf(","); fflush(stdout); } CMsleep(cm, 50); done++; +#ifdef HAVE_WINDOWS_H + DWORD result = WaitForSingleObject((HANDLE)subproc_proc, 1 ); + if (result != WAIT_TIMEOUT) { + DWORD exitCode = 0; + GetExitCodeProcess((HANDLE)subproc_proc, &exitCode); + exit_state = exitCode; + if (exit_state == 0) { + printf("Passed single remote subproc test\n"); + } else { + printf("Single remote subproc exit with status %d\n", + exit_state); + } + done++; + } +#else + int result; result = waitpid(subproc_proc, &exit_state, WNOHANG); if (result == -1) { perror("waitpid"); diff --git a/thirdparty/EVPath/EVPath/tests/evtest.c b/thirdparty/EVPath/EVPath/tests/evtest.c index 59481adf78..1a2cdf22fb 100644 --- a/thirdparty/EVPath/EVPath/tests/evtest.c +++ b/thirdparty/EVPath/EVPath/tests/evtest.c @@ -370,11 +370,11 @@ do_regression_master_test() printf("Waiting for remote....\n"); } #ifdef HAVE_WINDOWS_H - if (_cwait(&exit_state, subproc_proc, 0) == -1) { - perror("cwait"); - } + WaitForSingleObject((HANDLE)subproc_proc, INFINITE ); + DWORD exitCode = 0; + GetExitCodeProcess((HANDLE)subproc_proc, &exitCode); + exit_state = exitCode; if (exit_state == 0) { - if (quiet <= 0) printf("Passed single remote subproc test\n"); } else { printf("Single remote subproc exit with status %d\n", diff --git a/thirdparty/EVPath/EVPath/tests/support.c b/thirdparty/EVPath/EVPath/tests/support.c index 5a13be452c..f1ced333e1 100644 --- a/thirdparty/EVPath/EVPath/tests/support.c +++ b/thirdparty/EVPath/EVPath/tests/support.c @@ -103,13 +103,42 @@ run_subprocess(char **args) { char **run_args = args; #ifdef HAVE_WINDOWS_H - intptr_t child; - child = _spawnv(_P_NOWAIT, "./evtest.exe", args); - if (child == -1) { - printf("failed for evtest\n"); - perror("spawnv"); + 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, " "); + while (args[i] != NULL) { + strcat(comm_line, args[i]); + strcat(comm_line, " "); + i++; + } - return child; + 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]); + return 0; + } + return (intptr_t) pi.hProcess; #else pid_t child; if (quiet <=0) {printf("Forking subprocess\n");} @@ -149,6 +178,7 @@ run_subprocess(char **args) while(run_args[i]) { printf("%s ", run_args[i++]); } + printf("\n"); } if (no_fork) { child = -1;