Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

polygeistのコードベースを確認する #46

Open
yukarinoki opened this issue Oct 15, 2024 · 9 comments
Open

polygeistのコードベースを確認する #46

yukarinoki opened this issue Oct 15, 2024 · 9 comments

Comments

@yukarinoki
Copy link
Owner

確認するコミット

https://github.com/llvm/Polygeist/tree/cgo24

Retargetingのcommitによって確認する。

@yukarinoki
Copy link
Owner Author

polygeist側にはほぼ編集がない
llvm/Polygeist@main...cgo24

llvm側に編集があるのだろうか??

@yukarinoki
Copy link
Owner Author

@yukarinoki
Copy link
Owner Author

うーむ、これだという編集が見えないな。
gpu-kernel-emit-coarsened-alternativesで調べる。

@yukarinoki
Copy link
Owner Author

以下のpull requestが、cgo24の主要なコミットである。

以下のpull requestも気になる。pluto-optでしょうか。

@yukarinoki
Copy link
Owner Author

以下の論文をもう一回見てみよう!

@yukarinoki
Copy link
Owner Author

yukarinoki commented Nov 17, 2024

Polygeistのパイプラインは、図1のように4つのコンポーネントで構成されています:

  1. フロントエンド:CまたはC++コードからSCFループレベルでMLIRに入ることを可能にします(セクションIII-A)。
  2. 前処理ステップ:MLIR内でアフィンダイアレクトに引き上げます(セクションIII-B)。
  3. 多面体スケジューラ:OpenSCoPへの往復を介してプログラムのアフィン部分を処理し、新しい文分割ヒューリスティックによって制御されるPluto変換を実行します(セクションIII-CおよびIII-D)。
  4. バックエンド:ポストプロセッシングのMLIR最適化を実行し、最終的に実行可能ファイルにロワリングします(セクションIII-E)。

image

@yukarinoki
Copy link
Owner Author

以下の論文が大事である

https://inria.hal.science/hal-04711965/

@yukarinoki
Copy link
Owner Author

やるべきこと

  1. affine MLIRが出力されることを確認する
    行列積がいいかな

  2. GPUのIRを出力するための方法を探る。

@yukarinoki
Copy link
Owner Author

yukarinoki commented Nov 28, 2024

include/polygeist/Passes/Passes.h

変換パスが書いてある

std::unique_ptr<Pass>
createConvertParallelToGPUPass1(std::string arch = "sm_60");
std::unique_ptr<Pass>
createConvertParallelToGPUPass2(bool emitGPUKernelLaunchBounds = true);

include/polygest/Passes/Passes.td

TableGenで書かれた、Passの定義集
Parallel To GPUのpassはivanが書いてくれている

だから、僕はaffine to parallelを書いたら良いのだろうか???
まあ

lib/polygeist/Ops.cpp

ここにOpの変換の定義と、Opのクラスのコンストラクタ(ファクトリ?)が書いてある。

ivanが書いてあるのは、AlternativeOpに対する、FlattenAlternativesという変換がある。多分、Threadとかblockとかの調節をやっているのかもしれない

lib/polygeist/Passes/CMakeLists.txt

ここにpass関連のビルド定義が書いてある。

if(POLYGEIST_ENABLE_CUDA)
  find_package(CUDA)
  enable_language(CUDA)

  # Enable gpu-to-cubin pass.
  target_compile_definitions(obj.MLIRPolygeistTransforms
    PRIVATE
    POLYGEIST_ENABLE_CUDA=1
  )

  # Add CUDA headers includes and the libcuda.so library.
  target_include_directories(obj.MLIRPolygeistTransforms
    PRIVATE
    ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}
  )

  find_library(CUDA_DRIVER_LIBRARY cuda)

  target_link_libraries(MLIRPolygeistTransforms
    PRIVATE
    ${CUDA_DRIVER_LIBRARY}
  )

endif()

tools/cgeist/driver.cc

ここら辺に動かし方が書いてある
これが重要な気がするなぁ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant