# Author: shaovoon

• ### Intel Should Implement Conditional SIMD

Auto-vectorizer can be a great help in vectorizing simple instructions with SIMD instruction calls. int a[COUNT]; int b[COUNT]; int c[COUNT]; for(int i=0; i<COUNT; ++i) { a[i] = b[i] + c[i]; } But a simple conditional check is enough to break the auto-vectorizer. for(int i=0; i<COUNT; ++i) { // a conditional check breaks the auto-vectorizer if(b[i] […]

• ### C++: Quick and Dirty Log Extraction and Replay

New Text Stream library is hosted at Github. Log Extraction Hackers can stay infiltrated and undetected up to 200 days! Nowadays, hackers do not even bother to cover their tracks because most logs are not checked for unusual activities. This tip-trick is to help to change all that with the New Text Stream library. Unfortunately, […]

• ### C++17: Benchmark of Singular Min/Max and Iterator Versions

The benchmark code is hosted at GitHub. In this tip, we’ll benchmark native operator with singular min()/max() and iterator versions like min_element()/max_element(). Lastly, we benchmark the combined operations with minmax_element(). This is the benchmark code. const size_t MAX_LOOP = (argc == 2) ? atoi(argv[1]) : 1000; using int_type = uint64_t; std::vector vec(1000000); std::iota(vec.begin(), vec.end(), 1); […]

• ### C#: Never Test For NaN With Equality Test

Let's write a simple program to test. To get a NaN, we do a 0/0 and store it in num. First of all, the divisor has to be a float-point type because DivideByZeroException shall be thrown for integer or decimal zero divisor. Note: Non-zero number divided by zero (float) gives an infinity number. In our […]

• ### Shh…Your interviewer didn’t have the answers to his technical questions!

Advice for suitable type of technical question to ask in an interview   Write code to sum up from 1 to 100 One has to especially careful when the question is deceptively simple, for instance, sum up all the numbers from 1 to 100. A simple summing loop wouldn’t suffice to satisfy your interviewer. He […]

• ### No Code is the Fastest Code

Optimization of finding a point with shortest distance w.r.t. a point of interest The benchmark source code is hosted at Github. Table of Contents Introduction Shortest Distance Benchmark Results History Introduction When it comes to optimization, majority of developers turn to parallelism but per CPU core isn’t cheap. We could look to eliminate some operations […]

• ### C++14/20 Heterogeneous Lookup Benchmark

Download the benchmark code on GitHub. C++14 introduced ordered transparency lookup which enables const char* and string_view lookup without string instantiation on map/set objects. C++20 introduced unordered transparency lookup that allows to do same thing with unordered_map/unordered_set. We are officially in 2020 but as of writing time, the C++20 Standard is yet to be ratified […]

• ### Succinct Guide to Floating-Point Format For C++ and C# Programmers

Floating-Point Dissector is available for download at GitHub. Table of Contents Introduction Floating-Point Dissector Common Misconceptions Floating-Point Conversion to Integer 32-Bit Floating-Point Format Zero Subnormal (Underflow) Subnormal are much slower on Intel processor Infinity (Overflow) Not a Number Summary Chart Floating-Point Exception Equality Test Other Types References Introduction The IEEE 754 standard for floating-point format […]

• ### Lee Algorithm Mazesolver in Direct2D

Table of Contents Introduction Lee Algorithm for Mazesolving Important Notes Direct2D Code References History Introduction In 1999, my team won Obstacle Avoidance Robot(OAR) first prize in the Singapore Robotics Games(SRG). That was 20 years ago. I do not have a photo of OAR, but it looks very much like micromouse. The micromouse maze is constructed […]

• ### C# 7: ref returns and locals

Table of Contents Introduction ref-return on Value Member Benchmark Conclusion Reference History Introduction C# 7 introduced ref-local and ref-return functionality to allow safe direct-memory access to value variables. Before C# 7, we could do it in an unsafe code but now is available to access in a safe way. This is an example of ref-local […]