- Compile the program in gcc with debug symbols enabled (
-g
) - Do NOT strip the binary
- To generate assembly code using gcc use the -S option:
gcc -S hello.c
编译 CUDA 程序的主要工具是 NVIDIA 提供的闭源编译器 NVCC,但实际上,NVCC 是基于 LLVM 开发的(来源:NVIDIA CUDA Compiler),NVIDIA 也把 NVCC 其中一部分逻辑贡献给了 LLVM 上游,使得 Clang 也可以在 CUDA 的配合下编译 CUDA 程序。这篇博客尝试研究 Clang/LLVM 如何实现 CUDA 程序的编译,主要是 Clang 前端部分,后端部分,也就是从 LLVM IR 到 NVPTX 的这一步还没有进行深入的研究。
https://www.cs.cmu.edu/afs/cs/academic/class/15418-s18/www/lectures/03_progmodels.pdf
Intel ISPC(Intel SPMD Program Compiler)是一个专注于单指令多数据(SIMD)并行的编程语言和编译器,基于 SPMD(Single Program Multiple Data)编程模型。ISPC 提供了高层次的抽象,允许开发者编写看似标量的代码,但在底层会自动向量化运行以实现并行执行。
以下是 ISPC 和 SPMD 编程模型的抽象示例:
Author: Chris Lattner
In C, function overloading (using the same function name for different types or parameter lists, as in C++) is not directly supported. However, you can achieve a similar effect using macro functions to redefine function names based on type information. This doesn't provide true overloading in the sense of type-safe interfaces, but it can mimic the behavior in some simple scenarios.
Here’s a common pattern using macros and _Generic
to simulate function overloading in C11 and later:
#include <stdio.h>
void print_int(int x) {
LLVM 内置类型(Builtin Types)是 LLVM 类型系统的基础。 这些类型被用来表示 LLVM 中支持的各种数据类型。 LLVM IR(Intermediate Representation)使用这些内置类型来定义和操作数据。下面是一些主要的 LLVM 内置类型:
iN
: 表示 N 位的整数类型,其中 N 可以是任意正整数。例如:i1
: 1 位整数类型(通常表示布尔值)i8
: 8 位整数类型(类似于 C 语言中的char
)i32
: 32 位整数类型(类似于 C 语言中的int
)
i64
: 64 位整数类型(类似于 C 语言中的long long
)