• tvm 2019.12.21

- Tensor Core란 무엇인가? https://www.nvidia.com/en-us/data-center/tensorcore/
  . NVIDIA의 new Volta, Turing GPU Architecture에서 정의하는 feature인데, matrix multiplication이랑 convolution을 위한 거대한 boost를 주는 것임;
  . mixed-precision을 사용해서 accuracy 감소 없이 높은 thrroughput을 달성하게 해줌
  . Accelerate large matrix operations, perform mixed-precision matrix multiply and accumulate calculations in a single operation. = 대규모 매트릭트 연산 가속화, mixed-precision 매트릭스 곱 수행하고 단일 연산으로 계산 누적
  . Enables massive increases in throughput and efficiency = 하나의 NVIDIA GPU에서 병렬적으로 수행되는 수백개의 텐서코어 연산으로 처리량과 효율성을 크게 향상시킬 수 있음
  . TensorCore in TVM https://sampl.cs.washington.edu/tvmconf/slides/2019/L02-Siyuan-Feng.pdf
  . TensorCores는 Hardware accelerators이다.
  . Warp-level opration이다.
  . New memory scope fragment
  . WMMA : Warp-Level Matrix Multiply and Accumulate API (CUDA 9에서 소개)

전통적인 GPU schdule에서 global, shared, local memory scope를 가지고 있음.
https://docs.tvm.ai/tutorials/optimize/opt_conv_tensorcore.html
TensorCore를 원하기 위해서 3개의 특별한 메모리 스코프를 추가함 : wmma.matrix_a, wmma.matrix_bb, wmma.accumulator
하드웨어에서 모든 fragments scope는 온칩 레지스터 레벨에서 저장됨. 이거는 local memory와 동일함.

TensorCore는 특별한 하드웨어 오퍼레이션임. 그래서 TensorCore 명령어로 컴퓨터 유닛에 대체하기 위해서 tensorize를 사용할 수 있음. 먼저 Tensor intrinsic을 정의해야함.

TensorCore의 4개의 기본 operation : fill_fragment, load_matrix, mma_sync, store_matrix
fill_fragment랑 mma_sync는 둘다 매트릭스 곱셈에 사용되어짐.
그래서 샘플에서는 load, gemm, stora 이 세가지 intrinsic을 만듬! ir_builder로..

Warp-level operation이란?
TensorCore의 모든 명령어는 워프레벨 명령어입니다. 워프안에 모든 32개의 스레드 동시에 명령어를 해야합니다. threadidx.x = 32로 하는 것은 가장 쉬운 방법 중에 하나입니다. 그런 다음 threadldx.x를 직접 또는 간접적으로 TensorCore intrinsic이 포함된 루프를 제외한 모든 루프에 바인딩할 수있습니다. 이건 그냥 하나의 솔루션일 뿐 워프의 모든 스레드가 동시에 TensorCore를 호출할 수 있도록 해야한다.

Turing includes Tensor Cores, which are specialized hardware units designed for performing mixed precision matrix computations commonly used in deep learning neural network training and inference applications.

CUDA C++ makes Tensor Cores available via the Warp-Level Matrix Operations (WMMA) API. This API exposes specialized matrix load, matrix multiply and accumulate, and matrix store operations to efficiently use Tensor Cores from a CUDA-C++ program,

--------------------
https://docs.tvm.ai/tutorials/optimize/opt_matmul_auto_tensorcore.html
When the “tensor_core” pragma is set, the “rewrite for tensorcore” ir pass will automatically transform the schedule for tensorcore codegen, otherwise normal CUDA code, with lower performance but equal functionality, will be generated.

--------------- 
fireiron : 2018년부터해서 만들고 있다, 9개월정도 됨
GPU에서 linear algebra를 위한 고성능 도메인 스페시픽 랭귀지 DSL
Halid와 TVM을 기초로 계층적 스케쥴링 랭귀지
성능 최대를 위한 GPU 최적화를 표현하기 위해 디자인됨
Storage hierarchy(register, fragments, shared memory)와 compute hierarchy(threads, warps, blocks, kernels)의 요소들을 직접 표현할수 있다? 대신할 수 있다?
tensorcore와 machine level operation을 추론할 수 있다.
auto-scheduling과 auto-tuning에 적합하다.

matmul을 더 작은 부분으로 분해하기

'개발' 카테고리의 다른 글

Simple AMP: Zynq SoC Cortex-A9 Bare-MetalSystem with MicroBlaze Processor  (0) 2020.01.16
stack  (0) 2019.12.17
어셈블리어  (0) 2019.12.17
AArch64 generic timer  (0) 2019.12.09
plot graph color  (0) 2019.10.04

+ Recent posts