Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Windows #947

Merged
merged 19 commits into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: windows

on: [push, pull_request]

jobs:
# Build libamrex and all tutorials
tutorials:
name: MSVC C++17 w/o Fortran w/o MPI
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Build & Install
run: |
mkdir build
cd build
cmake .. -DENABLE_TUTORIALS=ON -DENABLE_FORTRAN=OFF -DENABLE_MPI=OFF -DCMAKE_CXX_STANDARD=17
cmake --build . --config Release --target tutorials
4 changes: 0 additions & 4 deletions Src/Amr/AMReX_Amr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
#include <omp.h>
#endif

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

#include <AMReX_Geometry.H>
#include <AMReX_TagBox.H>
#include <AMReX_Array.H>
Expand Down
1 change: 0 additions & 1 deletion Src/Amr/AMReX_AmrLevel.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

#include <sstream>

#include <unistd.h>
#include <memory>
#include <limits>

Expand Down
1 change: 0 additions & 1 deletion Src/Amr/AMReX_AsyncFillPatch.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <sstream>
#include <unistd.h>
#include <memory>
#include <limits>

Expand Down
2 changes: 0 additions & 2 deletions Src/Amr/AMReX_StateData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#include <iostream>
#include <algorithm>

#include <unistd.h>

#include <AMReX_RealBox.H>
#include <AMReX_StateData.H>
#include <AMReX_StateDescriptor.H>
Expand Down
43 changes: 20 additions & 23 deletions Src/Base/AMReX.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
#include <unistd.h>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <new>
#include <stack>
#include <limits>
#include <vector>
#include <algorithm>

#include <AMReX_FileSystem.H>
#include <AMReX_ParallelDescriptor.H>
#include <AMReX.H>
#include <AMReX_BaseFab.H>
Expand All @@ -20,7 +9,9 @@
#include <AMReX_Random.H>
#include <AMReX_Print.H>
#include <AMReX_Arena.H>

#include <AMReX_BLBackTrace.H>
#include <AMReX_MemPool.H>
#include <AMReX_Geometry.H>
#include <AMReX_Gpu.H>

#ifdef AMREX_USE_CUPTI
Expand Down Expand Up @@ -53,10 +44,22 @@
#include <omp.h>
#endif

#include <AMReX_BLBackTrace.H>
#include <AMReX_MemPool.H>
#if defined(__APPLE__)
#include <xmmintrin.h>
#endif

#include <AMReX_Geometry.H>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <csignal>
#include <cfenv>
#include <iostream>
#include <iomanip>
#include <new>
#include <stack>
#include <limits>
#include <vector>
#include <algorithm>

