Skip to content

Instantly share code, notes, and snippets.

View gnzlbg's full-sized avatar

gnzlbg gnzlbg

View GitHub Profile
@gnzlbg
gnzlbg / bfloat16.md
Last active April 25, 2019 13:34
concerns bfloat16

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 March 18, 2019 18:19
RFC for directly creating a pointer to a place

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:

@gnzlbg
gnzlbg / build_plan.json
Created February 27, 2019 09:22
build_plan json
{
"invocations": [
{
"package_name": "libc",
"package_version": "0.2.48",
"target_kind": [
"custom-build"
],
"kind": "Host",
"deps": [],
@gnzlbg
gnzlbg / summary.md
Last active February 19, 2019 16:56

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 February 8, 2019 11:17
Issue while implementing wrapping_div_unchecked in packed_simd

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) }

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`. 
[2018-12-28T12:21:14Z DEBUG bindgen] Trying to find clang with flags: ["-D__SSE2__"]
[2018-12-28T12:21:17Z DEBUG bindgen] Found clang: Clang { path: "/usr/bin/clang", version: Some(CXVersion { Major: 10, Minor: 0, Subminor: 0 }), c_search_paths: Some(["/usr/local/include", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.0/include", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include", "/usr/include", "/System/Library/Frameworks", "/Library/Frameworks"]), cpp_search_paths: Some(["/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1", "/usr/local/include", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.0/include", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include", "/usr/include", "/System/Library/Frameworks", "/Library/Frameworks"]) }
[2018-12-28T12:21:17Z DEBUG bindgen] Fixed-up opti
@gnzlbg
gnzlbg / log.txt
Created December 13, 2018 13:51
log macosx
This file has been truncated, but you can view the full file.
Timestamp Thread Type Activity PID TTL
2018-12-13 14:46:34.198610+0100 0x293 Default 0x0 91 0 diskarbitrationd: [com.apple.DiskArbitration.diskarbitrationd:default] <private>
2018-12-13 14:46:34.198692+0100 0x293 Default 0x0 91 0 diskarbitrationd: [com.apple.DiskArbitration.diskarbitrationd:default] <private>
2018-12-13 14:46:34.198778+0100 0x293 Default 0x0 91 0 diskarbitrationd: [com.apple.DiskArbitration.diskarbitrationd:default] <private>
2018-12-13 14:46:34.206097+0100 0x293 Default 0x0 91 0 diskarbitrationd: [com.apple.DiskArbitration.diskarbitrationd:default] <private>
2018-12-13 14:46:36.082382+0100 0xdea6 Activity 0xe80f 107 0 locationd: CL: kCLConnectionMessageWatchdog
This file has been truncated, but you can view the full file.
Timestamp Thread Type Activity PID TTL
2018-12-13 14:46:34.198610+0100 0x293 Default 0x0 91 0 diskarbitrationd: [com.apple.DiskArbitration.diskarbitrationd:default] <private>
2018-12-13 14:46:34.198692+0100 0x293 Default 0x0 91 0 diskarbitrationd: [com.apple.DiskArbitration.diskarbitrationd:default] <private>
2018-12-13 14:46:34.198778+0100 0x293 Default 0x0 91 0 diskarbitrationd: [com.apple.DiskArbitration.diskarbitrationd:default] <private>
2018-12-13 14:46:34.206097+0100 0x293 Default 0x0 91 0 diskarbitrationd: [com.apple.DiskArbitration.diskarbitrationd:default] <private>
2018-12-13 14:46:36.082382+0100 0xdea6 Activity 0xe80f 107 0 locationd: CL: kCLConnectionMessageWatchdog
This file has been truncated, but you can view the full file.
Timestamp Thread Type Activity PID TTL
2018-12-13 14:46:34.198610+0100 0x293 Default 0x0 91 0 diskarbitrationd: [com.apple.DiskArbitration.diskarbitrationd:default] <private>
2018-12-13 14:46:34.198692+0100 0x293 Default 0x0 91 0 diskarbitrationd: [com.apple.DiskArbitration.diskarbitrationd:default] <private>
2018-12-13 14:46:34.198778+0100 0x293 Default 0x0 91 0 diskarbitrationd: [com.apple.DiskArbitration.diskarbitrationd:default] <private>
2018-12-13 14:46:34.206097+0100 0x293 Default 0x0 91 0 diskarbitrationd: [com.apple.DiskArbitration.diskarbitrationd:default] <private>
2018-12-13 14:46:36.082382+0100 0xdea6 Activity 0xe80f 107 0 locationd: CL: kCLConnectionMessageWatchdog