Skip to content

Instantly share code, notes, and snippets.

View amsharifian's full-sized avatar

Amirali Sharifian amsharifian

View GitHub Profile
Epic code example:
class BasicBlockNoMaskFastNode(BID: Int, val NumInputs: Int = 1, val NumOuts: Int)
(implicit val p: Parameters,
name: sourcecode.Name,
file: sourcecode.File)
extends Module with CoreParams with UniformPrintfs {
val io = IO(new BasicBlockNoMaskFastVecIO(NumInputs, NumOuts)(p))
@amsharifian
amsharifian / gist:2ced74227a5bfc1ad583486227b5c51d
Created January 29, 2019 17:04
mac-os: Using a home-built compiler leads to fatal error: 'stdio.h' file not found
I've found a way. If we are using Xcode 10, you will notice that if you navigate to the /usr in the Finder, you will not see a folder called 'include' any more, which is why the terminal complains of the absence of the header files which is contained inside the 'include' folder. In the Xcode 10.0 Release Notes, it says there is a package:
/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
and you should install that package to have the /usr/include folder installed. Then you should be good to go.
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
@amsharifian
amsharifian / WhatIsStrictAliasingAndWhyDoWeCare.md
Created October 31, 2018 01:12 — forked from shafik/WhatIsStrictAliasingAndWhyDoWeCare.md
What is Strict Aliasing and Why do we Care?

What is the Strict Aliasing Rule and Why do we care?

(OR Type Punning, Undefined Behavior and Alignment, Oh My!)

What is strict aliasing? First we will describe what is aliasing and then we can learn what being strict about it means.

In C and C++ aliasing has to do with what expression types we are allowed to access stored values through. In both C and C++ the standard specifies which expression types are allowed to alias which types. The compiler and optimizer are allowed to assume we follow the aliasing rules strictly, hence the term strict aliasing rule. If we attempt to access a value using a type not allowed it is classified as undefined behavior(UB). Once we have undefined behavior all bets are off, the results of our program are no longer reliable.

Unfortunately with strict aliasing violations, we will often obtain the results we expect, leaving the possibility the a future version of a compiler with a new optimization will break code we th