mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-09 06:23:01 +08:00
Reorganization directory structure [3/n]
Change-Id: If3dfa3f6007f8810a6a1ae1a4f0c7da38544648d
This commit is contained in:
40
shared/source/utilities/windows/cpu_info.cpp
Normal file
40
shared/source/utilities/windows/cpu_info.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "utilities/cpu_info.h"
|
||||
|
||||
#include <intrin.h>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
void cpuid_windows_wrapper(int cpuInfo[4], int functionId) {
|
||||
__cpuid(cpuInfo, functionId);
|
||||
}
|
||||
|
||||
void cpuidex_windows_wrapper(int *cpuInfo, int functionId, int subfunctionId) {
|
||||
__cpuidex(cpuInfo, functionId, subfunctionId);
|
||||
}
|
||||
|
||||
void (*CpuInfo::cpuidexFunc)(int *, int, int) = cpuidex_windows_wrapper;
|
||||
void (*CpuInfo::cpuidFunc)(int[4], int) = cpuid_windows_wrapper;
|
||||
|
||||
const CpuInfo CpuInfo::instance;
|
||||
|
||||
void CpuInfo::cpuid(
|
||||
uint32_t cpuInfo[4],
|
||||
uint32_t functionId) const {
|
||||
cpuidFunc(reinterpret_cast<int *>(cpuInfo), functionId);
|
||||
}
|
||||
|
||||
void CpuInfo::cpuidex(
|
||||
uint32_t cpuInfo[4],
|
||||
uint32_t functionId,
|
||||
uint32_t subfunctionId) const {
|
||||
cpuidexFunc(reinterpret_cast<int *>(cpuInfo), functionId, subfunctionId);
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
40
shared/source/utilities/windows/directory.cpp
Normal file
40
shared/source/utilities/windows/directory.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "utilities/directory.h"
|
||||
|
||||
#include "os_interface/windows/windows_wrapper.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
std::vector<std::string> Directory::getFiles(const std::string &path) {
|
||||
std::vector<std::string> files;
|
||||
std::string newPath;
|
||||
|
||||
WIN32_FIND_DATAA ffd;
|
||||
HANDLE hFind = INVALID_HANDLE_VALUE;
|
||||
|
||||
if (path.c_str()[path.size() - 1] == '/') {
|
||||
return files;
|
||||
} else {
|
||||
newPath = path + "/*";
|
||||
}
|
||||
|
||||
hFind = FindFirstFileA(newPath.c_str(), &ffd);
|
||||
|
||||
if (INVALID_HANDLE_VALUE == hFind) {
|
||||
return files;
|
||||
}
|
||||
|
||||
do {
|
||||
files.push_back(path + "/" + ffd.cFileName);
|
||||
} while (FindNextFileA(hFind, &ffd) != 0);
|
||||
|
||||
FindClose(hFind);
|
||||
return files;
|
||||
}
|
||||
}; // namespace NEO
|
||||
112
shared/source/utilities/windows/timer_util.cpp
Normal file
112
shared/source/utilities/windows/timer_util.cpp
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "utilities/timer_util.h"
|
||||
|
||||
#include "helpers/debug_helpers.h"
|
||||
#include "os_interface/windows/windows_wrapper.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class Timer::TimerImpl {
|
||||
public:
|
||||
TimerImpl() {
|
||||
memset(&m_startTime, 0, sizeof(LARGE_INTEGER));
|
||||
memset(&m_endTime, 0, sizeof(LARGE_INTEGER));
|
||||
}
|
||||
|
||||
~TimerImpl() {
|
||||
}
|
||||
|
||||
LARGE_INTEGER start() {
|
||||
QueryPerformanceCounter((LARGE_INTEGER *)&m_startTime);
|
||||
return m_startTime;
|
||||
}
|
||||
|
||||
LARGE_INTEGER end() {
|
||||
QueryPerformanceCounter((LARGE_INTEGER *)&m_endTime);
|
||||
return m_endTime;
|
||||
}
|
||||
|
||||
long long int get() {
|
||||
auto timeDelta = (double)(m_endTime.QuadPart - m_startTime.QuadPart);
|
||||
timeDelta /= (double)mFrequency.QuadPart;
|
||||
timeDelta *= 1000000000.0;
|
||||
|
||||
if (m_endTime.QuadPart < m_startTime.QuadPart) {
|
||||
DEBUG_BREAK_IF(true);
|
||||
}
|
||||
return (long long)timeDelta;
|
||||
}
|
||||
|
||||
long long getStart() {
|
||||
return (long long)(((LARGE_INTEGER *)&m_startTime)->QuadPart);
|
||||
}
|
||||
|
||||
long long getEnd() {
|
||||
|
||||
return (long long)(((LARGE_INTEGER *)&m_endTime)->QuadPart);
|
||||
}
|
||||
|
||||
TimerImpl &operator=(const TimerImpl &t) {
|
||||
m_startTime = t.m_startTime;
|
||||
return *this;
|
||||
}
|
||||
|
||||
static void setFreq() {
|
||||
QueryPerformanceFrequency(&mFrequency);
|
||||
}
|
||||
|
||||
public:
|
||||
static LARGE_INTEGER mFrequency;
|
||||
|
||||
private:
|
||||
LARGE_INTEGER m_startTime;
|
||||
LARGE_INTEGER m_endTime;
|
||||
};
|
||||
|
||||
LARGE_INTEGER Timer::TimerImpl::mFrequency = {
|
||||
{{0}},
|
||||
};
|
||||
|
||||
Timer::Timer() {
|
||||
timerImpl = new TimerImpl();
|
||||
}
|
||||
|
||||
Timer::~Timer() {
|
||||
delete timerImpl;
|
||||
}
|
||||
|
||||
void Timer::start() {
|
||||
timerImpl->start();
|
||||
}
|
||||
|
||||
void Timer::end() {
|
||||
timerImpl->end();
|
||||
}
|
||||
|
||||
long long int Timer::get() {
|
||||
return timerImpl->get();
|
||||
}
|
||||
|
||||
long long Timer::getStart() {
|
||||
return timerImpl->getStart();
|
||||
}
|
||||
|
||||
long long Timer::getEnd() {
|
||||
return timerImpl->getEnd();
|
||||
}
|
||||
|
||||
Timer &Timer::operator=(const Timer &t) {
|
||||
*timerImpl = *(t.timerImpl);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Timer::setFreq() {
|
||||
TimerImpl::setFreq();
|
||||
}
|
||||
}; // namespace NEO
|
||||
Reference in New Issue
Block a user