-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cell): Implement vectorized access for global to register copy. (#…
…30) * Implement vectorize copy from global to register. * Add Vectorize struct brief. * fix empty line. * fix inline function define.
- Loading branch information
Showing
4 changed files
with
122 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"gotoSymbolStack.currentStackPosition": 0, | ||
"gotoSymbolStack.maxStackPosition": 0, | ||
"gotoSymbolStack.filePositionInfo": [], | ||
"files.associations": { | ||
"*.tcc": "cpp", | ||
"optional": "cpp", | ||
"ratio": "cpp", | ||
"system_error": "cpp", | ||
"array": "cpp", | ||
"functional": "cpp", | ||
"tuple": "cpp", | ||
"type_traits": "cpp", | ||
"utility": "cpp", | ||
"variant": "cpp", | ||
"compare": "cpp", | ||
"concepts": "cpp", | ||
"random": "cpp" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#pragma once | ||
|
||
#include "config.hpp" | ||
#include "cuda_utils.hpp" | ||
|
||
#include <cutlass/half.h> | ||
|
||
namespace tilefusion::cell::copy { | ||
|
||
/** | ||
* @brief Vectorize a data type. | ||
* | ||
* @tparam Element Data type. | ||
* @tparam kVecNums Number of vecotrized elements. | ||
*/ | ||
template <typename Element, const int kVecNums> | ||
struct Vectorize { | ||
using UnVecType = Element; | ||
using VecType = Element; | ||
static constexpr int vectorize_nums = kVecNums; | ||
|
||
/** | ||
* @brief Copy data from unvectorized to vectorized. | ||
* | ||
* @param src Source data. | ||
* @param dst Destination data. | ||
*/ | ||
DEVICE void copy(const UnVecType* src, UnVecType* dst) { | ||
const VecType* src_vec = reinterpret_cast<const VecType*>(src); | ||
VecType* dst_vec = reinterpret_cast<VecType*>(dst); | ||
*dst_vec = *src_vec; | ||
} | ||
}; | ||
|
||
template <> | ||
struct Vectorize<__half, 2> { | ||
using UnVecType = __half; | ||
using VecType = __half2; | ||
static constexpr int vectorize_nums = 2; | ||
static constexpr int vectorize_bits = 32; | ||
|
||
DEVICE void copy(const __half* src, __half* dst) { | ||
const __half2* src_vec = reinterpret_cast<const __half2*>(src); | ||
__half2* dst_vec = reinterpret_cast<__half2*>(dst); | ||
*dst_vec = *src_vec; | ||
} | ||
}; | ||
|
||
template <> | ||
struct Vectorize<cutlass::half_t, 2> { | ||
using UnVecType = cutlass::half_t; | ||
using VecType = __half2; | ||
static constexpr int vectorize_nums = 2; | ||
static constexpr int vectorize_bits = 32; | ||
|
||
DEVICE void copy(const cutlass::half_t* src, cutlass::half_t* dst) { | ||
const __half2* src_vec = reinterpret_cast<const __half2*>(src); | ||
__half2* dst_vec = reinterpret_cast<__half2*>(dst); | ||
*dst_vec = *src_vec; | ||
} | ||
}; | ||
|
||
template <> | ||
struct Vectorize<float, 2> { | ||
using UnVecType = float; | ||
using VecType = float2; | ||
static constexpr int vectorize_nums = 2; | ||
static constexpr int vectorize_bits = 64; | ||
|
||
DEVICE void copy(const float* src, float* dst) { | ||
const float2* src_vec = reinterpret_cast<const float2*>(src); | ||
float2* dst_vec = reinterpret_cast<float2*>(dst); | ||
*dst_vec = *src_vec; | ||
} | ||
}; | ||
|
||
} // namespace tilefusion::cell::copy |