Skip to content

Instantly share code, notes, and snippets.

View shibatch's full-sized avatar
🙂

Naoki Shibata shibatch

🙂
  • Kyoto, Japan
View GitHub Profile
@shibatch
shibatch / sha512.c
Created March 25, 2023 07:12
Public domain SHA-512 implementation
// This is a public domain implementation of SHA-512.
// Based on the SHA-256 implementation at https://github.com/983/SHA-256.
#include <stddef.h>
#include <stdint.h>
#define SHA512_HEX_SIZE (128 + 1)
#define SHA512_BYTES_SIZE 64
typedef struct sha512 {
#ifndef __FAST_MATH__
#define sin Sleef_sin_u10
#define sinf Sleef_sinf_u10
#define cos Sleef_cos_u10
#define cosf Sleef_cosf_u10
#define tan Sleef_tan_u10
#define tanf Sleef_tanf_u10
#define asin Sleef_asin_u10
#define asinf Sleef_asinf_u10
#define acos Sleef_acos_u10
@shibatch
shibatch / bfloat16test.c
Created October 18, 2020 13:32
Half precision function prototype
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <x86intrin.h>
__m256i ftoh256h(__m256i l, __m256i h) {
__m256i rl = _mm256_shuffle_epi8(l, (__m256i) { 0x0d0c090805040100l, -1l, 0x0d0c090805040100l, -1l });
rl = _mm256_permute4x64_epi64(rl, (0 << 0) | (2 << 2) | (1 << 4) | (3 << 6));
__m256i rh = _mm256_shuffle_epi8(h, (__m256i) { 0x0d0c090805040100l, -1l, 0x0d0c090805040100l, -1l });
rh = _mm256_permute4x64_epi64(rh, (1 << 0) | (3 << 2) | (0 << 4) | (2 << 6));
@shibatch
shibatch / index.php
Last active February 23, 2020 02:12 — forked from vsoch/index.php
Unlike the original script, the generated RSS feed can be used for podcasting. This script generates RSS feed for files in a directory folder. Put this file in a folder with files, modify the $allowed_ext variable to customize your extensions, and $feedName, $feedDesc, $feedURL, and $feedBaseURL. Then navigate to the folder on the web to see the…
<?php
header('Content-type: text/xml');
/*
Based on https://gist.github.com/vsoch/4898025919365bf23b6f
The generated feed can be used for podcasting.
Runs from a directory containing files to provide an
RSS feed that contains the list and modification times for all the
files.
*/
@shibatch
shibatch / ph.c
Created December 16, 2019 05:08
Explanatory source code for the modified Payne Hanek reduction http://dx.doi.org/10.1109/TPDS.2019.2960333
// Explanatory source code for the modified Payne Hanek reduction
// http://dx.doi.org/10.1109/TPDS.2019.2960333
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <mpfr.h>
typedef struct { double x, y; } double2;
double2 dd(double d) { double2 r = { d, 0 }; return r; }
@shibatch
shibatch / boot-netinst.sh
Created May 3, 2019 07:42
Script for installing debian on QEMU
#!/bin/bash
set -e
image_size_g=64
cdimage_file=mini.iso
image_file=qemu_ppc64le.img
dd if=/dev/zero of=$image_file bs=1 count=0 seek=$((image_size_g * 1024 ** 3))
mkfs.ext4 -F $image_file
qemu-img convert -O qcow2 $image_file $image_file.qcow2 && rm -f $image_file
qemu-system-ppc64 -M cap-htm=off -m 8G -smp cores=4,threads=1 -nographic -nodefaults -monitor pty -serial stdio -netdev user,id=n1 -device e1000,netdev=n1 -hda $image_file.qcow2 -cdrom $cdimage_file -boot d
@shibatch
shibatch / sleefvml_test.cpp
Created January 6, 2019 06:00
Prototype of SleefVML
#include "sleef.h"
#define INLINE inline
// Below is a part of helperavx2.h
#define VECTLENDP 4
#define VECTLENSP 8
typedef __m256i vmask;
@shibatch
shibatch / collectwallpaper.sh
Created July 25, 2018 17:18
Cygwin shell script for automatically collecting Windows spotlight wallpapers
#!/usr/bin/bash
PATH=/bin:/usr/bin:$PATH
LASTDATE=INIT
while true; do
CURDATE=`date +'%D'`
if [ "$CURDATE" != "$LASTDATE" ]
then
for i in `cygpath $USERPROFILE`/AppData/Local/Packages/Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy/LocalState/Assets/*; do
if [ "`file $i | perl -pe 's|.* ([0-9]+x[0-9]+),.*|\1|'`" = 1920x1080 ]
then