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

enable occa on Windows #646

Open
wants to merge 15 commits into
base: development
Choose a base branch
from
Open
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
12 changes: 9 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
name: Build

on:
on:
push:
branches: [ main, development ]
paths-ignore:
- 'README.md'
- 'INSTALL.md'
- 'docs/**'
pull_request:
branches: [ main, development ]
paths-ignore:
- 'README.md'
- 'INSTALL.md'
- 'docs/**'

jobs:
run:
Expand Down
55 changes: 55 additions & 0 deletions include/occa/defines/msvc.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#ifndef OCCA_DEFINES_MSVC_HEADER
#define OCCA_DEFINES_MSVC_HEADER

// NBN: adapted from compiledDefines.hpp
// FIXME: #defines appropriate for local win64 build
// FIXME: user must edit for current system
// TODO: enable local generation with cmake?

#ifndef OCCA_LINUX_OS
# define OCCA_LINUX_OS 1
#endif

#ifndef OCCA_MACOS_OS
# define OCCA_MACOS_OS 2
#endif

#ifndef OCCA_WINDOWS_OS
# define OCCA_WINDOWS_OS 4
#endif

#ifndef OCCA_WINUX_OS
# define OCCA_WINUX_OS (OCCA_LINUX_OS | OCCA_WINDOWS_OS)
#endif

#define OCCA_OS OCCA_WINDOWS_OS
#define OCCA_USING_VS 1
#define OCCA_VS_VERSION _MSC_VER
#define OCCA_UNSAFE 0

#define OCCA_MPI_ENABLED 1
#define OCCA_OPENMP_ENABLED 1
#define OCCA_CUDA_ENABLED 1
#define OCCA_DPCPP_ENABLED 0
#define OCCA_HIP_ENABLED 0
#define OCCA_OPENCL_ENABLED 0
#define OCCA_METAL_ENABLED 0

// TODO: select appropriate intrinsics
#define __AVX__
#define __SSE4_2__
#define __SSE4_1__
#define __SSE3__
#define __SSE2__

// TODO: define appropriate paths
#define OCCA_BUILD_DIR "D:/TW/occa"
#define OCCA_SOURCE_DIR "D:/TW/occa"

#ifdef NDEBUG
# define OCCA_DEBUG_ENABLED 0
#else
# define OCCA_DEBUG_ENABLED 1
#endif

#endif // OCCA_DEFINES_MSVC_HEADER
8 changes: 3 additions & 5 deletions include/occa/defines/windows.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#ifndef OCCA_DEFINES_WINDOWS_HEADER
#define OCCA_DEFINES_WINDOWS_HEADER
# if OCCA_OS == OCCA_WINDOWS_OS

// (OCCA_VS_VERSION == 1900) : MSVC++ 14.x - Visual Studio 2015
// (OCCA_VS_VERSION >= 1910) : MSVC++ 15.x - Visual Studio 2017
#define OCCA_VS_VERSION _MSC_VER
#ifdef _MSC_VER
#include <occa/defines/msvc.hpp>
#endif

