Skip to content

Instantly share code, notes, and snippets.

gnzlbg gnzlbg

Block or report user

Report or block gnzlbg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:b282db61d37e305b7ca153d41f179f7c
name old ns/iter new ns/iter diff ns/iter diff % speedup
acos 3 2 -1 -33.33% x 1.50
acosf 2 3 1 50.00% x 0.67
acosh 114 132 18 15.79% x 0.86
acoshf 48 52 4 8.33% x 0.92
asin 2 4 2 100.00% x 0.50
asinf 2 3 1 50.00% x 0.67
atan 13 15 2 15.38% x 0.87
atan2 23 22 -1 -4.35% x 1.05
atan2f 11 15 4 36.36% x 0.73
View gist:06893e29c14692fd9ff869a7bf210315
[error]: Function "erf" not `extern "C"`
[error]: Function "erfc" not `extern "C"`
[error]: Function "floor" not `extern "C"`
[error]: Function "exp2f" not `extern "C"`
[error]: Function "fmaxf" not `extern "C"`
[error]: Function "fdimf" not `extern "C"`
[error]: Function "fmodf" not `extern "C"`
[error]: Function "ldexp" not `extern "C"`
[error]: Function "modf" not `extern "C"`
[error]: Function "modf" missing `#[inline]` and `#[no_panic]` attributes
View regex bench
name old ns/iter new ns/iter diff ns/iter diff % speedup
misc::anchored_literal_long_match 32 (12187 MB/s) 29 (13448 MB/s) -3 -9.38% x 1.10
misc::anchored_literal_long_non_match 35 (11142 MB/s) 35 (11142 MB/s) 0 0.00% x 1.00
misc::anchored_literal_short_match 32 (812 MB/s) 29 (896 MB/s) -3 -9.38% x 1.10
misc::anchored_literal_short_non_match 32 (812 MB/s) 35 (742 MB/s) 3 9.38% x 0.91
misc::easy0_1K 40 (26275 MB/s) 39 (26948 MB/s) -1 -2.50% x 1.03
misc::easy0_1MB 62 (16912951 MB/s) 66 (15887924 MB/s) 4 6.45% x 0.94
misc::easy0_32 40 (1475 MB/s) 43 (1372 MB/s) 3 7.50% x 0.93
misc::easy0_32K 40 (819875 MB/s)
@gnzlbg
gnzlbg / volatile_arch.md
Last active Jun 28, 2019
Volatile arch
View volatile_arch.md

Add the following intrinsics to core::arch::x86_64:

/// (Module documentation)
///
/// Semantics of volatile memory operations: volatile memory operations (reads and writes)
/// must be emitted by the compiler and cannot be re-ordered across other volatile operations.
/// 
/// The result of a volatile read is frozen (`freeze` is applied to it). That is,
/// reading uninitialized memory via a volatile read never returns uninitialized memory. 
@gnzlbg
gnzlbg / bfloat16.md
Last active Apr 25, 2019
concerns bfloat16
View bfloat16.md

Add f16b floating-point type for native support of bfloat16

I was asked to properly write my “concerns” here, so these are my concerns in the most constructive way I found to phrase them.

  • concern: llvm-bfloat16

This text claims that LLVM will add a native type for bfloa16. The claim is not supported in the text (e.g. no links to mailing list threads of people working or discussing this). The text should either support the claim or justify the native type in a universe where that never happens.

  • concern: unspecified-abi-issues
@gnzlbg
gnzlbg / pointer_place.md
Created Mar 18, 2019
RFC for directly creating a pointer to a place
View pointer_place.md

Summary

There is currently no way to create a raw pointer to a place. This pre-RFC adds support for it to the language.

Motivation

Verbosity of FFI code dealing with raw pointers

A lot of Rust FFI code reads:

View build_plan.json
{
"invocations": [
{
"package_name": "libc",
"package_version": "0.2.48",
"target_kind": [
"custom-build"
],
"kind": "Host",
"deps": [],
View summary.md

So @eddyb and me talked about this, and this comment summarizes that.

@eddyb proposes a bench_input function with the operational semantics of the identity function, that the optimizer is encouraged / hinted to treat as an unknown pure function (think extern { const fn bench_input<T>(T) -> T; }).

That is, the statement bench_input(expr); can be completely optimized away. Given:

let mut v = Vec::with_capacity(1);
v.push(1);
let v = bench_input(v); 
@gnzlbg
gnzlbg / packed_simd_wrapping_div.md
Last active Feb 8, 2019
Issue while implementing wrapping_div_unchecked in packed_simd
View packed_simd_wrapping_div.md

I have one example from packed_simd, where I want to implement vertical (lane-wise) division for packed SIMD vectors (repr(simd)). The Intel SVML (Short-Vector Math Library) exposes these with the _mm_div_ep{i,u}{lane_bitwidth} APIs.

I've implemented two functions for integers:

impl Simd<[T; N]> where T: Signed | Unsigned {
    pub fn wrapping_div(self, other: Self) -> Self {
        assert!(!other.eq(Self::splat(0)).any(),
                     "division by zero: `{:?} / {:?}`", self, other);
        unsafe { intrinsic::wrapping_div(self, other) }
View setlongjmp_draft.md

Proposal:

Add setjmp and longjmp with the following semantics:

pub type JmpBuf = <implementation-defined>;

/// Saves the current execution context into `env`. If `longjmp(env, val)` is used 
/// to restore execution at this call site, this function returns `val`. Otherwise, 
/// it returns `0`. 
You can’t perform that action at this time.