namespace amrex {

Expand Down Expand Up @@ -315,13 +318,7 @@ amrex::Initialize (int& argc, char**& argv, bool build_parm_parse,
if (argc > 0)
{
if (argv[0][0] != '/') {
constexpr int bufSize = 1024;
char temp[bufSize];
char *rCheck = getcwd(temp, bufSize);
if(rCheck == 0) {
amrex::Abort("**** Error: getcwd buffer too small.");
}
system::exename = temp;
system::exename = FileSystem::CurrentPath();
system::exename += "/";
}
system::exename += argv[0];
Expand Down
18 changes: 14 additions & 4 deletions Src/Base/AMReX_Arena.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,17 @@
#include <AMReX_ParmParse.H>
#include <AMReX_Gpu.H>

#ifdef _WIN32
///#include <memoryapi.h>
//#define AMREX_MLOCK(x,y) VirtualLock(x,y)
//#define AMREX_MUNLOCK(x,y) VirtualUnlock(x,y)
#define AMREX_MLOCK(x,y) ((void)0)
#define AMREX_MUNLOCK(x,y) ((void)0)
#else
#include <sys/mman.h>
#define AMREX_MLOCK(x,y) mlock(x,y)
#define AMREX_MUNLOCK(x,y) munlock(x,y)
#endif

namespace amrex {

Expand Down Expand Up @@ -54,7 +64,7 @@ Arena::allocate_system (std::size_t nbytes)
if (arena_info.use_cpu_memory)
{
p = std::malloc(nbytes);
if (p && arena_info.device_use_hostalloc) mlock(p, nbytes);
if (p && arena_info.device_use_hostalloc) AMREX_MLOCK(p, nbytes);
}
else if (arena_info.device_use_hostalloc)
{
Expand Down Expand Up @@ -99,7 +109,7 @@ Arena::allocate_system (std::size_t nbytes)
}
#else
p = std::malloc(nbytes);
if (p && arena_info.device_use_hostalloc) mlock(p, nbytes);
if (p && arena_info.device_use_hostalloc) AMREX_MLOCK(p, nbytes);
#endif
if (p == nullptr) amrex::Abort("Sorry, malloc failed");
return p;
Expand All @@ -111,7 +121,7 @@ Arena::deallocate_system (void* p, std::size_t nbytes)
#ifdef AMREX_USE_GPU
if (arena_info.use_cpu_memory)
{
if (p && arena_info.device_use_hostalloc) munlock(p, nbytes);
if (p && arena_info.device_use_hostalloc) AMREX_MUNLOCK(p, nbytes);
std::free(p);
}
else if (arena_info.device_use_hostalloc)
Expand All @@ -129,7 +139,7 @@ Arena::deallocate_system (void* p, std::size_t nbytes)
sycl::free(p,Gpu::Device::syclContext()););
}
#else
if (p && arena_info.device_use_hostalloc) munlock(p, nbytes);
if (p && arena_info.device_use_hostalloc) AMREX_MUNLOCK(p, nbytes);
std::free(p);
#endif
}
Expand Down
22 changes: 11 additions & 11 deletions Src/Base/AMReX_Array4.H
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace amrex {
AMREX_GPU_HOST_DEVICE
constexpr Array4 () noexcept : p(nullptr) {}

template <class U=T, class = typename std::enable_if<std::is_const<U>::value>::type >
template <class U=T, typename std::enable_if<std::is_const<U>::value,int>::type = 0>
AMREX_GPU_HOST_DEVICE
constexpr Array4 (Array4<typename std::remove_const<T>::type> const& rhs) noexcept
: p(rhs.p),
Expand All @@ -44,9 +44,9 @@ namespace amrex {
{}

template <class U,
class = typename std::enable_if
typename std::enable_if
<std::is_same<typename std::remove_const<T>::type,
typename std::remove_const<U>::type>::value>::type >
typename std::remove_const<U>::type>::value,int>::type = 0>
AMREX_GPU_HOST_DEVICE
constexpr Array4 (Array4<U> const& rhs, int start_comp) noexcept
: p((T*)(rhs.p+start_comp*rhs.nstride)),
Expand All @@ -61,7 +61,7 @@ namespace amrex {
AMREX_GPU_HOST_DEVICE
explicit operator bool() const noexcept { return p != nullptr; }

template <class U=T, class = typename std::enable_if<!std::is_void<U>::value>::type >
template <class U=T, typename std::enable_if<!std::is_void<U>::value,int>::type = 0>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
U& operator() (int i, int j, int k) const noexcept {
#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
Expand All @@ -70,7 +70,7 @@ namespace amrex {
return p[(i-begin.x)+(j-begin.y)*jstride+(k-begin.z)*kstride];
}

template <class U=T, class = typename std::enable_if<!std::is_void<U>::value>::type >
template <class U=T, typename std::enable_if<!std::is_void<U>::value,int>::type = 0>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
U& operator() (int i, int j, int k, int n) const noexcept {
#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
Expand All @@ -79,7 +79,7 @@ namespace amrex {
return p[(i-begin.x)+(j-begin.y)*jstride+(k-begin.z)*kstride+n*nstride];
}

template <class U=T, class = typename std::enable_if<!std::is_void<U>::value>::type >
template <class U=T, typename std::enable_if<!std::is_void<U>::value,int>::type = 0>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
T* ptr (int i, int j, int k) const noexcept {
#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
Expand All @@ -88,7 +88,7 @@ namespace amrex {
return p + ((i-begin.x)+(j-begin.y)*jstride+(k-begin.z)*kstride);
}

template <class U=T, class = typename std::enable_if<!std::is_void<U>::value>::type >
template <class U=T, typename std::enable_if<!std::is_void<U>::value,int>::type = 0>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
T* ptr (int i, int j, int k, int n) const noexcept {
#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
Expand All @@ -97,7 +97,7 @@ namespace amrex {
return p + ((i-begin.x)+(j-begin.y)*jstride+(k-begin.z)*kstride+n*nstride);
}

template <class U=T, class = typename std::enable_if<!std::is_void<U>::value>::type >
template <class U=T, typename std::enable_if<!std::is_void<U>::value,int>::type = 0>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
U& operator() (IntVect const& iv) const noexcept {
#if (AMREX_SPACEDIM == 1)
Expand All @@ -109,7 +109,7 @@ namespace amrex {
#endif
}

template <class U=T, class = typename std::enable_if<!std::is_void<U>::value>::type >
template <class U=T, typename std::enable_if<!std::is_void<U>::value,int>::type = 0>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
U& operator() (IntVect const& iv, int n) const noexcept {
#if (AMREX_SPACEDIM == 1)
Expand All @@ -121,7 +121,7 @@ namespace amrex {
#endif
}

template <class U=T, class = typename std::enable_if<!std::is_void<U>::value>::type >
template <class U=T, typename std::enable_if<!std::is_void<U>::value,int>::type = 0>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
T* ptr (IntVect const& iv) const noexcept {
#if (AMREX_SPACEDIM == 1)
Expand All @@ -133,7 +133,7 @@ namespace amrex {
#endif
}

template <class U=T, class = typename std::enable_if<!std::is_void<U>::value>::type >
template <class U=T, typename std::enable_if<!std::is_void<U>::value,int>::type = 0>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
T* ptr (IntVect const& iv, int n) const noexcept {
#if (AMREX_SPACEDIM == 1)
Expand Down
9 changes: 0 additions & 9 deletions Src/Base/AMReX_BLBackTrace.H
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,9 @@
#include <string>
#include <utility>
#include <sstream>

#include <cstdio>
#include <cstdlib>

#include <execinfo.h>
#if defined(__APPLE__)
#include <xmmintrin.h>
#endif

#include <csignal>
#include <cfenv>

#ifdef _OPENMP
#include <omp.h>
#endif
Expand Down
24 changes: 15 additions & 9 deletions Src/Base/AMReX_BLBackTrace.cpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
#include <iostream>
#include <sstream>
#include <fstream>
#include <cstring>
#include <cstdio>

#include <unistd.h>

#include <AMReX_BLBackTrace.H>
#include <AMReX_ParallelDescriptor.H>
#include <AMReX_Print.H>
#include <AMReX_VisMF.H>
#include <AMReX_AsyncOut.H>
#include <AMReX.H>
#include <AMReX_Utility.H>

#ifdef AMREX_TINY_PROFILING
#include <AMReX_TinyProfiler.H>
#endif

#include <iostream>
#include <sstream>
#include <fstream>
#include <cstring>
#include <cstdio>
#include <csignal>
#include <cfenv>

#if defined(AMREX_EXPORT_DYNAMIC) && defined(__APPLE__)
#include <cxxabi.h>
#include <dlfcn.h>
Expand All @@ -25,6 +26,11 @@
#define AMREX_BACKTRACE_SUPPORTED 1
#endif

#ifndef _WIN32
#include <execinfo.h>
#include <unistd.h>
#endif

namespace amrex {

#ifdef AMREX_BACKTRACING
Expand Down Expand Up @@ -107,7 +113,7 @@ BLBackTrace::handler(int s)
#endif

if (ParallelDescriptor::NProcs() > 1) {
sleep(3);
amrex::Sleep(3);
}

#endif
Expand Down
4 changes: 2 additions & 2 deletions Src/Base/AMReX_BaseFab.H
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public:
*/
void resize (const Box& b, int N = 1);

template <class U=T, class = typename std::enable_if<std::is_trivially_destructible<U>::value>::type >
template <class U=T, typename std::enable_if<std::is_trivially_destructible<U>::value,int>::type = 0>
Elixir elixir () noexcept;

/**
Expand Down Expand Up @@ -2036,7 +2036,7 @@ BaseFab<T>::resize (const Box& b, int n)
}

template <class T>
template <class,class>
template <class U, typename std::enable_if<std::is_trivially_destructible<U>::value,int>::type>
Elixir
BaseFab<T>::elixir () noexcept
{
Expand Down
4 changes: 3 additions & 1 deletion Src/Base/AMReX_Extension.H
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,10 @@

// __attribute__((weak))

#ifdef AMREX_TYPECHECK
#if defined(AMREX_TYPECHECK)
#define AMREX_ATTRIBUTE_WEAK
#elif defined(_WIN32)
#define AMREX_ATTRIBUTE_WEAK
#else
#define AMREX_ATTRIBUTE_WEAK __attribute__((weak))
#endif
Expand Down
3 changes: 2 additions & 1 deletion Src/Base/AMReX_FPC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
defined(__amd64__) || \
defined(__LITTLE_ENDIAN__) || \
defined(__powerpc__) || \
defined(powerpc)
defined(powerpc) || \
defined(_WIN32)
#define AMREX_LITTLE_ENDIAN
#endif

Expand Down
Loading