david-grs / geiger Goto Github PK
View Code? Open in Web Editor NEWC++ micro benchmark library
License: MIT License
C++ micro benchmark library
License: MIT License
The papi.h
file tries to include itself.
It appears that geiger is header-only as promised but then has dependencies on
Any interest in making that optional?
Hi David,
Wondered how geiger deals with compiler optimisations. If you see Chandler Carruth`s CPPCon video here : https://www.youtube.com/watch?v=nXaxk27zwlk&feature=youtu.be&t=2441
which is used in Google benchmark ( benchmark::DoNotOptimize and benchmark::ClobberMemory )
Thanks,
Akin
Hi, this is the bench result output format I'm seeing.
It is not equal to the one on your examples with the 'time' column.
Is this normal?
The full code used is below
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <chrono>
#include <algorithm>
#include <geiger/geiger.h>
__global__ void hadamard(size_t n, float* a, float* b, float* c)
{
int const id = blockIdx.x * blockDim.x + threadIdx.x;
if(id < n)
c[id] = a[id] * b[id];
}
__global__ void hadamard_fast(size_t n, float* a, float* b, float* c)
{
int const id = blockIdx.x * blockDim.x + threadIdx.x;
if(id < n)
c[id] = __fmul_rn(a[id], b[id]);
}
int main()
{
geiger::init();
geiger::suite<> suite;
size_t size = 1000;
int block_size = 64;
int grid_size = (int)ceil((float)size/block_size);
float* a = (float*)malloc(sizeof(float)*size);
float* b = (float*)malloc(sizeof(float)*size);
float* c = (float*)malloc(sizeof(float)*size);
std::fill(a, a + size, 5);
std::fill(b, b + size, 3);
float* d_a;
float* d_b;
float* d_c;
cudaMalloc(&d_a, sizeof(float)*size);
cudaMalloc(&d_b, sizeof(float)*size);
cudaMalloc(&d_c, sizeof(float)*size);
cudaMemcpy(d_a, a, sizeof(float) * size, cudaMemcpyHostToDevice);
cudaMemcpy(d_b, b, sizeof(float) * size, cudaMemcpyHostToDevice);
cudaMemcpy(d_c, c, sizeof(float) * size, cudaMemcpyHostToDevice);
suite.add("hadamard standard", [d_a, d_b, d_c,
size, block_size, grid_size]()
{
hadamard<<<grid_size, block_size>>>(size, d_a, d_b, d_c);
})
.add("hadamard fast", [d_a, d_b, d_c,
size, block_size, grid_size]()
{
hadamard_fast<<<grid_size, block_size>>>(size, d_a, d_b, d_c);
})
.set_printer<geiger::printer::console<>>()
.run(std::chrono::milliseconds(1));
cudaMemcpy(c, d_c, sizeof(float) * size, cudaMemcpyDeviceToHost);
std::cout << "result: " << c[0] << std::endl;
cudaFree(d_a);
cudaFree(d_b);
cudaFree(d_c);
free(a);
free(b);
free(c);
return 0;
}
On a very standard Ubuntu 16.10 box I am seeing:
edd@brad:~/git/geiger/build(master)$ examples/walk
Test Time (ns) L1 DCM L2 DCM L3 TCM
--------------------------------------------------------------------
terminate called after throwing an instance of 'std::runtime_error'
what(): PAPI_start_counters failed with events: PAPI_L1_DCM PAPI_L2_DCM PAPI_L3_TCM : Event does not exist
Aborted (core dumped)
edd@brad:~/git/geiger/build(master)$
Same with other examples and some tests. Is that expected?
I've just now used this very nice library to benchmark some answers on a stackoverflow performance optimization question:
Convert two integers into a single float value
unfortunately, the best solutions take around 1 ns / iteration or less... which means that the results printout isn't accurate enough. I'm sure you have options to increase the printed value precision, or change the timing unit from nanosecond to picosecond (if not - I'll open another issue). But - there's no documentation on how to make that happen.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.