Skip to content

Instantly share code, notes, and snippets.

View kaityo256's full-sized avatar
🤖
I, Robot

Hiroshi Watanabe kaityo256

🤖
I, Robot
  • Keio University
  • Japan
View GitHub Profile
@kaityo256
kaityo256 / sstest.cc
Created November 6, 2015 06:19
benchmark for std::stringstream
//----------------------------------------------------------------------
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <random>
#include <sys/time.h>
//----------------------------------------------------------------------
std::uniform_int_distribution<> rand9(0, 9);
const int TRIAL = 500000;
@kaityo256
kaityo256 / sstest2.cc
Created November 6, 2015 08:58
benchmark for std::stringstream
//----------------------------------------------------------------------
#include <iostream>
#include <string>
#include <stdlib.h>
#include <sstream>
#include <vector>
#include <sys/time.h>
//----------------------------------------------------------------------
const int TRIAL = 500000;
const int LEN = 100;
@kaityo256
kaityo256 / diag.rb
Created November 10, 2015 07:34
clangの警告オプション一覧表示スクリプト ref: http://qiita.com/kaityo256/items/a2ea1474973cd938c50c
list = Array.new
str = ""
while line=gets
next if line=~/^\s*\/\//
next if line.chomp.strip == ""
str = str + line.chomp.strip
if line=~/\;/
list.push str
str = ""
@kaityo256
kaityo256 / modelname.cc
Created March 24, 2016 09:54
puts modelname of cpu with cpuid
//------------------------------------------------------------------------
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdarg.h>
//------------------------------------------------------------------------
void
cpuid(uint32_t v, uint32_t &a, uint32_t &b, uint32_t &c, uint32_t &d){
uint32_t eax, ebx, ecx, edx;
asm("nop" :: "a" (v));
$ cd public_html
$ ruby linkchecker.rb
/path/to/public_html/foo.html is isolated.
/path/to/public_html/bar.html is isolated.
@kaityo256
kaityo256 / show_mnist.py
Created October 11, 2016 10:21
MNISTのデータを可視化するサンプル
import chainer
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--number', '-n', type=int, default=0, help='')
args = parser.parse_args()
n = args.number
train, test = chainer.datasets.get_mnist()
s = 28
print test[n][1]
@kaityo256
kaityo256 / export.py
Created October 17, 2016 10:10
Chainerで学習したモデルをC++で読み込む ref: http://qiita.com/kaityo256/items/f1e2c8e38cbf8ffd8c09
from __future__ import print_function
import struct
import numpy as np
import chainer
import chainer.functions as F
import chainer.links as L
from chainer import training
from chainer.training import extensions
# Network definition
@kaityo256
kaityo256 / test.cpp
Last active October 18, 2016 01:18
LJの力計算を組み込み関数で書いて馬鹿SIMD化 ref: http://qiita.com/kaityo256/items/bf10fdb0f90809e3d2bf
//------------------------------------------------------------------------
#include <immintrin.h>
#include <stdio.h>
//------------------------------------------------------------------------
enum {X, Y, Z};
const int N = 20000;
const double dt = 0.01;
double __attribute__((aligned(32))) q[N][4] = {};
double __attribute__((aligned(32))) p[N][4] = {};
double __attribute__((aligned(32))) c24[4] = {24 * dt, 24 * dt, 24 * dt, 24 * dt};
@kaityo256
kaityo256 / pack.cpp
Last active June 6, 2019 09:54
pack data using AVX-512
/*
# Copyright H. Watanabe 2017
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
*/
//------------------------------------------------------------------------
#include <x86intrin.h>
#include <immintrin.h>
#include <iostream>
@kaityo256
kaityo256 / test.cpp
Created February 27, 2017 03:21
Sample code using vpternlogd (AVX-512)
/*
# Copyright H. Watanabe 2017
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
*/
//------------------------------------------------------------------------
#include <immintrin.h>
#include <iostream>
#include <stdio.h>