mirror of
https://github.com/NGSolve/netgen.git
synced 2025-05-06 02:30:49 +05:00
Merge bc489e2f0db946ab30b442c8d593f9cb4e8f4053 into 0a1fd5a2e295b68815ac3daffd73886f52dd7d2a
This commit is contained in:
commit
696819d207
@ -2,6 +2,7 @@
|
||||
#define NETGEN_CORE_PYTHON_NGCORE_HPP
|
||||
|
||||
#include "ngcore_api.hpp" // for operator new
|
||||
#include <cstdint>
|
||||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/operators.h>
|
||||
#include <pybind11/numpy.h>
|
||||
@ -182,10 +183,12 @@ namespace ngcore
|
||||
static std::string GetName() { return "D"; }
|
||||
};
|
||||
|
||||
#if INTPTR_MAX != INT32_MAX
|
||||
template<>
|
||||
struct PyNameTraits<size_t> {
|
||||
static std::string GetName() { return "S"; }
|
||||
};
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
struct PyNameTraits<std::shared_ptr<T>> {
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <cstdint>
|
||||
|
||||
#include "python_ngcore.hpp"
|
||||
#include "bitarray.hpp"
|
||||
#include "taskmanager.hpp"
|
||||
@ -23,7 +25,9 @@ PYBIND11_MODULE(pyngcore, m) // NOLINT
|
||||
catch(...) {}
|
||||
ExportArray<int>(m);
|
||||
ExportArray<unsigned>(m);
|
||||
#if INTPTR_MAX != INT32_MAX
|
||||
ExportArray<size_t>(m);
|
||||
#endif
|
||||
ExportArray<double>(m);
|
||||
ExportArray<float>(m);
|
||||
ExportArray<signed short>(m);
|
||||
|
@ -8,6 +8,7 @@
|
||||
/**************************************************************************/
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include <optional>
|
||||
|
||||
@ -104,8 +105,10 @@ namespace ngcore
|
||||
{ return TablePrefixSum32 (FlatArray<unsigned> (entrysize.Size(), (unsigned int*)(int*)(entrysize.Addr(0)))); }
|
||||
NETGEN_INLINE size_t * TablePrefixSum (FlatArray<std::atomic<int>> entrysize)
|
||||
{ return TablePrefixSum32 (FlatArray<unsigned> (entrysize.Size(), (unsigned int*)(std::atomic<int>*)entrysize.Addr(0))); }
|
||||
#if INTPTR_MAX != INT32_MAX
|
||||
NETGEN_INLINE size_t * TablePrefixSum (FlatArray<size_t> entrysize)
|
||||
{ return TablePrefixSum64 (entrysize); }
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
|
@ -19,7 +19,9 @@
|
||||
#ifdef NETGEN_ARCH_AMD64
|
||||
#ifdef WIN32
|
||||
#include <intrin.h> // for __rdtsc() CPU time step counter
|
||||
#else
|
||||
#define NGCORE_HAVE_RDTSC
|
||||
#elif defined __SSE__
|
||||
#define NGCORE_HAVE_RDTSC
|
||||
#include <x86intrin.h> // for __rdtsc() CPU time step counter
|
||||
#endif // WIN32
|
||||
#endif // NETGEN_ARCH_AMD64
|
||||
@ -65,7 +67,7 @@ namespace ngcore
|
||||
{
|
||||
#if defined(__APPLE__) && defined(NETGEN_ARCH_ARM64)
|
||||
return mach_absolute_time();
|
||||
#elif defined(NETGEN_ARCH_AMD64)
|
||||
#elif defined(NETGEN_ARCH_AMD64) || defined(NGCORE_HAVE_RDTSC)
|
||||
return __rdtsc();
|
||||
#elif defined(NETGEN_ARCH_ARM64) && defined(__GNUC__)
|
||||
// __GNUC__ is also defined by CLANG. Use inline asm to read Generic Timer
|
||||
@ -74,6 +76,8 @@ namespace ngcore
|
||||
return tics;
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
return std::chrono::high_resolution_clock::now().time_since_epoch().count();
|
||||
#elifndef NGCORE_HAVE_RDTSC
|
||||
return TTimePoint(std::chrono::steady_clock::now().time_since_epoch().count());
|
||||
#else
|
||||
#warning "Unsupported CPU architecture"
|
||||
return 0;
|
||||
|
@ -1 +1,7 @@
|
||||
from .pyngcore import *
|
||||
|
||||
# <size_t> is the same as <unsigned int> on 32 bit arches
|
||||
# in which case Array_I_S is not defined by python_ngcore_export.cpp.
|
||||
# In this case identify it with Array_I_U.
|
||||
try: Array_I_S
|
||||
except NameError: Array_I_S=Array_I_U
|
||||
|
Loading…
x
Reference in New Issue
Block a user