(draft; work in progress)
See also:
- Compilers
- Program analysis:
- Dynamic analysis - instrumentation, translation, sanitizers
(draft; work in progress)
See also:
#!/usr/bin/env python | |
# allows print() behavior as in python3 | |
from __future__ import print_function | |
# required for assembly | |
from keystone import * | |
# required for emulation | |
from unicorn import * | |
from unicorn.x86_const import * |
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
In C++20 we will hopefully get bit_cast see the proposal and reference implementation. This utility should give us a simple and safe way to type pun.
The one issue I ran into with this utility is that is requires the size of the To and From type to be the same, as well as checking that To and From types are trivially copyable. The static_assert version of the check is as follows:
# define BIT_CAST_STATIC_ASSERTS(TO, FROM) do { \
static_assert(sizeof(TO) == sizeof(FROM)); \
static_assert(std::is_trivially_copyable<TO>::value); \
static_assert(std::is_trivially_copyable<FROM>::value); \
} while (false)
#!/bin/sh | |
sudo apt-get install cpufrequtils | |
echo 'GOVERNOR="powersave"' | sudo tee /etc/defaults/cpufrequtils | |
sudo /etc/init.d/cpufrequtils restart | |
cpufreq-info |
Picked these from here
Command | Note |
---|---|
Ctrl + a | go to the start of the command line |
Ctrl + e | go to the end of the command line |
Ctrl + k | delete from cursor to the end of the command line |
These commands are based on a askubuntu answer http://askubuntu.com/a/581497 | |
To install gcc-6 (gcc-6.1.1), I had to do more stuff as shown below. | |
USE THOSE COMMANDS AT YOUR OWN RISK. I SHALL NOT BE RESPONSIBLE FOR ANYTHING. | |
ABSOLUTELY NO WARRANTY. | |
If you are still reading let's carry on with the code. | |
sudo apt-get update && \ | |
sudo apt-get install build-essential software-properties-common -y && \ | |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \ |
# This is the CMakeCache file. | |
# For build in directory: /home/shauren/projects/TrinityCore/build | |
# It was generated by CMake: /usr/bin/cmake | |
# You can edit this file to change values found and used by cmake. | |
# If you do not want to change any of the values, simply exit the editor. | |
# If you do want to change a value, simply edit, save, and exit the editor. | |
# The syntax for the file is as follows: | |
# KEY:TYPE=VALUE | |
# KEY is the name of a variable in the cache. | |
# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT TYPE!. |
In general, check the crt/host_config.h
file to find out which versions are supported.
Sometimes it is possible to hack the requirements there to get some newer versions working, too :)
Thrust version can be found in $CUDA_ROOT/include/thrust/version.h
.
Download Archives: https://developer.nvidia.com/cuda-toolkit-archive
Release notes for CUDA Toolkit (CTK):
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |