LAPACK CPU time functions.

This commit is contained in:
Antonio Sánchez 2024-01-23 23:58:58 +00:00
parent a73970a864
commit 851b40afd8
3 changed files with 73 additions and 2 deletions

View File

@ -22,7 +22,7 @@ add_custom_target(lapack)
include_directories(../blas)
set(EigenLapack_SRCS
single.cpp double.cpp complex_single.cpp complex_double.cpp ../blas/xerbla.cpp
dsecnd_INT_CPU_TIME.cpp second_INT_CPU_TIME.cpp single.cpp double.cpp complex_single.cpp complex_double.cpp ../blas/xerbla.cpp
)
if(EIGEN_Fortran_COMPILER_WORKS)
@ -38,7 +38,6 @@ set(EigenLapack_SRCS ${EigenLapack_SRCS}
dlapy2.f dlapy3.f slapy2.f slapy3.f
clacgv.f zlacgv.f
slamch.f dlamch.f
second_NONE.f dsecnd_NONE.f
)
option(EIGEN_ENABLE_LAPACK_TESTS OFF "Enable the Lapack unit tests")

View File

@ -0,0 +1,36 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2024 The Eigen Authors
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifdef _WIN32
#include <cstdint>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#else
#include <ctime>
#endif
extern "C" {
double dsecnd_();
}
// Elapsed CPU Time in seconds.
double dsecnd_() {
#ifdef _WIN32
// GetProcessTimes() uses 100-nanosecond time units.
FILETIME creation_time, exit_time, kernel_time, user_time;
GetProcessTimes(GetCurrentProcess(), &creation_time, &exit_time, &kernel_time, &user_time);
ULARGE_INTEGER user;
user.HighPart = user_time.dwHighDateTime;
user.LowPart = user_time.dwLowDateTime;
uint64_t time_100ns = user.QuadPart;
return static_cast<double>(time_100ns) / 10000000.0;
#else
return static_cast<double>(std::clock()) / static_cast<double>(CLOCKS_PER_SEC);
#endif
}

View File

@ -0,0 +1,36 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2024 The Eigen Authors
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifdef _WIN32
#include <cstdint>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#else
#include <ctime>
#endif
extern "C" {
float second_();
}
// Elapsed CPU Time in seconds.
float second_() {
#ifdef _WIN32
// GetProcessTimes() uses 100-nanosecond time units.
FILETIME creation_time, exit_time, kernel_time, user_time;
GetProcessTimes(GetCurrentProcess(), &creation_time, &exit_time, &kernel_time, &user_time);
ULARGE_INTEGER user;
user.HighPart = user_time.dwHighDateTime;
user.LowPart = user_time.dwLowDateTime;
uint64_t time_100ns = user.QuadPart;
return static_cast<float>(time_100ns) / 10000000.0f;
#else
return static_cast<float>(std::clock()) / static_cast<float>(CLOCKS_PER_SEC);
#endif
}