generated from feelpp/feelpp-project
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
benchmarking distribution #6 Adds real uniform distribution benchmark…
…s, removes error when plotting
- Loading branch information
1 parent
e1de326
commit e89327f
Showing
18 changed files
with
796 additions
and
42 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
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
This file was deleted.
Oops, something went wrong.
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
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
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
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 @@ | ||
Flag,Method,Duration |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,105 @@ | ||
#include <iostream> | ||
#include <vector> | ||
#include <random> | ||
#include <chrono> | ||
#include <fstream> | ||
#include "../extlibs/EigenRand/EigenRand/EigenRand" | ||
#include "../extlibs/Xoshiro-cpp/XoshiroCpp.hpp" | ||
#include "../extlibs/pcg-cpp/include/pcg_random.hpp" | ||
#include "../extlibs/eigen/Eigen/Dense" | ||
#include "../extlibs/eigen/Eigen/Core" | ||
|
||
using namespace XoshiroCpp; | ||
|
||
int main(int argc, char *argv[]) { | ||
std::string flag; | ||
std::stringstream ss; | ||
|
||
if (argc > 1) { | ||
for(int i = 1; i < argc; ++i) { | ||
if(i != 1) { | ||
ss << " "; | ||
} | ||
ss << argv[i]; | ||
} | ||
|
||
flag = ss.str(); | ||
} | ||
else { | ||
flag = "default"; | ||
} | ||
|
||
std::ofstream outputFile("uniform_real.csv", std::ofstream::app); | ||
|
||
const int numVectors = 100000000; | ||
|
||
std::vector<double> stdVector(numVectors); | ||
std::vector<double> mersenneVector(numVectors); | ||
Eigen::VectorXd EigenVector(numVectors); | ||
std::vector<double> pcgCppVector(numVectors); | ||
std::vector<double> xoshiroCppVector(numVectors); | ||
Eigen::VectorXd EigenVector2(numVectors); | ||
|
||
auto startEigen = std::chrono::steady_clock::now(); | ||
Eigen::VectorXd eigenVector = Eigen::VectorXd::Random(numVectors).array() / 2.0 + 0.5; // Remap the Eigen random from [-1,1] to [0,1] | ||
auto endEigen = std::chrono::steady_clock::now(); | ||
auto durationEigen = std::chrono::duration_cast<std::chrono::milliseconds>(endEigen - startEigen); | ||
outputFile<< "\n" << flag << ",Eigen::VectorXd::Random,"<< durationEigen.count(); | ||
|
||
std::random_device rd; | ||
std::mt19937 gen(rd()); | ||
std::uniform_real_distribution<double> dist(0.0, 1.0); | ||
|
||
auto startStdUniform = std::chrono::steady_clock::now(); | ||
for (int i = 0; i < numVectors; ++i) { | ||
stdVector[i] = dist(gen); | ||
} | ||
auto endStdUniform = std::chrono::steady_clock::now(); | ||
auto durationStdUniform = std::chrono::duration_cast<std::chrono::milliseconds>(endStdUniform - startStdUniform); | ||
outputFile<< "\n" << flag << ",std::uniform_real_distribution," << durationStdUniform.count(); | ||
|
||
std::mt19937 mersenne(gen()); | ||
std::uniform_real_distribution<double> mersenneDist(0.0, 1.0); | ||
|
||
auto startMersenne = std::chrono::steady_clock::now(); | ||
for (int i = 0; i < numVectors; ++i) { | ||
mersenneVector[i] = mersenneDist(mersenne); | ||
} | ||
auto endMersenne = std::chrono::steady_clock::now(); | ||
auto durationMersenne = std::chrono::duration_cast<std::chrono::milliseconds>(endMersenne - startMersenne); | ||
outputFile<< "\n" << flag << ",Mersenne Twister," << durationMersenne.count(); | ||
|
||
Eigen::Rand::Vmt19937_64 urng{ 42 }; | ||
auto startEigenRand = std::chrono::steady_clock::now(); | ||
EigenVector = Eigen::Rand::uniformRealLike(EigenVector, urng); | ||
auto endEigenRand = std::chrono::steady_clock::now(); | ||
auto durationEigenRand = std::chrono::duration_cast<std::chrono::milliseconds>(endEigenRand - startEigenRand); | ||
outputFile << "\n" << flag << ",EigenRand,"<< durationEigenRand.count(); | ||
|
||
pcg64_fast rng; | ||
rng.seed(42); | ||
std::uniform_real_distribution<double> pcgDist(0.0, 1.0); | ||
|
||
auto startPcgCpp = std::chrono::steady_clock::now(); | ||
for (int i = 0; i < numVectors; ++i) { | ||
pcgCppVector[i] = pcgDist(rng); | ||
} | ||
auto endPcgCpp = std::chrono::steady_clock::now(); | ||
auto durationPcgCpp = std::chrono::duration_cast<std::chrono::milliseconds>(endPcgCpp - startPcgCpp); | ||
outputFile << "\n" << flag << ",pcg-cpp," << durationPcgCpp.count(); | ||
|
||
const std::uint64_t seed = 12345; | ||
Xoshiro256PlusPlus rg(seed); | ||
std::uniform_real_distribution<double> DIST(0.0,1.0); | ||
|
||
auto startXoshiroCpp = std::chrono::steady_clock::now(); | ||
for (int i = 0; i < numVectors; i++) { | ||
xoshiroCppVector[i] = DIST(rg); | ||
} | ||
auto endXoshiroCpp = std::chrono::steady_clock::now(); | ||
auto durationXoshiroCpp = std::chrono::duration_cast<std::chrono::milliseconds>(endXoshiroCpp - startXoshiroCpp); | ||
outputFile << "\n" << flag << ",XoshiroCpp,"<< durationXoshiroCpp.count(); | ||
outputFile.close(); | ||
|
||
return 0; | ||
} |
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 @@ | ||
Flag,Method,Duration |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1 +1,25 @@ | ||
RNG TYPE,EXECUTION TIME | ||
METHOD,TIME | ||
Shading mask STD RNG -Ofast -march=native,9.99015 | ||
Shading mask PCG RNG -Ofast -march=native,8.34877 | ||
Shading mask XOSHIRO RNG -Ofast -march=native,7.88745 | ||
Shading mask MIX RNG -Ofast -march=native,9.741 | ||
Shading mask STD RNG -Ofast -march=native,9.88132 | ||
Shading mask PCG RNG -Ofast -march=native,9.80248 | ||
Shading mask XOSHIRO RNG -Ofast -march=native,9.92391 | ||
Shading mask MIX RNG -Ofast -march=native,10.1443 | ||
Shading mask STD RNG -Ofast -march=native,10.9991 | ||
Shading mask PCG RNG -Ofast -march=native,9.99749 | ||
Shading mask XOSHIRO RNG -Ofast -march=native,9.81854 | ||
Shading mask MIX RNG -Ofast -march=native,9.63068 | ||
Shading mask STD RNG -Ofast -march=native,11.0136 | ||
Shading mask PCG RNG -Ofast -march=native,10.4724 | ||
Shading mask XOSHIRO RNG -Ofast -march=native,10.855 | ||
Shading mask MIX RNG -Ofast -march=native,10.9804 | ||
Shading mask STD RNG -Ofast -march=native -funroll-loops -funsafe-math-optimizations,11.7976 | ||
Shading mask PCG RNG -Ofast -march=native -funroll-loops -funsafe-math-optimizations,10.2469 | ||
Shading mask XOSHIRO RNG -Ofast -march=native -funroll-loops -funsafe-math-optimizations,9.38577 | ||
Shading mask MIX RNG -Ofast -march=native -funroll-loops -funsafe-math-optimizations,10.0054 | ||
Shading mask STD RNG -O3 -march=native,10.7028 | ||
Shading mask PCG RNG -O3 -march=native,10.8316 | ||
Shading mask XOSHIRO RNG -O3 -march=native,10.3154 | ||
Shading mask MIX RNG -O3 -march=native,11.3336 |
Oops, something went wrong.