Sign inSign up

harmsmits/libtester

By harmsmits

•Updated over 6 years ago

Image
0

872

harmsmits/libtester repository overview

⁠Libasm-ish

This is my personal library I use for projects at Codam.

⁠Docker

  • Running an interactive development environment bound to the ... directory: docker run -it -v ...:/home harmsmits/libtester /bin/bash

⁠Registers

Registers Credits to wikipedia⁠.

⁠Branch prediction

#define likely(x)      __builtin_expect(!!(x), 1)
#define unlikely(x)    __builtin_expect(!!(x), 0)

An example:

const char *home_dir ;

home_dir = getenv("HOME");
if (likely(home_dir))
    printf("home directory: %s\n", home_dir);
else
    perror("getenv");

For above example, we have marked “if” condition as “likely()” true, so compiler will put true code immediately after branch, and false code within the branch instruction. In this way compiler can achieve optimization. But we won't use likely() and unlikely() macros blindly. If prediction is correct, it means there is zero cycle of jump instruction, but if prediction is wrong, then it will take several cycles, because the processor will need to flush it’s pipeline which is worst than no prediction.

⁠Sources

Tag summary

Content type

Image

Digest

Size

173.8 MB

Last updated

over 6 years ago

docker pull harmsmits/libtester