Skip to content

Commit

Permalink
Went through C and C++ benchmarks, documented and added tool for comp…
Browse files Browse the repository at this point in the history
…iling.

Added "bin/" to .gitignore, changed CFLAGS order, added heat_equation readme.
Changed c99 CFLAGS order.
shallow_water-c99: Got it running with bp_util.
Removed some empties and added notes on OpenCL implementation.
Removed placeholders for unimplemented c99 and c11 benchmarks.
They are annoying... really does not make any sense having them.
shallow_water-cpp11_boost: Removed unused typedef.
Output-printing is now the same for these benchmarks.
Black Scholes armadillo implementation is now running.
Got blitz running.
Got black_scholes BXX running, holy **** it is good :)
  • Loading branch information
safl committed Apr 1, 2015
1 parent 0139f8e commit f134250
Show file tree
Hide file tree
Showing 735 changed files with 792 additions and 454 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.pyc
build/
bin/
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ uninstall_sp:
@echo "Or just remove those files in some other way."
@echo 'rm -rf $$(cat record.txt)'

# Compile all c99 benchmarks
c99:
echo

# Compile all cpp11 benchmarks
cpp11:
echo

# Remove stuff...
clean:
rm -f MANIFEST
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/_utils/c99/Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LIBS=-lm
EXTRAS+=

$(BENCHMARK): $(BENCH_SRC)
$(CC) $(UTILS) $< -o bin/$@ $(CFLAGS) $(INCLUDE) $(LIBS) $(EXTRAS)
$(CC) $(CFLAGS) $(INCLUDE) $(LIBS) $(EXTRAS) $(UTILS) $< -o bin/$@

clean:
rm -rf *.o *~
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/_utils/cpp11/Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LIBS=-lm
EXTRAS+=

$(BENCHMARK): $(BENCH_SRC)
$(CXX) $(UTILS) $< -o bin/$@ $(CXXFLAGS) $(INCLUDE) $(LIBS) $(EXTRAS)
$(CXX) $(UTILS) $(CXXFLAGS) $(INCLUDE) $< $(LIBS) $(EXTRAS) -o bin/$@

clean:
rm -rf *.o *~
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
25 changes: 3 additions & 22 deletions benchmarks/black_scholes/cpp11_armadillo/Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
include ../Makefile.common

all: benchmarks

clean:
rm -rf *.o *~
find bin/ -type f -name "*" -exec rm {} \;

benchmarks: $(BENCHMARKS)

#
# Benchmarks
#
black_scholes: src/black_scholes.cpp
$(CXX) $< -o bin/$@ $(CXXFLAGS) $(INCLUDE) $(LIBS) $(EXTRAS)

mc: src/mc.cpp
$(CXX) $< -o bin/$@ $(CXXFLAGS) $(INCLUDE) $(LIBS) $(EXTRAS)

synth: src/synth.cpp
$(CXX) $< -o bin/$@ $(CXXFLAGS) $(INCLUDE) $(LIBS) $(EXTRAS)

include ../../_utils/cpp11/Makefile.common
CXXFLAGS+=-fopenmp
LIBS+=-larmadillo
51 changes: 19 additions & 32 deletions benchmarks/black_scholes/cpp11_armadillo/src/black_scholes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <armadillo>
#include "util/timing.hpp"
#include "util/argparse.hpp"
#include <bp_util.h>

using namespace std;
using namespace arma;
using namespace argparse;

template <typename T>
Col<T> cnd(Col<T> x)
Expand Down Expand Up @@ -80,49 +78,38 @@ T* pricing(size_t samples, size_t iterations, char flag, T x, T d_t, T r, T v)