# endif
#endif
4 changes: 4 additions & 0 deletions include/occa/types/primitive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,15 @@ namespace occa {
case primitiveType::int16_ : return (T) value.int16_;
case primitiveType::int32_ : return (T) value.int32_;
case primitiveType::int64_ : return (T) value.int64_;
#ifndef _MSC_VER // NBN: GCC only
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
#endif
case primitiveType::float_ : return (T) value.float_;
case primitiveType::double_ : return (T) value.double_;
#ifndef _MSC_VER
#pragma GCC diagnostic pop
#endif
default: OCCA_FORCE_ERROR("Type not set");
}
return T();
Expand Down
169 changes: 169 additions & 0 deletions include/occa/types/typeinfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ namespace occa {
typedef unsigned int uint_t;
typedef unsigned long ulong_t;

#ifndef _MSC_VER
// NBN: these are defined in /occa/src/types/typeinfo.cpp
template <> const std::string primitiveinfo<char>::id;
template <> const std::string primitiveinfo<char>::name;
template <> const bool primitiveinfo<char>::isUnsigned;
Expand Down Expand Up @@ -202,6 +204,173 @@ namespace occa {
template <> const std::string typeinfo<double4>::id;
template <> const std::string typeinfo<double4>::name;
template <> const bool typeinfo<double4>::isUnsigned;
#else
// NBN: MSVC error C2737: "const object must be initialized"
template <> const std::string primitiveinfo<char>::id = "c";
template <> const std::string primitiveinfo<char>::name = "char";
template <> const bool primitiveinfo<char>::isUnsigned = false;

template <> const std::string primitiveinfo<short>::id = "s";
template <> const std::string primitiveinfo<short>::name = "short";
template <> const bool primitiveinfo<short>::isUnsigned = false;

template <> const std::string primitiveinfo<int>::id = "i";
template <> const std::string primitiveinfo<int>::name = "int";
template <> const bool primitiveinfo<int>::isUnsigned = false;

template <> const std::string primitiveinfo<long>::id = "l";
template <> const std::string primitiveinfo<long>::name = "long";
template <> const bool primitiveinfo<long>::isUnsigned = false;

template <> const std::string primitiveinfo<schar_t>::id = "sc";
template <> const std::string primitiveinfo<schar_t>::name = "schar_t";
template <> const bool primitiveinfo<schar_t>::isUnsigned = false;

template <> const std::string primitiveinfo<uchar_t>::id = "uc";
template <> const std::string primitiveinfo<uchar_t>::name = "uchar_t";
template <> const bool primitiveinfo<uchar_t>::isUnsigned = true;

template <> const std::string primitiveinfo<ushort_t>::id = "us";
template <> const std::string primitiveinfo<ushort_t>::name = "ushort_t";
template <> const bool primitiveinfo<ushort_t>::isUnsigned = true;

template <> const std::string primitiveinfo<uint_t>::id = "ui";
template <> const std::string primitiveinfo<uint_t>::name = "uint_t";
template <> const bool primitiveinfo<uint_t>::isUnsigned = true;

template <> const std::string primitiveinfo<ulong_t>::id = "ul";
template <> const std::string primitiveinfo<ulong_t>::name = "ulong_t";
template <> const bool primitiveinfo<ulong_t>::isUnsigned = true;

template <> const std::string primitiveinfo<float>::id = "f";
template <> const std::string primitiveinfo<float>::name = "float";
template <> const bool primitiveinfo<float>::isUnsigned = false;

template <> const std::string primitiveinfo<double>::id = "d";
template <> const std::string primitiveinfo<double>::name = "double";
template <> const bool primitiveinfo<double>::isUnsigned = false;

template <> const std::string typeinfo<uint8_t>::id = "u8";
template <> const std::string typeinfo<uint8_t>::name = "uint8";
template <> const bool typeinfo<uint8_t>::isUnsigned = true;

template <> const std::string typeinfo<uint16_t>::id = "u16";
template <> const std::string typeinfo<uint16_t>::name = "uint16";
template <> const bool typeinfo<uint16_t>::isUnsigned = true;

template <> const std::string typeinfo<uint32_t>::id = "u32";
template <> const std::string typeinfo<uint32_t>::name = "uint32";
template <> const bool typeinfo<uint32_t>::isUnsigned = true;

template <> const std::string typeinfo<uint64_t>::id = "u64";
template <> const std::string typeinfo<uint64_t>::name = "uint64";
template <> const bool typeinfo<uint64_t>::isUnsigned = true;

template <> const std::string typeinfo<int8_t>::id = "i8";
template <> const std::string typeinfo<int8_t>::name = "int8";
template <> const bool typeinfo<int8_t>::isUnsigned = false;

template <> const std::string typeinfo<int16_t>::id = "i16";
template <> const std::string typeinfo<int16_t>::name = "int16";
template <> const bool typeinfo<int16_t>::isUnsigned = false;

template <> const std::string typeinfo<int32_t>::id = "i32";
template <> const std::string typeinfo<int32_t>::name = "int32";
template <> const bool typeinfo<int32_t>::isUnsigned = false;

template <> const std::string typeinfo<int64_t>::id = "i64";
template <> const std::string typeinfo<int64_t>::name = "int64";
template <> const bool typeinfo<int64_t>::isUnsigned = false;

template <> const std::string typeinfo<float>::id = "f32";
template <> const std::string typeinfo<float>::name = "float";
template <> const bool typeinfo<float>::isUnsigned = false;

template <> const std::string typeinfo<double>::id = "f64";
template <> const std::string typeinfo<double>::name = "double";
template <> const bool typeinfo<double>::isUnsigned = false;

template <> const std::string typeinfo<uchar2>::id = "vuc2";
template <> const std::string typeinfo<uchar2>::name = "uchar2";
template <> const bool typeinfo<uchar2>::isUnsigned = true;

template <> const std::string typeinfo<uchar4>::id = "vuc4";
template <> const std::string typeinfo<uchar4>::name = "uchar4";
template <> const bool typeinfo<uchar4>::isUnsigned = true;

template <> const std::string typeinfo<char2>::id = "vc2";
template <> const std::string typeinfo<char2>::name = "char2";
template <> const bool typeinfo<char2>::isUnsigned = false;

template <> const std::string typeinfo<char4>::id = "vc4";
template <> const std::string typeinfo<char4>::name = "char4";
template <> const bool typeinfo<char4>::isUnsigned = false;

template <> const std::string typeinfo<ushort2>::id = "vus2";
template <> const std::string typeinfo<ushort2>::name = "ushort2";
template <> const bool typeinfo<ushort2>::isUnsigned = true;

template <> const std::string typeinfo<ushort4>::id = "vus4";
template <> const std::string typeinfo<ushort4>::name = "ushort4";
template <> const bool typeinfo<ushort4>::isUnsigned = true;

template <> const std::string typeinfo<short2>::id = "vs2";
template <> const std::string typeinfo<short2>::name = "short2";
template <> const bool typeinfo<short2>::isUnsigned = false;

template <> const std::string typeinfo<short4>::id = "vs4";
template <> const std::string typeinfo<short4>::name = "short4";
template <> const bool typeinfo<short4>::isUnsigned = false;

template <> const std::string typeinfo<uint2>::id = "vui2";
template <> const std::string typeinfo<uint2>::name = "uint2";
template <> const bool typeinfo<uint2>::isUnsigned = true;

template <> const std::string typeinfo<uint4>::id = "vui4";
template <> const std::string typeinfo<uint4>::name = "uint4";
template <> const bool typeinfo<uint4>::isUnsigned = true;

template <> const std::string typeinfo<int2>::id = "vi2";
template <> const std::string typeinfo<int2>::name = "int2";
template <> const bool typeinfo<int2>::isUnsigned = false;

template <> const std::string typeinfo<int4>::id = "vi4";
template <> const std::string typeinfo<int4>::name = "int4";
template <> const bool typeinfo<int4>::isUnsigned = false;

template <> const std::string typeinfo<ulong2>::id = "vul2";
template <> const std::string typeinfo<ulong2>::name = "ulong2";
template <> const bool typeinfo<ulong2>::isUnsigned = true;

template <> const std::string typeinfo<ulong4>::id = "vul4";
template <> const std::string typeinfo<ulong4>::name = "ulong4";
template <> const bool typeinfo<ulong4>::isUnsigned = true;

template <> const std::string typeinfo<long2>::id = "vl2";
template <> const std::string typeinfo<long2>::name = "long2";
template <> const bool typeinfo<long2>::isUnsigned = false;

template <> const std::string typeinfo<long4>::id = "vl4";
template <> const std::string typeinfo<long4>::name = "long4";
template <> const bool typeinfo<long4>::isUnsigned = false;

template <> const std::string typeinfo<float2>::id = "vf2";
template <> const std::string typeinfo<float2>::name = "float2";
template <> const bool typeinfo<float2>::isUnsigned = false;

template <> const std::string typeinfo<float4>::id = "vf4";
template <> const std::string typeinfo<float4>::name = "float4";
template <> const bool typeinfo<float4>::isUnsigned = false;

template <> const std::string typeinfo<double2>::id = "vd2";
template <> const std::string typeinfo<double2>::name = "double2";
template <> const bool typeinfo<double2>::isUnsigned = false;

template <> const std::string typeinfo<double4>::id = "vd4";
template <> const std::string typeinfo<double4>::name = "double4";
template <> const bool typeinfo<double4>::isUnsigned = false;
#endif // NBN: MSVC

}

#endif
25 changes: 25 additions & 0 deletions scripts/buildvc/libocca.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31702.278
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libocca", "libocca.vcxproj", "{9C04ABAC-B788-4C2D-ABFC-092DAE783731}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9C04ABAC-B788-4C2D-ABFC-092DAE783731}.Debug|x64.ActiveCfg = Debug|x64
{9C04ABAC-B788-4C2D-ABFC-092DAE783731}.Debug|x64.Build.0 = Debug|x64
{9C04ABAC-B788-4C2D-ABFC-092DAE783731}.Release|x64.ActiveCfg = Release|x64
{9C04ABAC-B788-4C2D-ABFC-092DAE783731}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D92D54DA-69C9-4E7F-96F0-BEA13CE74CAD}
EndGlobalSection
EndGlobal
Loading