Notes for C family, like C++, Objective-C, ISPC, NVCC.
2025-05-11 | #Words: 3884
I previously mentioned planning to abandon ISPC in favor of C++—ISPC evolves too quickly, and its documentation is poor, making it hard to keep up. Additionally, recent C++ standards have added solid support for official SIMD libraries, eliminating the need for third-party tools like ISPC. While ISPC still offers the best performance, I can no longer keep pace with its updates. However, you could pin to a specific ISPC version for development, as CPU instruction set updates are relatively slow.
2025-05-07 | #Words: 1878
Microsoft’s official C/C++ extension for VS Code offers features like syntax highlighting, library recognition, and—most importantly for this article—code formatting. Code formatting automatically adjusts your code to follow a specific standard, making it easier to read. In many large projects, formatting code to meet project standards is required before submission (though some projects use custom formatters, which we won’t discuss here).
2025-03-14 | #Words: 1119
This method is less universal than the ones in my previous post, but it drastically reduces code volume (*way* less code).
2025-03-13 | #Words: 914
I’ve been using ISPC on macOS for a while, but it’s limited by the small number of cores/threads. Recently, I wanted to switch to Ubuntu, but the snap-installed ISPC only ran on a single core for some reason. To fix this, I decided to compile ISPC from source—this requires Clang and LLVM. However, Ubuntu has a quirk: many software versions are tied to the system version, and the default installed LLVM/Clang is version 14, which may lack necessary components. I had no choice but to tackle this, and took the opportunity to study their compilation and usage.
2024-04-22 | #Words: 3758
This article is primarily an experimental exploration and intellectual exercise—a preliminary attempt to study implementations of time measurement and the use of inline assembly and assembly functions in C/C++. Unless you have specific use cases, do not use assembly instructions to implement this functionality. The Further Reading section lists alternative methods that do not require inline assembly.
2024-04-15 | #Words: 850
This article only covers native (Microsoft-provided) time measurement functions on Windows. Third-party high-precision time measurement libraries are not discussed here.
2024-04-15 | #Words: 1038
2023-11-27 | #Words: 1235
This article serves as a complete summary of measuring the execution time of functions or features in C/C++. At the end, we’ll demonstrate a comparison of three methods.
2023-06-08 | #Words: 3210
Recently, I suddenly discovered something when I was learning about clang/llvm: `gcc` is a collection of tools that includes or calls all tools that convert source code into executable program, not just a simple compiler. This helped me gain a deeper understanding of compilers, so I wrote this article as a record.
2023-05-16 | #Words: 2545
I just want to try to see whether is the case. I think the central limit theorem (CLT) and normal distribution are a very magical part of probability theory. I will use dice points as discrete events to calculate the probability of the sum of points. First, Implementing the program to simulate a uniformly distribute. Second, adjusting the probability of non-uniform distribution.
2023-05-12 | #Words: 967
In C language, there is a variable called union, which is used to store objects of different types and sizes in different situations. This is very similar to a struct: a struct is a collection of one or more variables. The declaration method of union is very simple and exactly the same as struct, as follows
2023-05-03 | #Words: 492
When using nvcc in the command line today, an error helper_cuda.h: No such file or directory appeared. This error message means: During compilation, the helper_cuda.h header file cannot be found (if other xxx.h cannot be found, the following explanations and solutions are also common).
2023-04-26 | #Words: 1293
typedef is a special feature in the C language, which is used to create new type names. You also can know from the name type def(ine). typedef is similar to alias program in Unix, which adds another name to an object. typedef also makes multiple names actually correspond to same objext, but the object of typedef operation is a data type. It is to give a nickname to the data type. This nickname usually has the first letter capitalized and is used to indicate that it is not an underlying data type.
2023-04-19 | #Words: 1005
enum is abbreviation of enumerate. It is a type of constant in C language, called enumeration constant. enum provides a convenient way to associate values and names, and it is an alternative to #define. enum can be regarded as a special array, which is a list of constants, but this constant just be integer. So if there are only a few irrelevant and discontinuous constants, just define some constants directly is fine.