blob: 59a14ff47c1f986294945e7116c580d8c5e8d2d9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
// ======================================================================== //
// Copyright 2009-2019 Intel Corporation //
// //
// Licensed under the Apache License, Version 2.0 (the "License"); //
// you may not use this file except in compliance with the License. //
// You may obtain a copy of the License at //
// //
// http://www.apache.org/licenses/LICENSE-2.0 //
// //
// Unless required by applicable law or agreed to in writing, software //
// distributed under the License is distributed on an "AS IS" BASIS, //
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
// See the License for the specific language governing permissions and //
// limitations under the License. //
// ======================================================================== //
#include "platform.h"
namespace oidn {
// ----------------------------------------------------------------------------
// Common functions
// ----------------------------------------------------------------------------
void* alignedMalloc(size_t size, size_t alignment)
{
if (size == 0)
return nullptr;
assert((alignment & (alignment-1)) == 0);
void* ptr = _mm_malloc(size, alignment);
if (ptr == nullptr)
throw std::bad_alloc();
return ptr;
}
void alignedFree(void* ptr)
{
if (ptr)
_mm_free(ptr);
}
// ----------------------------------------------------------------------------
// System information
// ----------------------------------------------------------------------------
std::string getPlatformName()
{
std::string name;
#if defined(__linux__)
name = "Linux";
#elif defined(__FreeBSD__)
name = "FreeBSD";
#elif defined(__CYGWIN__)
name = "Cygwin";
#elif defined(_WIN32)
name = "Windows";
#elif defined(__APPLE__)
name = "macOS";
#elif defined(__unix__)
name = "Unix";
#else
return "Unknown";
#endif
#if defined(__x86_64__) || defined(_M_X64) || defined(__ia64__) || defined(__aarch64__)
name += " (64-bit)";
#else
name += " (32-bit)";
#endif
return name;
}
std::string getCompilerName()
{
#if defined(__INTEL_COMPILER)
int mayor = __INTEL_COMPILER / 100 % 100;
int minor = __INTEL_COMPILER % 100;
std::string version = "Intel Compiler ";
version += toString(mayor);
version += "." + toString(minor);
#if defined(__INTEL_COMPILER_UPDATE)
version += "." + toString(__INTEL_COMPILER_UPDATE);
#endif
return version;
#elif defined(__clang__)
return "Clang " __clang_version__;
#elif defined(__GNUC__)
return "GCC " __VERSION__;
#elif defined(_MSC_VER)
std::string version = toString(_MSC_FULL_VER);
version.insert(4, ".");
version.insert(9, ".");
version.insert(2, ".");
return "Visual C++ Compiler " + version;
#else
return "Unknown";
#endif
}
std::string getBuildName()
{
#if defined(NDEBUG)
return "Release";
#else
return "Debug";
#endif
}
} // namespace oidn
|