-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/soa'
# Conflicts: # .gitignore # src/main.cpp # src/parallel/simd/rt_sse.h # src/parallel/simd/scene.h # src/parallel/simd/utils/rt_helper.h # src/parallel/simd/utils/types.h # src/xmake.lua # tests/test_sse.cpp
- Loading branch information
Showing
28 changed files
with
1,036 additions
and
885 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#include "config.h" | ||
Application::Application() { | ||
app.description("Parallel Path Tracing in C++ with SIMD|SoA|OpenMP|CUDA"); | ||
app.name("PathTracer"); | ||
|
||
app.add_option("-o,--output", output, "Output file name"); | ||
app.add_option("--width", width, "Image width"); | ||
app.add_option("--height", height, "Image height"); | ||
app.add_option("-s,--samples", samples, "Samples per pixel"); | ||
app.add_option("-t,--threads", threads, "Number of threads"); | ||
app.add_option("-m,--mode", executeMode, "Mode: CPU, SoA, SIMD_SSE, SIMD_AVX, SIMD_AVX_512, RawThread, OpenMP, Async")->required(); | ||
app.add_option("-p,--profile", profile, "Profile mode"); | ||
app.add_option("-l,--load", loadType, "Thread load type: Row, Column, Task"); | ||
app.add_option("--task", taskSize, "Task size"); | ||
app.add_option("--scene", scene, "Scene name"); | ||
app.allow_extras(); | ||
} | ||
|
||
int Application::run(int argc, char **argv) { | ||
CLI11_PARSE(app, argc, argv); | ||
return 0; | ||
} | ||
|
||
void Application::print() { | ||
std::cout << "Configuration:" << std::endl; | ||
std::cout << "Image: " << width << "x" << height << std::endl; | ||
std::cout << "Samples: " << samples << std::endl; | ||
std::cout << "ThreadNum: " << threads << std::endl; | ||
std::cout << "TaskSize: " << taskSize << std::endl; | ||
std::cout << "SplitThreadLoadType: " << loadType << std::endl; | ||
std::cout << "OpenMPMode: " << openMPMode << std::endl; | ||
} | ||
|
||
ExecuteMode Application::getExecuteMode() { | ||
if (executeMode == "CPU") { | ||
return ExecuteMode::CPU; | ||
} else if (executeMode == "SoA") { | ||
return ExecuteMode::SoA; | ||
} else if (executeMode == "SIMD_SSE") { | ||
return ExecuteMode::SIMD_SSE; | ||
} else if (executeMode == "SIMD_AVX") { | ||
return ExecuteMode::SIMD_AVX; | ||
} else if (executeMode == "SIMD_AVX_512") { | ||
return ExecuteMode::SIMD_AVX_512; | ||
} else if (executeMode == "RawThread") { | ||
return ExecuteMode::RawThread; | ||
} else if (executeMode == "OpenMP") { | ||
return ExecuteMode::OpenMP; | ||
} else if (executeMode == "Async") { | ||
return ExecuteMode::Async; | ||
} else { | ||
return ExecuteMode::CPU; | ||
} | ||
} | ||
|
||
ThreadLoadType Application::getThreadLoadType() { | ||
if (loadType == "Row") { | ||
return ThreadLoadType::Row; | ||
} else if (loadType == "Column") { | ||
return ThreadLoadType::Column; | ||
} else if (loadType == "Block") { | ||
return ThreadLoadType::Block; | ||
} else { | ||
return ThreadLoadType::Row; | ||
} | ||
} | ||
|
||
OpenMPMode Application::getOpenMPMode() { | ||
if (openMPMode == "ParallelFor") { | ||
return OpenMPMode::ParallelFor; | ||
} else if (openMPMode == "ParallelTask") { | ||
return OpenMPMode::ParallelTask; | ||
} else if (openMPMode == "ParallelWorkStealing") { | ||
return OpenMPMode::ParallelWorkStealing; | ||
} else { | ||
return OpenMPMode::ParallelFor; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#pragma once | ||
#include <CLI/App.hpp> | ||
#include <CLI/Config.hpp> | ||
#include <CLI/Formatter.hpp> | ||
|
||
enum class ExecuteMode { | ||
CPU, | ||
SoA, | ||
SIMD_SSE, | ||
SIMD_AVX, | ||
SIMD_AVX_512, | ||
RawThread, | ||
OpenMP, | ||
Async, | ||
}; | ||
|
||
enum class ThreadLoadType { | ||
Row, | ||
Column, | ||
Block, | ||
}; | ||
|
||
enum class OpenMPMode { | ||
ParallelFor, | ||
ParallelTask, | ||
ParallelWorkStealing, | ||
}; | ||
|
||
class Application { | ||
public: | ||
Application(); | ||
~Application(){}; | ||
int run(int argc, char **argv); | ||
ThreadLoadType getThreadLoadType(); | ||
ExecuteMode getExecuteMode(); | ||
OpenMPMode getOpenMPMode(); | ||
void print(); | ||
std::string name() const { return executeMode; } | ||
std::string getLogLevel() const { return logLevel; } | ||
|
||
public: | ||
CLI::App app; | ||
std::string output = "image.ppm"; | ||
int width = 512; | ||
int height = 512; | ||
int samples = 1; | ||
int threads = 8; | ||
bool profile = true; | ||
int taskSize = 1 * 1; | ||
std::string scene = "basic"; | ||
|
||
private: | ||
std::string loadType = "Row"; | ||
std::string openMPMode = "ParallelFor"; | ||
std::string executeMode = "CPU"; | ||
std::string logLevel = "off"; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// 实现一个输出到文件的静态类,方便全局调用 | ||
// 基于spdlog实现,写入到文件 | ||
|
||
#pragma once | ||
|
||
#include <spdlog/sinks/basic_file_sink.h> | ||
#include <spdlog/spdlog.h> | ||
|
||
class DebugHelper { | ||
public: | ||
static void init(std::string name = "default", std::string level = "error") { | ||
auto log_level = getLevel(level); | ||
auto path = std::format("logs/{}/{}.log", level, name); | ||
auto logger = spdlog::basic_logger_mt("basic_logger", path); | ||
spdlog::set_default_logger(logger); | ||
spdlog::set_level(log_level); | ||
spdlog::set_pattern("[%l] %v"); | ||
} | ||
|
||
static spdlog::level::level_enum getLevel(std::string &level) { | ||
if (level == "trace") { | ||
return spdlog::level::trace; | ||
} else if (level == "debug") { | ||
return spdlog::level::debug; | ||
} else if (level == "info") { | ||
return spdlog::level::info; | ||
} else if (level == "warn") { | ||
return spdlog::level::warn; | ||
} else if (level == "error") { | ||
return spdlog::level::err; | ||
} else if (level == "critical") { | ||
return spdlog::level::critical; | ||
} else { | ||
level = "off"; | ||
return spdlog::level::off; | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.