Category | programming

  1. Git Ignore File

    In some circumstances, we would like to ignore the files (or directories) under the Git repository base directory. How could we do this? For example, assume that we have a Git repository with following files:

    out/bin/conv
    preprocessed/out/gen-case1.h
    preprocessed/out/gen-case2.h
    preprocessed/input.txt
    conv …

    More

  2. C++11 Unique Pointer

    C++11 introduced three new smart pointer class templates: std::unique_ptr, std::shared_ptr, and std::weak_ptr. These smart pointer class templates are designed to replace the old std::auto_ptr smart pointer, which is known to have some defect and deprecated now. In this post, I would like to give a …

    More

  3. C++ std::multimap and Equal Range

    Today I have encountered a problem: Given that there are multiple equivalent keys in an instance of std::multimap, how could we list all of the corresponding values? For example:

    #include <map>
    #include <iostream>
    
    int main() {
      std::multimap<int, int> xs;
      xs.insert(std::make_pair(1, 12));
      xs.insert(std …

    More

  4. Count Trailing Zeros

    How to count the number of trailing zeros of an integer? The simplest way is to use the built-in function __builtin_ctz():

    uint64_t count(uint64_t n) {
      return __builtin_ctz(n);
    }
    

    What will happen if we don't have __builtin_ctz()? If we have another built-in function __popcount(), which can compute the Hamming weight (the …

    More

  5. C++ Virtual Destructor and Inheritence

    It is a well-known idiom to define a virtual destructor for the classes with virtual functions. If we don't define a virtual destructor, then the base class destructor will be invoked when you are deleting the object through the base class pointer even if the object is an instance of …

    More

  6. LLVM Bugpoint

    In this post, I would like to introduce the bugpoint command line tool. This is a automatic test case reduction tool which can help us generate minimal test case.

    As a compiler developer, the first step to debug is to create a minimal test case which can still reproduce the …

    More

  7. Vim Vundle

    In the past, I didn't like to install the Vim plug-ins or new syntax highlight because all of the files were messed up in the .vim directory which makes it difficult to uninstall a plug-in.

    Recently, I have come across with Vim Vundle. It is a vim plug-in manager which …

    More

  8. Pre-compile the OpenCL Kernel Program - Part 2

    In the part 1 of this article, we have mentioned how to pre-compile the OpenCL kernel program and load the pre-compiled binaries with the OpenCL API.

    However, I was using the ioc64 command from the Intel OpenCL SDK to pre-compile the kernel program. This command might be unavailable in the …

    More

« Prev Page 4 / 5 Next »