int main(int argc, char* argv[])
{
const char usage[] = "usage: ./black_scholes --size=1000*10 [--verbose]";
if (2>argc) {
cout << usage << endl;
return 1;
}

arguments_t args; // Parse command-line
if (!parse_args(argc, argv, args)) {
cout << "Err: Invalid argument(s)." << endl;
cout << usage << endl;
return 1;
}
if (2 > args.size.size()) {
cout << "Err: Not enough arguments." << endl;
cout << usage << endl;
return 1;
}
if (2 < args.size.size()) {
cout << "Err: Too many arguments." << endl;
cout << usage << endl;
return 1;
}
//const char usage[] = "usage: ./black_scholes --size=1000*10 [--verbose]";

bp_arguments_type args = parse_args(argc, argv); // Parse args
const size_t samples = args.sizes[0];
const size_t iterations = args.sizes[1];

printf(
"Running black_scholes(cpp11_armadillo) --size=%ld*%ld\n",
samples,
iterations
);

size_t start = sample_time();
size_t start = bp_sample_time();
double* prices = pricing( // Do the computations...
args.size[0], args.size[1],
samples, iterations,
'c', 65.0, 1.0 / 365.0,
0.08, 0.3
);
size_t end = sample_time();
size_t stop = bp_sample_time();
size_t elapsed = stop - start;
// Output timing
cout << "{elapsed-time: "<< (end-start)/1000000.0 <<"";
printf("Ran black_scholes(cpp11_armadillo) iter: %ld size: %ld elapsed-time: %lf\n", iterations, samples, elapsed/(double)1000000.0);
if (args.verbose) { // and values.
cout << ", \"output\": [";
for(size_t i=0; i<args.size[1]; i++) {
for(size_t i=0; i<iterations; i++) {
cout << prices[i];
if (args.size[1]-1!=i) {
if (iterations-1!=i) {
cout << ", ";
}
}
cout << "]" << endl;
}
cout << "}" << endl;

free(prices); // Cleanup
return 0;
Expand Down
Empty file.
28 changes: 3 additions & 25 deletions benchmarks/black_scholes/cpp11_blitz/Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,3 @@
include ../Makefile.common

BENCHMARKS=mc

all: benchmarks

clean:
rm -rf *.o *~
find bin/ -type f -name "*" -exec rm {} \;

benchmarks: $(BENCHMARKS)

#
# Benchmarks
#
black_scholes: src/black_scholes.cpp
echo $(BENCHMARKS)
$(CXX) $< -o bin/$@ $(CXXFLAGS) $(INCLUDE) $(LIBS) $(EXTRAS)

mc: src/mc.cpp
$(CXX) $< -o bin/$@ $(CXXFLAGS) $(INCLUDE) $(LIBS) $(EXTRAS)

synth: src/synth.cpp
$(CXX) $< -o bin/$@ $(CXXFLAGS) $(INCLUDE) $(LIBS) $(EXTRAS)

include ../../_utils/cpp11/Makefile.common
CXXFLAGS+=-fopenmp
LIBS+=-lblitz
49 changes: 18 additions & 31 deletions benchmarks/black_scholes/cpp11_blitz/src/black_scholes.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#include <blitz/array.h>
#include <random/uniform.h>
#include "util/argparse.hpp"
#include "util/timing.hpp"
#include <bp_util.h>

using namespace blitz;
using namespace ranlib;
using namespace argparse;

template <typename T>
Array<T, 1> cnd(Array<T, 1> & x)
Expand Down Expand Up @@ -69,49 +67,38 @@ T* pricing(size_t samples, size_t iterations, char flag, T x, T d_t, T r, T v)

int main(int argc, char* argv[])
{
const char usage[] = "usage: ./black_scholes --size=1000*10 [--verbose]";
if (2>argc) {
cout << usage << endl;
return 1;
}
//const char usage[] = "usage: ./black_scholes --size=1000*10 [--verbose]";

arguments_t args; // Parse command-line
if (!parse_args(argc, argv, args)) {
cout << "Err: Invalid argument(s)." << endl;
cout << usage << endl;
return 1;
}
if (2 > args.size.size()) {
cout << "Err: Not enough arguments." << endl;
cout << usage << endl;
return 1;
}
if (2 < args.size.size()) {
cout << "Err: Too many arguments." << endl;
cout << usage << endl;
return 1;
}
bp_arguments_type args = parse_args(argc, argv); // Parse args
const size_t samples = args.sizes[0];
const size_t iterations = args.sizes[1];

printf(
"Running black_scholes(cpp11_blitz) --size=%ld*%ld\n",
samples,
iterations
);

size_t start = sample_time();
size_t start = bp_sample_time();
double* prices = pricing( // Do the computations...
args.size[0], args.size[1],
samples, iterations,
'c', 65.0, 1.0 / 365.0,
0.08, 0.3
);
size_t end = sample_time();
size_t stop = bp_sample_time();
size_t elapsed = stop - start;
// Output timing
cout << "{elapsed-time: "<< (end-start)/1000000.0 <<"";
printf("Ran black_scholes(cpp11_blitz) iter: %ld size: %ld elapsed-time: %lf\n", iterations, samples, elapsed/(double)1000000.0);
if (args.verbose) { // and values.
cout << ", \"output\": [";
for(size_t i=0; i<args.size[1]; i++) {
for(size_t i=0; i<iterations; i++) {
cout << prices[i];
if (args.size[1]-1!=i) {
if (iterations-1!=i) {
cout << ", ";
}
}
cout << "]" << endl;
}
cout << "}" << endl;

free(prices); // Cleanup
return 0;
Expand Down
Empty file.
Empty file.
4 changes: 4 additions & 0 deletions benchmarks/black_scholes/cpp11_bxx/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include ../../_utils/cpp11/Makefile.common
CXXFLAGS+=-fopenmp
LIBS+=-L$(HOME)/.local/lib -lbh
INCLUDE+=-I$(HOME)/.local/include -I$(HOME)/.local/include/bohrium
52 changes: 20 additions & 32 deletions benchmarks/black_scholes/cpp11_bxx/src/black_scholes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ GNU Lesser General Public License along with bohrium.
If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include "bxx/bohrium.hpp"
#include "util/timing.hpp"
#include "util/argparse.hpp"
#include <bxx/bohrium.hpp>
#include <bp_util.h>

using namespace std;
using namespace bxx;
using namespace argparse;

template <typename T>
multi_array<T>& cnd(multi_array<T>& x)
Expand Down Expand Up @@ -80,48 +78,38 @@ T* pricing(size_t samples, size_t iterations, char flag, T x, T d_t, T r, T v)

int main(int argc, char* argv[])
{
const char usage[] = "usage: ./black_scholes --size=1000*10 [--verbose]";
if (2>argc) {
cout << usage << endl;
return 1;
}
//const char usage[] = "usage: ./black_scholes --size=1000*10 [--verbose]";

arguments_t args; // Parse command-line
if (!parse_args(argc, argv, args)) {
cout << "Err: Invalid argument(s)." << endl;
cout << usage << endl;
return 1;
}
if (2 > args.size.size()) {
cout << "Err: Not enough arguments." << endl;
cout << usage << endl;
return 1;
}
if (2 < args.size.size()) {
cout << "Err: Too many arguments." << endl;
cout << usage << endl;
return 1;
}
bp_arguments_type args = parse_args(argc, argv); // Parse args
const size_t samples = args.sizes[0];
const size_t iterations = args.sizes[1];

printf(
"Running black_scholes(cpp11_bxx) --size=%ld*%ld\n",
samples,
iterations
);

bh_intp start = sample_time();
double* prices = pricing<double>( // Do the computations...
args.size[0], args.size[1],
size_t start = bp_sample_time();
double* prices = pricing( // Do the computations...
samples, iterations,
'c', 65.0, 1.0 / 365.0,
0.08, 0.3
);
size_t stop = bp_sample_time();
size_t elapsed = stop - start;
// Output timing
cout << "{elapsed-time: "<< (sample_time()-start)/1000000.0 <<"";
printf("Ran black_scholes(cpp11_bxx) iter: %ld size: %ld elapsed-time: %lf\n", iterations, samples, elapsed/(double)1000000.0);
if (args.verbose) { // and values.
cout << ", \"output\": [";
for(size_t i=0; i<args.size[1]; i++) {
for(size_t i=0; i<iterations; i++) {
cout << prices[i];
if (args.size[1]-1!=i) {
if (iterations-1!=i) {
cout << ", ";
}
}
cout << "]" << endl;
}
cout << "}" << endl;

free(prices); // Cleanup
return 0;
Expand Down
Empty file.
25 changes: 3 additions & 22 deletions benchmarks/black_scholes/cpp11_eigen/Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
include ../Makefile.common

all: benchmarks

clean:
rm -rf *.o *~
find bin/ -type f -name "*" -exec rm {} \;

benchmarks: $(BENCHMARKS)

#
# Benchmarks
#
black_scholes: src/black_scholes.cpp
$(CXX) $< -o bin/$@ $(CXXFLAGS) $(INCLUDE) $(LIBS) $(EXTRAS)

mc: src/mc.cpp
$(CXX) $< -o bin/$@ $(CXXFLAGS) $(INCLUDE) $(LIBS) $(EXTRAS)

synth: src/synth.cpp
$(CXX) $< -o bin/$@ $(CXXFLAGS) $(INCLUDE) $(LIBS) $(EXTRAS)

include ../../_utils/cpp11/Makefile.common
CXXFLAGS+=-fopenmp
INCLUDE+=-I/usr/include/eigen3
1 change: 1 addition & 0 deletions benchmarks/black_scholes/cpp11_eigen/issues.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Compilation errors.

0 comments on commit f134250

Please sign in to comment.