Skip to content

Instantly share code, notes, and snippets.

View alexgpg's full-sized avatar

Alexander Popov alexgpg

View GitHub Profile
@alexgpg
alexgpg / Dockerfile
Last active June 13, 2022 21:33
Docker image for test google benchmark fix (#1340) and PR(#1410)
FROM ubuntu:14.04
RUN apt-get update
RUN apt-get -y install software-properties-common git llvm-3.9-tools wget \
libssl-dev build-essential
# Install GCC 5
RUN add-apt-repository ppa:ubuntu-toolchain-r/test
RUN apt-get update
RUN apt-get -y install gcc-5 g++-5
@alexgpg
alexgpg / README.md
Last active May 8, 2022 01:07
Possible bug: GCC does extra data copy for asm volatile with no code

Possible bug: GCC does extra data copy(memcpy) for asm volatile with no code

It's a page to find out is it a bug in GCC or not. The question is this a bug or some expected behaviour?

TL;DR GCC do extra unnecessary copy(with memcpy call) if asm volatile("" : "+m,r"(value) : : "memory"); is used and value is a large object. It's important for NotNotOptimize() function in Google Benchmark (see the bug)

@alexgpg
alexgpg / Makefile
Last active February 4, 2022 18:00
benchmark::DoNotOptimize() GCC vs clang
.PHONY: all build bench.bin run
all: build run
build: bench.bin
run:
./bench.bin
bench.bin: main.cc
@alexgpg
alexgpg / test.md
Last active April 18, 2020 20:17
it's a blog test

It's a test. But post will be soon.

How *it* works.

How it works. line 2

@alexgpg
alexgpg / o2o3.diff
Created November 1, 2018 13:48
git diff /tmp/o2 /tmp/o3 > /tmp/o2o3.diff
iff --git a/tmp/o2 b/tmp/o3
index 8208721..fa628ed 100644
--- a/tmp/o2
+++ b/tmp/o3
@@ -38,7 +38,7 @@ The following options control optimizations:
-ffloat-store [disabled]
-fforward-propagate [enabled]
-fgcse [enabled]
- -fgcse-after-reload [disabled]
+ -fgcse-after-reload [enabled]
@alexgpg
alexgpg / typesafe.cc
Last active July 31, 2017 09:37
type safe long
struct safe_long {
template<typename T> safe_long(T val_);
explicit operator long() { return val; }
long val;
};
template<> safe_long::safe_long(long val_) : val(val_) {}
@alexgpg
alexgpg / cdplayer.sh
Created November 12, 2015 00:59
Play CD
cdparanoia -p -q -Z -S 2 -- 1 - | mplayer -rawaudio samplesize=2:channels=2:rate=44100:format=0x10001 -demuxer rawaudio - -cache 8096
// "License": Public Domain
// I, Mathias Panzenböck, place this file hereby into the public domain. Use it at your own risk for whatever you like.
// In case there are jurisdictions that don't support putting things in the public domain you can also consider it to
// be "dual licensed" under the BSD, MIT and Apache licenses, if you want to. This code is trivial anyway. Consider it
// an example on how to get the endian conversion functions on different platforms.
#ifndef PORTABLE_ENDIAN_H__
#define PORTABLE_ENDIAN_H__
#if (defined(_WIN16) || defined(_WIN32) || defined(_WIN64)) && !defined(__WINDOWS__)
[3] pry(main)> [1,2,3][(0..234)]
=> [1, 2, 3]
[4] pry(main)> [1,2,3][(1..234)]
=> [2, 3]
[5] pry(main)> [1,2,3][(2..234)]
=> [3]
[6] pry(main)> [1,2,3][(3..234)]
=> []
[7] pry(main)> [1,2,3][(4..234)]
=> nil
open import Level
open import Data.List
open import Data.Sum
open import Relation.Binary
module InsertionSort {ℓ ℓ₁ ℓ₂} (totalOrder : TotalOrder ℓ ℓ₁ ℓ₂) where
open TotalOrder totalOrder renaming (Carrier to A)
open IsTotalOrder isTotalOrder renaming (trans to ≤-trans; total to _≤?_)