Function Simulator

The key class of function simulator is TopUnit. We can use TopUnit.CycleStep() to begin the execution of simulator.

In CycleStep(), we will call the Frontend() and Backend(), the former is used to update the many types of counters and the latter is used to execute instructions sequence.

In Backend(), we will call the following functions one by one

  • BackendCommit()
  • BackendMemory()
  • BackendExecute()
  • BackendSchedule()

Among all these functions, the third function BackendExecute() will execute all the instructions.

Heterogeneous Compilation

CUDA Compilation 不同在于

The tools used in the CUDA compilation are all closed source except gcc, g++ etc., for example fatbinary and nvlink. We need to substitue these tools to tools in clang system.

  1. Clang Offload Bundler is used to combined different code for different machine structurel.
  2. Clang Offload Packager is used to embed device code into host code.
  3. Clang Linker Wrapper is used to .

这里面最复杂的感觉是怎么处理链接关系,如果仅仅说代码嵌入,从 CUDA 的流程来看,在 cudafe1.cpp include stub.c 生成 .o 这一步中 host code 中就已经包含了 device code,如果仅仅说 embed 的话,这显然就已经完成了,但是为何 CUDA 还进行后续那么多步骤,因为这一步生成的 .o 显然是无法运行的,device code 都还只是一个 extern signal,还需要同 CUDA runtime library 进行链接,这个过程该怎么进行比较难想。

0%