Category | programming

  1. Pre-compile the OpenCL Kernel Program - Part 1

    In the previous post, we have written a simple vector addition OpenCL program. We were compiling the OpenCL kernel program from source code at run-time, thus we have to distribute the OpenCL source code to our users.

    However, in some cases, we may prefer to pre-compile the OpenCL kernel program …

    More

  2. C++ Private Inheritence and Using Directive

    I used to feel that the private inheritence is useless. Although we can implement the has-a semantics with private inheritence, it provides little benefits compared with object composition. Besides, in order to expose the privately inherited members to public, C++ introduced an awkward syntax, i.e. the using directives. These …

    More

  3. OpenCL 1.2 Manual Pages

    There is a package for OpenCL 1.2 manual pages in the Ubuntu repository. To install the opencl-1.2-man-doc package, please run this command:

    $ sudo apt-get install opencl-1.2-man-doc
    

    After installing this package, we can check the OpenCL API with man command. For example, run man 3 clGetPlatformIDs to read …

    More

  4. C++ std::list Operations

    To sort the doubly linked list std::list, we can simply call the sort() member function. For example,

    #include <iostream>
    #include <list>
    
    int main() {
      std::list<int> xs{5, 4, 3, 2, 1};
    
      xs.sort();  // Sort the std::list!
    
      for (auto &x : xs) {
        std::cout << x << std::endl;
      }
    }
    

    We can't …

    More

  5. C++ Associative Container and Iterator Validness

    I used to believe that iterators will be invalidated after calling the member functions insert() or erase() of containers. Thus, I would adopt a conservative approach:

    1. Create a temporary container.
    2. Copy the elements which I would like to keep to the temporary container.
    3. Swap the container.

    For example, to remove …

    More

  6. Git Merge Base and Checkout

    Today I have learned two different usages of git command. First, to list the least common ancestor of two refs, we may use following command:

    $ git merge-base --octopus <commit_1> <commit_2> ... <commit_n>
    

    Please notice that --octopus is mandatory; otherwise, git will create a hypothetical commit M, which merges commit_2 .. commit_n, and …

    More

  7. Soundness and Completeness of the Type System

    In the section 6 of Programming Languages course, Dan Grossman discussed about the soundness and the completeness of the type system. He said that:

    • A type-system is sound implies that all of type-checked programs are correct (in the other words, all of the incorrect program can't be type checked), i …

    More

« Prev Page 5 / 5