Skip to content

Instantly share code, notes, and snippets.

View syoyo's full-sized avatar
💗
ray tracing

Syoyo Fujita syoyo

💗
ray tracing
View GitHub Profile
@syoyo
syoyo / gist:d502bd890f9e32f159da
Created October 25, 2015 06:12
Simple task queue using C++11 thread&atomic
std::vector<std::thread> workers;
std::atomic<unsigned int> i(0);
for (auto t = 0; t < std::thread::hardware_concurrency(); t++){
workers.push_back(std::thread([&,t](){
int index = 0;
while((index = i++) < numItems){
...
}
}));
@syoyo
syoyo / gist:44620be1c77195bc736e
Created October 9, 2015 15:03
Bilinear interpolation of alpha value
// Simple Bilinear interpolation(e.g. texture filtering)
// w0 + w1 + w2 + w3 = 1.0f;
// a[0] ~ a[3] = alpha value of 2x2 pixels.
float ret = w0 * a[0] + w1 * a[1] + w2 * a[2] + w3 * a[3];
// Sometimes ret become 0x3ffffff if all a's are 1.0f(0x3f800000) due to numerical error?
// atan2(y, x) =
//
// y y
// pi/2|\ pi/2|\
// | |
// pi | 0 pi | 0
// ---------o---------> x =>> ---------o--------> x
// -pi | -0 pi | 2 pi
// | |
// | |
@syoyo
syoyo / gist:8e7c92e2e6a6895b0038
Created October 4, 2015 04:51
Hugo static render
# config.toml
baseurl = ""
languageCode = "en-us"
title = "Fah doc"
relativeURLs = true
uglyURLs = true
@syoyo
syoyo / gist:e29580d6f952d30e8042
Last active December 2, 2017 20:56
GCE instance explicit termination
gcloud compute instances create ${GCE_MASTER_INSTANCE_NAME} ...
# wait instance boot up
# fixme: there should be much better way
sleep 30
# shutdown after 60 min
# must add -f flag(background execution)
gcloud compute ssh ${GCE_MASTER_INSTANCE_NAME} --zone ${GCE_ZONE} --ssh-flag="-f" --command="sudo /sbin/shutdown -h -P +60"
$ cat test.n
(none
; This top-level code is dynamic and compiled to Lua code
(function printhello ()
; all statements are symbolic expressions
; known from Lisp and Scheme
(print "None is as dynamic as this!"))
(static mymul(a b)
@syoyo
syoyo / gist:57f03324d712681fbfd2
Created August 8, 2015 09:59
ARM NEON + clang ext_vector_type test
#include <arm_neon.h>
typedef float float4 __attribute__((ext_vector_type(4)));
float4 mymax(float4 a, float4 b)
{
float4 ret;
ret = vmaxq_f32(a, b);
return ret;
//
// SPARC HPC-ACE
// FCCpx -Krestp=all -Kfast expf_test.cpp
//
fmath_exp aveDiff= 1e-06 maxDiff=3.891789e-06
new_exp aveDiff= 2e-08 maxDiff=1.192089e-07
new_exp4 aveDiff= 2e-08 maxDiff=1.192078e-07
new_exp4d aveDiff= 2e-08 maxDiff=5.036628e-08
std::exp 0.197360
fmath_exp 0.110120
@syoyo
syoyo / gist:956846067e49eb42c4b1
Created June 29, 2015 10:05
new_exp, new_exp4 sim
//// new_exp
// == sim start ==
LLFB4
L32
LSSN114
L33
LSSN115
00000001 : ld %f0
LSSN116
@syoyo
syoyo / gist:f98f95206c9418588645
Created June 25, 2015 12:14
new_exp on Epiphany.
00000610 <_new_exp>:
610: 200b 0002 mov r1,0x0
614: 200b 13c2 movt r1,0x3c00
618: 59ab 0cc2 mov r2,0xcccd
61c: 00a7 fmul r0,r0,r1
61e: 712b 0882 mov r3,0x8889
622: 610b 13d2 movt r3,0x3d08
626: 498b 13e2 movt r2,0x3e4c
62a: 200b 0002 mov r1,0x0
62e: 300b 13f2 movt r1,0x3f80