Skip to content

Instantly share code, notes, and snippets.

Throughput comparison

R9 5950X using AnimRay commit 729370df6ba0220fe55a506c462acfd19d0b942a

General purpose kernel

$ uname -a
Linux vangogh 5.11.0-17-generic #18-Ubuntu SMP Thu May 6 20:10:11 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
@KayEss
KayEss / spheres-white--.md
Last active May 1, 2021 14:24
perf summary for some ray traced outputs

double

"spheres-white.tga" 1920x1080 225/225 (128x72)
"spheres-white.tga" 1920x1080 225/225 (128x72)
"spheres-white.tga" 1920x1080 225/225 (128x72)
"spheres-white.tga" 1920x1080 225/225 (128x72)
"spheres-white.tga" 1920x1080 225/225 (128x72)

 Performance counter stats for './build.tmp/clang-release/scenes/early/spheres-white -w 1920 -h 1080 -c 100 -s 20' (5 runs):
@KayEss
KayEss / ttt.cpp
Last active September 10, 2020 13:20
Quick clock
// clang++ -O3 time.cpp -o ttt
#include <chrono>
#include <iostream>
int main() {
auto last = std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::system_clock::now().time_since_epoch()).count();
while(true) {
@KayEss
KayEss / urandom.cpp
Last active February 21, 2019 10:55
Check for 32 byte collisions in urandom output
/**
# Look for 32 byte collisions from urandom.
Compile with:
```
clang++ urandom.cpp -std=c++17 -O3 -o urandom -Werror
```
*/
@KayEss
KayEss / lisp.cpp
Last active June 9, 2023 17:06
Build me a LISP
/// # Build me a LISP
// Read this nicely formatted at https://kirit.com/Build%20me%20a%20LISP
/**
Normally programming language blog posts get started with grammars and syntax
and parsing and all sorts of stuff like that. I can't be bothered with all of
that, so instead, let's start with the (maybe more interesting aspect) of the
actual evaluation of the code. Here we'll build an evaluation engine for LISP
like languages in less than 50 lines of C++ -- [and literate C++ at
@KayEss
KayEss / coro3.cpp
Last active June 17, 2017 04:18
Coroutine generator
/*
* A generator. Initial code taken from N4649 p15
* http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4649.pdf
*/
#include <experimental/coroutine>
#include <iostream>
@KayEss
KayEss / pi.cpp
Last active March 5, 2017 06:12
Estimate pi using monte-carlo method varying radius and number of samples.
// Compile with:
// clang++ --std=c++14 -O3 -o pi pi.cpp
#include <algorithm>
#include <cmath>
#include <experimental/iterator>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <type_traits>
@KayEss
KayEss / check.cpp
Last active August 29, 2015 05:42
`DEBUG` and release builds -- is it reasonable to expect the compiler to completely optimise away the `check` function on non-`DEBUG` builds, but leave the side effects of the arguments alone?
#ifdef DEBUG
inline void check(const auto &b) {
if ( !b ) std::terminate();
}
#else
inline void check(const auto &) {
}
#endif
@KayEss
KayEss / syscall.cpp
Last active August 29, 2015 14:27
General form for Linux system call
// Signal handling.... sigh
template<typename F> inline
int syscall(F f) {
int result{};
do {
result = f();
} while ( result == -1 && errno == EINTR );
return result;
}
@KayEss
KayEss / snake.cpp
Created May 22, 2015 07:13
Brute force solution for Vietnamese snake problem
// Compile as C++14
// clang++ --std=c++14 snake.cpp -O3 -o /tmp/snake && /tmp/snake
// http://www.theguardian.com/science/alexs-adventures-in-numberland/2015/may/20/can-you-do-the-maths-puzzle-for-vietnamese-eight-year-olds-that-has-stumped-parents-and-teachers
#include <iostream>
#include <vector>
#include <algorithm>
int main() {
std::size_t tries = 0, wins = 0;