mirror of
https://github.com/ROCm/composable_kernel.git
synced 2026-06-28 18:56:59 +00:00
[ck] Enforce LF-only line endings in C/C++ sources
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
## Summary
Several CK source files carry Windows **CRLF** line endings (a trailing
carriage return on each line), introduced by editors configured for
Windows endings or copy/paste from Windows tooling. These are purely
cosmetic but they pollute diffs (whole-file churn the first time someone
makes an LF edit), confuse `clang-format`, and are inconsistent with the
LF-only convention used across the rest of the tree.
This PR (a) normalizes every existing CRLF file (6 files) to LF and (b)
adds a pre-checkin gate so new CRLF leaks are rejected before merge.
## File extensions covered
Both the cleanup scan and the new Jenkins enforcement stage use the same
predicate as the adjacent `ASCII Only Check` stage:
```
*.h *.hpp *.cpp *.h.in *.hpp.in *.cpp.in *.inc *.cl
```
(excluding `*/build/*` and `*/include/rapidjson/*`). The local
pre-commit hook's `c++/inc` type filter covers the same set.
## Why no enforcement today
CK is opted out of the rocm-libraries root `.pre-commit-config.yaml`, so
the existing `pre-commit` workflow doesn't touch CK. The local CK
`.pre-commit-config.yaml` only runs for developers who installed hooks.
The **authoritative gate is therefore the new Jenkins stage** in this
PR; the local hook is convenience.
## Commit layout (bisect-friendly)
1. `[ck] Normalize CRLF line endings to LF in C/C++ sources`
Mechanical line-ending cleanup across 6 files. No content change: every
edit is purely CRLF -> LF, verified with `git diff --ignore-cr-at-eol`
reporting an empty diff.
2. `[ck] Enforce LF-only line endings in C/C++ sources`
- New `projects/composablekernel/script/check_no_crlf.sh` (modeled on
`check_ascii_only.sh`).
- New `crlf-checker` entry in
`projects/composablekernel/.pre-commit-config.yaml` under the
local-hooks block (`types_or: [c++, inc]`).
- New `CRLF Check` parallel stage in
`projects/composablekernel/Jenkinsfile`'s `Static checks` block,
mirroring the adjacent `ASCII Only Check` stage. Always-on, no
`RUN_CPPCHECK` gate.
The tree is buildable at every commit boundary. Commit 1 leaves 0 CRLF
violations; commit 2 wires the gate.
## Demo
Script output on a synthesized violation:
```
$ printf 'int main() {}\r\n' > /tmp/bad.cpp
$ projects/composablekernel/script/check_no_crlf.sh /tmp/bad.cpp
ERROR: /tmp/bad.cpp contains CRLF (Windows) line endings:
1:int main() {}<CR>
Fix: convert to LF, e.g. 'sed -i 's/\r$//' /tmp/bad.cpp' or 'dos2unix /tmp/bad.cpp'
$ echo $?
1
```
Full repo scan after the cleanup commit:
```
$ cd projects/composablekernel && find . -type f \( -name '*.h' -o -name '*.hpp' -o -name '*.cpp' \
-o -name '*.h.in' -o -name '*.hpp.in' -o -name '*.cpp.in' -o -name '*.inc' -o -name '*.cl' \) \
-not -path '*/build/*' -not -path '*/include/rapidjson/*' -print0 \
| xargs -0 -P 8 -n 64 script/check_no_crlf.sh
$ echo $?
0
```
## Test plan
- [ ] Jenkins PR build: confirm new `Static checks -> CRLF Check` stage
runs green over the full predicate and the existing `ASCII Only Check` /
`Clang Format` stages are unaffected.
- [ ] Local: `pre-commit run crlf-checker --all-files` runs cleanly
after installing CK pre-commit hooks.
- [ ] Manually inject a CRLF line ending in any `.cpp/.hpp/.inc` file,
push: confirm Jenkins fails the new stage with a clear error.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
75 lines
2.4 KiB
C++
75 lines
2.4 KiB
C++
// Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#include "ck/ck.hpp"
|
|
#include "ck/host_utility/device_prop.hpp"
|
|
|
|
#include "prefetch_op_util.hpp"
|
|
|
|
template <typename T, uint32_t NUM_THREADS, uint32_t NUM_SCALARS, bool IS_L1_PREFETCH>
|
|
bool run_test(bool time_kernels)
|
|
{
|
|
bool pass = true;
|
|
|
|
#if defined(__gfx125__)
|
|
const auto coherence =
|
|
IS_L1_PREFETCH ? ck::AmdBufferCoherenceEnum::CU_RT : ck::AmdBufferCoherenceEnum::SE_RT;
|
|
using global_prefetch_op = ck::GlobalPrefetchDataOp<coherence>;
|
|
using flat_prefetch_op = ck::FlatPrefetchDataOp<coherence>;
|
|
#else
|
|
using global_prefetch_op = ck::GlobalPrefetchDataOp<>;
|
|
using flat_prefetch_op = ck::FlatPrefetchDataOp<>;
|
|
#endif
|
|
|
|
const auto global_prefetch_kernel =
|
|
ck::prefetch_op_util::kernel_with_prefetch<T, NUM_THREADS, NUM_SCALARS, global_prefetch_op>;
|
|
const auto flat_prefetch_kernel = ck::prefetch_op_util::
|
|
kernel_with_prefetch_and_shared_mem<T, NUM_THREADS, NUM_SCALARS, flat_prefetch_op>;
|
|
|
|
const auto prefetch_kernel_container =
|
|
std::make_tuple(global_prefetch_kernel, flat_prefetch_kernel);
|
|
|
|
ck::static_for<0, 2, 1>{}([&](auto i) {
|
|
std::string kernel_name = (i == 1 ? "flat_prefetch" : "global_prefetch");
|
|
|
|
auto kernel = std::get<ck::Number<i>{}>(prefetch_kernel_container);
|
|
|
|
pass &=
|
|
ck::prefetch_op_util::test_prefetch_impl<decltype(kernel), T, NUM_THREADS, NUM_SCALARS>(
|
|
time_kernels, kernel, kernel_name);
|
|
});
|
|
|
|
return pass;
|
|
}
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
if(!ck::is_gfx125_supported())
|
|
{
|
|
std::cout << "This feature is not supported by current HW, skipping tests." << std::endl;
|
|
return 0;
|
|
}
|
|
|
|
bool time_kernels = false;
|
|
|
|
if(argc == 2)
|
|
{
|
|
time_kernels = std::stoi(argv[1]);
|
|
}
|
|
|
|
bool pass = true;
|
|
|
|
std::cout << "=== Testing L2 Global Cache Prefetch ===" << std::endl;
|
|
|
|
pass &= run_test<float, 4096, 1024, false>(time_kernels);
|
|
pass &= run_test<double, 4096, 512, false>(time_kernels);
|
|
|
|
std::cout << "=== Testing L1 Global Cache Prefetch ===" << std::endl;
|
|
|
|
pass &= run_test<float, 4096, 1024, true>(time_kernels);
|
|
pass &= run_test<double, 4096, 512, true>(time_kernels);
|
|
|
|
std::cout << "TestGlobalPrefetch ..... " << (pass ? "SUCCESS" : "FAILURE") << std::endl;
|
|
return pass ? 0 : 1;
|
|
}
|