Initial setup for CLion

This commit is contained in:
2026-03-28 16:54:11 +11:00
parent 239cc02591
commit 7b4134133c
1136 changed files with 811916 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
#pragma once
#include <chrono>
// Utility Timer
template <typename Clock = std::chrono::high_resolution_clock> class Stopwatch {
typename Clock::time_point start_point;
public:
Stopwatch() : start_point(Clock::now()) {}
// Returns elapsed time
template <typename Rep = typename Clock::duration::rep, typename Units = typename Clock::duration> Rep elapsedTime() const {
std::atomic_thread_fence(std::memory_order_relaxed);
auto counted_time = std::chrono::duration_cast<Units>(Clock::now() - start_point).count();
std::atomic_thread_fence(std::memory_order_relaxed);
return static_cast<Rep>(counted_time);
}
};
using preciseStopwatch = Stopwatch<>;

View File

@@ -0,0 +1,20 @@
#pragma once
#include <fstream>
#include <string>
#include <vector>
#include <cuda_runtime.h>
#include <spdlog/spdlog.h>
namespace Util {
// Checks if a file exists at the given file path
bool doesFileExist(const std::string &filepath);
// Checks and logs CUDA error codes
void checkCudaErrorCode(cudaError_t code);
// Retrieves a list of file names in the specified directory
std::vector<std::string> getFilesInDirectory(const std::string &dirPath);
}
#include "Util.inl"

View File

@@ -0,0 +1,30 @@
#pragma once
#include <filesystem>
namespace Util {
inline bool doesFileExist(const std::string &filepath) {
std::ifstream f(filepath.c_str());
return f.good();
}
inline void checkCudaErrorCode(cudaError_t code) {
if (code != cudaSuccess) {
std::string errMsg = "CUDA operation failed with code: " + std::to_string(code) + " (" + cudaGetErrorName(code) +
"), with message: " + cudaGetErrorString(code);
spdlog::error(errMsg);
// throw std::runtime_error(errMsg);
}
}
inline std::vector<std::string> getFilesInDirectory(const std::string &dirPath) {
std::vector<std::string> fileNames;
for (const auto &entry : std::filesystem::directory_iterator(dirPath)) {
if (entry.is_regular_file()) {
fileNames.push_back(entry.path().string());
}
}
return fileNames;
}
}