Skip to content
This repository has been archived by the owner on Feb 2, 2024. It is now read-only.

Commit

Permalink
Merge 841812f into 9c7c326
Browse files Browse the repository at this point in the history
  • Loading branch information
shssf committed Aug 15, 2019
2 parents 9c7c326 + 841812f commit 4b6d3d7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
4 changes: 3 additions & 1 deletion hpat/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@
# default value for transport
# used if no function decorator controls the transport
config_transport_mpi_default = distutils_util.strtobool(os.getenv('HPAT_CONFIG_MPI', 'True'))

# current value for transport controlled by decorator
config_transport_mpi = True
# need to initialize this here because decorator called later then modules have been initialized
config_transport_mpi = config_transport_mpi_default
34 changes: 32 additions & 2 deletions hpat/transport/hpat_transport_single_process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,31 @@
#include <stdexcept>
#include <vector>

#ifdef _WIN32 // MSC_VER
#include <Windows.h>

// no gettimeofday on Win32/Win64
int gettimeofday(struct timeval* tp, struct timezone* tzp)
{
static const uint64_t EPOCH = ((uint64_t)116444736000000000ULL);

SYSTEMTIME nSystemTime;
FILETIME nFileTime;
uint64_t nTime;

GetSystemTime(&nSystemTime);
SystemTimeToFileTime(&nSystemTime, &nFileTime);
nTime = ((uint64_t)nFileTime.dwLowDateTime);
nTime += ((uint64_t)nFileTime.dwHighDateTime) << 32;

tp->tv_sec = (long)((nTime - EPOCH) / 10000000L);
tp->tv_usec = (long)(nSystemTime.wMilliseconds * 1000);
return 0;
}
#else
#include <sys/time.h>
#endif // _WIN32

#include "../_hpat_common.h"

using namespace std;
Expand Down Expand Up @@ -215,7 +240,12 @@ static int hpat_dist_get_size()

static double hpat_dist_get_time()
{
throw runtime_error(__FUNCTION__ + string(": Is not implemented"));
timeval result;
gettimeofday(&result, nullptr);
double sec = result.tv_sec;
double usec = result.tv_usec;

return sec + (usec / 1E6);
}

static MPI_Request hpat_dist_irecv(void* out, int size, int type_enum, int pe, int tag, bool cond)
Expand Down Expand Up @@ -261,7 +291,7 @@ static int hpat_finalize()

static double hpat_get_time()
{
throw runtime_error(__FUNCTION__ + string(": Is not implemented"));
return hpat_dist_get_time();
}

/// return vector of offsets of newlines in first n bytes of given stream
Expand Down

0 comments on commit 4b6d3d7

Please sign in to comment.