-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
57 lines (48 loc) · 2.37 KB
/
Copy pathmain.cpp
File metadata and controls
57 lines (48 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <iostream>
#include <chrono>
#include "include/models/ode.hpp"
#include "include/models/mandelbrot.hpp"
int main() {
std::cout << "========================================" << std::endl;
std::cout << " MORPHOGEN SIMULATION ENGINE " << std::endl;
std::cout << "========================================" << std::endl;
// 1. ODE Model Simulation
std::cout << "\n[1] Running ODE Model..." << std::endl;
ODE ode;
double ans = ode.calculate(1, 2, 0.01);
std::cout << "ODE calculation final state: " << ans << std::endl;
// 2. Mandelbrot Fractal Generation (GPU & CPU)
std::cout << "\n[2] Running Mandelbrot Pattern Generation..." << std::endl;
MandelbrotConfig config;
config.width = 1280;
config.height = 720;
config.max_iterations = 500;
Mandelbrot mandelbrot(config);
// CPU Execution
std::cout << "\n-> Running CPU Mandelbrot simulation ("
<< config.width << "x" << config.height
<< ", max " << config.max_iterations << " iters)..." << std::endl;
auto startCpu = std::chrono::high_resolution_clock::now();
std::vector<int> cpu_results = mandelbrot.computeCPU();
auto endCpu = std::chrono::high_resolution_clock::now();
std::chrono::duration<double, std::milli> cpu_duration = endCpu - startCpu;
std::cout << "CPU Elapsed Time: " << cpu_duration.count() << " ms" << std::endl;
// Export CPU Image
if (Mandelbrot::savePPM("mandelbrot_cpu.ppm", cpu_results, config.width, config.height, config.max_iterations)) {
std::cout << "Exported CPU fractal rendering to mandelbrot_cpu.ppm" << std::endl;
}
// GPU Execution (CUDA)
std::cout << "\n-> Running GPU Mandelbrot simulation..." << std::endl;
std::vector<int> gpu_results = mandelbrot.computeGPU();
if (!gpu_results.empty()) {
if (Mandelbrot::savePPM("mandelbrot_gpu.ppm", gpu_results, config.width, config.height, config.max_iterations)) {
std::cout << "Exported GPU fractal rendering to mandelbrot_gpu.ppm" << std::endl;
}
// Verification
std::cout << "\n-> Verifying GPU vs CPU computation..." << std::endl;
bool match = mandelbrot.verify(cpu_results, gpu_results);
std::cout << "Verification Status: " << (match ? "SUCCESS" : "MISMATCH") << std::endl;
}
std::cout << "\nSimulation run complete." << std::endl;
return 0;
}