Skip to content

Instantly share code, notes, and snippets.

View degski's full-sized avatar
💭
stop watching us

degski

💭
stop watching us
View GitHub Profile
@degski
degski / invertible_hash_functions.hpp
Last active May 6, 2024 13:29
invertible hash functions
// MIT License
//
// Copyright (c) 2018 degski
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
@degski
degski / shift_rotate_avx2.cpp
Last active October 14, 2023 22:57
lane-crossing shift and rotate instructions in AVX2
// MIT License
//
// Copyright (c) 2018 degski
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
#include <cassert>
#include <cinttypes>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cstring>
#include <iomanip>
#include <iostream>
// prfchwintrin.h
/*===---- prfchwintrin.h - PREFETCHW intrinsic -----------------------------===
*
* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
* See https://llvm.org/LICENSE.txt for license information.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*
*===-----------------------------------------------------------------------===
*/
@degski
degski / compile_mimalloc.cmd
Last active September 29, 2020 09:13
Compile mimalloc with clang/llvm, both with and without thin-lto, both standard and secure.
:: MIT License
::
:: Copyright (c) 2019, 2020 degski
::
:: Permission is hereby granted, free of charge, to any person obtaining a copy
:: of this software and associated documentation files (the "Software"), to deal
:: in the Software without restriction, including without limitation the rights
:: to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
:: copies of the Software, and to permit persons to whom the Software is
/************************************************************************
http://www.incompleteideas.net/
http://www.incompleteideas.net/td-backprop-pseudo-code.text
Nonlinear TD/Backprop pseudo C-code
Written by Allen Bonde Jr. and Rich Sutton in April 1992.
// https://morestina.net/blog/1400/minimalistic-blocking-bounded-queue-for-c
template<typename T>
class queue {
std::deque<T> content;
size_t capacity;
std::mutex mutex;
std::condition_variable not_empty;
std::condition_variable not_full;
@degski
degski / mimalloc.h
Last active July 4, 2019 07:24
Auto-linking various library builds
// MIT License
//
// Copyright (c) 2019 degski
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
@degski
degski / main.cpp
Created June 14, 2019 06:03
Vose Alias Method - discrete_distribution
// MIT License
//
// Copyright (c) 2019 degski
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
@degski
degski / bug.cpp
Created May 6, 2019 15:10
Clang bug 38102
// MIT License
//
// Copyright (c) 2019 degski
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is