Skip to content

cuBLAS の高速化のため GPU 常駐メモリモデルとバッファ再利用を導入する #16

Description

@SanaeProject

現状の問題

現在、BLAS を使用する各演算で以下の処理が毎回行われている:

  • cudaMalloc / cudaFree を毎回実行
  • Host ↔ Device の memcpy を毎回実行
  • cublasCreate / cublasDestroy を毎回実行

このため、AXPY や SCAL などの軽量演算ではオーバーヘッドが支配的になり、
BLAS を使った方が遅くなる状況が発生している。

改善方針

以下の最適化を行い、cuBLAS の性能を最大限引き出す:

  • ベクトル・行列を GPU メモリ上に常駐させる
  • 必要なときだけ upload() / download() を行う
  • cudaMalloc を繰り返さないためのバッファ再利用
  • cuBLAS ハンドルを static 化して再利用

期待される効果

  • AXPY / SCAL / Hadamard などの軽量演算が 10〜300 倍高速化
  • メモリ断片化の減少
  • API がより GPU フレンドリーになる
  • cuBLAS の性能が理論値に近づく

タスク

  • GpuVector / GpuMatrix クラスの実装
  • upload() / download() の追加
  • バッファ再利用機構の追加
  • static cuBLAS ハンドルの導入
  • Add/Sub/ScalarMul を GPU 常駐版に書き換え
  • GEMM を GPU 常駐行列に対応させる

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions