Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ class KernelReshapeAndCacheFlashStrided {
}

__aicore__ inline void Process() {
#if defined(__CCE_AICORE__) && __CCE_AICORE__ == 200
AscendC::DataCacheCleanAndInvalid<int64_t,
AscendC::CacheLine::ENTIRE_DATA_CACHE>(
slot_mapping_);
#endif
auto local = copy_buffer_.Get<uint8_t>();
AscendC::DataCopyExtParams copy_params{
1, static_cast<uint32_t>(head_bytes_), 0, 0, 0};
Expand Down Expand Up @@ -79,6 +84,11 @@ class KernelReshapeAndCacheFlashStrided {
copy_params, pad_params);
}
}
#if defined(__CCE_AICORE__) && __CCE_AICORE__ == 200
AscendC::DataCacheCleanAndInvalid<uint8_t,
AscendC::CacheLine::ENTIRE_DATA_CACHE>(
key_cache_);
#endif
}

private:
Expand All @@ -88,10 +98,19 @@ class KernelReshapeAndCacheFlashStrided {
AscendC::LocalTensor<uint8_t>& local,
const AscendC::DataCopyExtParams& copy_params,
const AscendC::DataCopyPadExtParams<uint8_t>& pad_params) {
#if defined(__CCE_AICORE__) && __CCE_AICORE__ == 200
// DataCopyPad is unsupported on 310P's m200 cores. Scalar GM accesses
// preserve exact bytes even when padded head addresses are unaligned.
for (int64_t byte = 0; byte < head_bytes_; ++byte) {
destination.SetValue(destination_offset + byte,
source.GetValue(source_offset + byte));
}
#else
AscendC::DataCopyPad(local, source[source_offset], copy_params, pad_params);
AscendC::PipeBarrier<PIPE_ALL>();
AscendC::DataCopyPad(destination[destination_offset], local, copy_params);
AscendC::PipeBarrier<PIPE_ALL>();
#endif
}

AscendC::TPipe pipe_;
Expand Down
42 changes: 42 additions & 0 deletions src/native/ascend/error_.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#ifndef INFINI_OPS_ASCEND_ERROR__H_
#define INFINI_OPS_ASCEND_ERROR__H_

#include <cassert>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <memory>

#include "acl/acl.h"
#include "aclnn/acl_meta.h"

namespace infini::ops::ascend {

inline bool IsAscend310P() {
const auto* soc = aclrtGetSocName();
return soc != nullptr && std::strncmp(soc, "Ascend310P", 10) == 0;
}

inline void CheckAcl(int64_t status, const char* operation) {
#ifndef NDEBUG
if (status != ACL_SUCCESS) {
std::fprintf(stderr, "%s:%d: %s: `%s` failed with ACL status %lld.\n",
__FILE__, __LINE__, __func__, operation,
static_cast<long long>(status));
}
assert(status == ACL_SUCCESS && "`ACL` operation failed.");
#endif
(void)status;
(void)operation;
}

using AclTensorOwner = std::unique_ptr<aclTensor, decltype(&aclDestroyTensor)>;

inline AclTensorOwner OwnAclTensor(aclTensor* tensor) {
assert(tensor != nullptr && "`aclCreateTensor` failed.");
return AclTensorOwner(tensor, &aclDestroyTensor);
}

} // namespace infini::ops::ascend

#endif
Loading
Loading