Skip to content

Instantly share code, notes, and snippets.

@taqu
taqu / fp16conversion.cpp
Last active September 20, 2020 09:34
32bit Float to 16 bit Float計測 ref: https://qiita.com/taqu/items/3de14e7d602c1f00df87
#include <immintrin.h>
#include <emmintrin.h>
#include <cstdint>
#include <cmath>
#include <chrono>
#include <random>
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
@taqu
taqu / AES-NI.cpp
Created September 20, 2020 09:55
AES256 codec with Intel's AES-NI
#include <assert.h>
#include <stdint.h>
#include <wmmintrin.h>
#ifdef BUILD_EXPORTS
#define DLL_EXPORT __declspec(dllexport)
#else
#define DLL_EXPORT
#endif
@taqu
taqu / chacha.cpp
Last active October 14, 2025 15:07
An encoder of the chiper ChaCha
#include <stdint.h>
#define ROTL(a,b) (((a)<<(b)) | ((a)>>(32-(b))))
#define QR(a,b,c,d) (\
a += b, d ^= a, d = ROTL(d,16),\
c += d, b ^= c, b = ROTL(b,12),\
a += b, d ^= a, d = ROTL(d, 8),\
c += d, b ^= c, b = ROTL(b, 7))
#ifdef __cplusplus
@taqu
taqu / inv_mt.cpp
Created May 6, 2022 18:17
The inversion of the Mersenne Twister
#include <random>
#include <iostream>
class mt_random
{
public:
static constexpr uint32_t N = 624;
static constexpr uint32_t M = 397;
static constexpr uint32_t MATRIX_A = 0x9908B0DFUL;
static constexpr uint32_t UPPER_MASK = 0x80000000UL;
#include <cstdint>
#include <cstring>
#include <iostream>
#include <fstream>
#include <vector>
using s8 = int8_t;
using s16 = int16_t;
using s32 = int32_t;
using s64 = int64_t;
cmake_minimum_required(VERSION 3.2)
set(CMAKE_CONFIGURATION_TYPES "Debug" "Release")
set(PROJECT_NAME Lua)
project(${PROJECT_NAME})
set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
########################################################################
@PACKAGE_INIT@
set_and_check(Lua_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@")
set_and_check(Lua_LIBRARY_DIR "@PACKAGE_LIBRARY_INSTALL_DIR@")
include("${CMAKE_CURRENT_LIST_DIR}/LuaTargets.cmake")
void Mul(uniform float R[3], uniform const float V[3], uniform const float X)
{
R[0] = V[0] * X;
R[1] = V[1] * X;
R[2] = V[2] * X;
}
float Dot(float X0, float Y0, float Z0, float X1, float Y1, float Z1)
{
/**
*/
#include "crater.h"
#include <cassert>
#ifdef _WIN32
# include <Windows.h>
#endif
#define LAVA_VK_EXPORTED_FUNCTION(NAME) PFN_##NAME NAME;
@taqu
taqu / mul128.c
Last active September 21, 2022 03:32
#include <stdint.h>
#include <stdio.h>
#if defined(__GNUC__) || defined(__clang__)
void mul(uint64_t* high, uint64_t* low, uint64_t x0, uint64_t x1)
{
unsigned __int128 r = (unsigned __int128)x0 * (unsigned __int128)x1;
*high = r>>64;
*low = (uint64_t)r;
}