Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
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
15 changes: 9 additions & 6 deletions src/targets/gpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ else()
set(MIGRAPHX_USE_HIPRTC ON CACHE BOOL "Use hipRTC APIs")
endif()

file(GLOB KERNEL_FILES CONFIGURE_DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/kernels/include/migraphx/kernels/*.hpp)
file(GLOB_RECURSE KERNEL_FILES CONFIGURE_DEPENDS LIST_DIRECTORIES false
${CMAKE_CURRENT_SOURCE_DIR}/kernels/include/*.hpp
)

if(NOT MIGRAPHX_USE_COMPOSABLEKERNEL)
list(REMOVE_ITEM KERNEL_FILES
Expand Down Expand Up @@ -124,15 +125,17 @@ endif()

add_library(migraphx_gpu_kernel_file_check EXCLUDE_FROM_ALL)

set(CK_TIDY_SKIP_KERNEL_FILES "ck" "ck_gemm" "ck_gemm_softmax_gemm")
set(CK_TIDY_SKIP_KERNEL_FILES ck ck_gemm ck_gemm_softmax_gemm)
foreach(KERNEL_FILE ${KERNEL_FILES})
get_filename_component(KERNEL_BASE_FILE ${KERNEL_FILE} NAME_WE)
file(RELATIVE_PATH KERNEL_FILE_REL ${CMAKE_CURRENT_SOURCE_DIR}/kernels/include/ ${KERNEL_FILE})
get_filename_component(KERNEL_BASE_FILE ${KERNEL_FILE_REL} NAME_WE)
get_filename_component(KERNEL_DIR ${KERNEL_FILE_REL} DIRECTORY)
# Temporary workaround for tidy issue that arises from the fact that CK no longer exposes headers to the host code
if(${KERNEL_BASE_FILE} IN_LIST CK_TIDY_SKIP_KERNEL_FILES)
continue()
endif()
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/kernels/include/migraphx/kernels/${KERNEL_BASE_FILE}.cpp "#include <migraphx/kernels/${KERNEL_BASE_FILE}.hpp>\n")
target_sources(migraphx_gpu_kernel_file_check PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/kernels/include/migraphx/kernels/${KERNEL_BASE_FILE}.cpp)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/kernels/include/${KERNEL_DIR}/${KERNEL_BASE_FILE}.cpp "#include <${KERNEL_DIR}/${KERNEL_BASE_FILE}.hpp>\n")
target_sources(migraphx_gpu_kernel_file_check PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/kernels/include/${KERNEL_DIR}/${KERNEL_BASE_FILE}.cpp)
endforeach()

target_link_libraries(migraphx_gpu_kernel_file_check compile_migraphx_gpu_kernels)
Expand Down
8 changes: 8 additions & 0 deletions src/targets/gpu/kernels/include/migraphx/kernels/test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,14 @@ struct test_manager
__device__ [[maybe_unused]] static void __VA_ARGS__( \
[[maybe_unused]] migraphx::test::test_manager& migraphx_private_test_manager)

// NOLINTNEXTLINE
#define TEST_CASE_TEMPLATE(...) \
__device__ [[maybe_unused]] static void __VA_ARGS__( \
[[maybe_unused]] migraphx::test::test_manager& migraphx_private_test_manager)

// NOLINTNEXTLINE
#define TEST_CASE_REGISTER(...)

} // namespace test
} // namespace migraphx
#endif // MIGRAPHX_GUARD_KERNELS_TEST_HPP
31 changes: 31 additions & 0 deletions src/targets/gpu/kernels/include/rocm/algorithm.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef ROCM_GUARD_ROCM_ALGORITHM_HPP
#define ROCM_GUARD_ROCM_ALGORITHM_HPP

Check warning on line 2 in src/targets/gpu/kernels/include/rocm/algorithm.hpp

View workflow job for this annotation

GitHub Actions / cppcheck

style: Macros must be prefixed with MIGRAPHX_ [definePrefix]

#include <rocm/algorithm/iter_swap.hpp>
#include <rocm/algorithm/fill.hpp>
#include <rocm/algorithm/accumulate.hpp>
#include <rocm/algorithm/copy.hpp>
#include <rocm/algorithm/copy_if.hpp>
#include <rocm/algorithm/transform.hpp>
#include <rocm/algorithm/is_sorted_until.hpp>
#include <rocm/algorithm/is_sorted.hpp>
#include <rocm/algorithm/for_each.hpp>
#include <rocm/algorithm/find_if.hpp>
#include <rocm/algorithm/find.hpp>
#include <rocm/algorithm/any_of.hpp>
#include <rocm/algorithm/none_of.hpp>
#include <rocm/algorithm/all_of.hpp>
#include <rocm/algorithm/search.hpp>
#include <rocm/algorithm/inner_product.hpp>
#include <rocm/algorithm/equal.hpp>
#include <rocm/algorithm/iota.hpp>
#include <rocm/algorithm/min_element.hpp>
#include <rocm/algorithm/max_element.hpp>
#include <rocm/algorithm/rotate.hpp>
#include <rocm/algorithm/upper_bound.hpp>
#include <rocm/algorithm/lower_bound.hpp>
#include <rocm/algorithm/sort.hpp>
#include <rocm/algorithm/stable_sort.hpp>
#include <rocm/algorithm/merge.hpp>

#endif // ROCM_GUARD_ROCM_ALGORITHM_HPP
27 changes: 27 additions & 0 deletions src/targets/gpu/kernels/include/rocm/algorithm/accumulate.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef ROCM_GUARD_ROCM_ALGORITHM_ACCUMULATE_HPP
#define ROCM_GUARD_ROCM_ALGORITHM_ACCUMULATE_HPP

Check warning on line 2 in src/targets/gpu/kernels/include/rocm/algorithm/accumulate.hpp

View workflow job for this annotation

GitHub Actions / tidy

invalid case style for macro definition 'ROCM_GUARD_ROCM_ALGORITHM_ACCUMULATE_HPP' [readability-identifier-naming,-warnings-as-errors]

#include <rocm/config.hpp>

namespace rocm {
inline namespace ROCM_INLINE_NS {

template <class InputIt, class T, class BinaryOperation>
constexpr T accumulate(InputIt first, InputIt last, T init, BinaryOperation op)
{
for(; first != last; ++first)
{
init = op(static_cast<T&&>(init), *first);
}
return init;
}

template <class InputIt, class T>
constexpr T accumulate(InputIt first, InputIt last, T init)
{
return accumulate(first, last, init, [](auto x, auto y) { return x + y; });
}

} // namespace ROCM_INLINE_NS
} // namespace rocm
#endif // ROCM_GUARD_ROCM_ALGORITHM_ACCUMULATE_HPP
18 changes: 18 additions & 0 deletions src/targets/gpu/kernels/include/rocm/algorithm/all_of.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef ROCM_GUARD_ROCM_ALGORITHM_ALL_OF_HPP
#define ROCM_GUARD_ROCM_ALGORITHM_ALL_OF_HPP

Check warning on line 2 in src/targets/gpu/kernels/include/rocm/algorithm/all_of.hpp

View workflow job for this annotation

GitHub Actions / tidy

invalid case style for macro definition 'ROCM_GUARD_ROCM_ALGORITHM_ALL_OF_HPP' [readability-identifier-naming,-warnings-as-errors]

#include <rocm/config.hpp>
#include <rocm/algorithm/none_of.hpp>

namespace rocm {
inline namespace ROCM_INLINE_NS {

template <class InputIt, class UnaryPredicate>
constexpr bool all_of(InputIt first, InputIt last, UnaryPredicate p)
{
return none_of(first, last, [=](auto&& x) { return not p(x); });
}

} // namespace ROCM_INLINE_NS
} // namespace rocm
#endif // ROCM_GUARD_ROCM_ALGORITHM_ALL_OF_HPP
18 changes: 18 additions & 0 deletions src/targets/gpu/kernels/include/rocm/algorithm/any_of.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef ROCM_GUARD_ROCM_ALGORITHM_ANY_OF_HPP
#define ROCM_GUARD_ROCM_ALGORITHM_ANY_OF_HPP

Check warning on line 2 in src/targets/gpu/kernels/include/rocm/algorithm/any_of.hpp

View workflow job for this annotation

GitHub Actions / tidy

invalid case style for macro definition 'ROCM_GUARD_ROCM_ALGORITHM_ANY_OF_HPP' [readability-identifier-naming,-warnings-as-errors]

#include <rocm/config.hpp>
#include <rocm/algorithm/find_if.hpp>

namespace rocm {
inline namespace ROCM_INLINE_NS {

template <class InputIt, class UnaryPredicate>
constexpr bool any_of(InputIt first, InputIt last, UnaryPredicate p)
{
return find_if(first, last, p) != last;
}

} // namespace ROCM_INLINE_NS
} // namespace rocm
#endif // ROCM_GUARD_ROCM_ALGORITHM_ANY_OF_HPP
21 changes: 21 additions & 0 deletions src/targets/gpu/kernels/include/rocm/algorithm/copy.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef ROCM_GUARD_ROCM_ALGORITHM_COPY_HPP
#define ROCM_GUARD_ROCM_ALGORITHM_COPY_HPP

#include <rocm/config.hpp>

namespace rocm {
inline namespace ROCM_INLINE_NS {

template <class InputIt, class OutputIt>
constexpr OutputIt copy(InputIt first, InputIt last, OutputIt d_first)
{
while(first != last)
{
*d_first++ = *first++;
}
return d_first;
}

} // namespace ROCM_INLINE_NS
} // namespace rocm
#endif // ROCM_GUARD_ROCM_ALGORITHM_COPY_HPP
25 changes: 25 additions & 0 deletions src/targets/gpu/kernels/include/rocm/algorithm/copy_if.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef ROCM_GUARD_ROCM_ALGORITHM_COPY_IF_HPP
#define ROCM_GUARD_ROCM_ALGORITHM_COPY_IF_HPP

#include <rocm/config.hpp>

namespace rocm {
inline namespace ROCM_INLINE_NS {

template <class InputIt, class OutputIt, class UnaryPredicate>
constexpr OutputIt copy_if(InputIt first, InputIt last, OutputIt d_first, UnaryPredicate pred)
{
for(; first != last; ++first)
{
if(pred(*first))
{
*d_first = *first;
++d_first;
}
}
return d_first;
}

} // namespace ROCM_INLINE_NS
} // namespace rocm
#endif // ROCM_GUARD_ROCM_ALGORITHM_COPY_IF_HPP
28 changes: 28 additions & 0 deletions src/targets/gpu/kernels/include/rocm/algorithm/equal.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef ROCM_GUARD_ROCM_ALGORITHM_EQUAL_HPP
#define ROCM_GUARD_ROCM_ALGORITHM_EQUAL_HPP

#include <rocm/config.hpp>

namespace rocm {
inline namespace ROCM_INLINE_NS {

template <class Iterator1, class Iterator2, class BinaryPred>
constexpr bool equal(Iterator1 first1, Iterator1 last1, Iterator2 first2, BinaryPred p)
{
for(; first1 != last1; ++first1, ++first2)
if(not p(*first1, *first2))
{
return false;
}
return true;
}

template <class Iterator1, class Iterator2>
constexpr bool equal(Iterator1 first1, Iterator1 last1, Iterator2 first2)
{
return equal(first1, last1, first2, [](auto&& x, auto&& y) { return x == y; });
}

} // namespace ROCM_INLINE_NS
} // namespace rocm
#endif // ROCM_GUARD_ROCM_ALGORITHM_EQUAL_HPP
18 changes: 18 additions & 0 deletions src/targets/gpu/kernels/include/rocm/algorithm/fill.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef ROCM_GUARD_ROCM_ALGORITHM_FILL_HPP
#define ROCM_GUARD_ROCM_ALGORITHM_FILL_HPP

#include <rocm/config.hpp>

namespace rocm {
inline namespace ROCM_INLINE_NS {

template <class Iterator, class T>
constexpr void fill(Iterator first, Iterator last, const T& value)
{
for(; first != last; ++first)
*first = value;
}

} // namespace ROCM_INLINE_NS
} // namespace rocm
#endif // ROCM_GUARD_ROCM_ALGORITHM_FILL_HPP
18 changes: 18 additions & 0 deletions src/targets/gpu/kernels/include/rocm/algorithm/find.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef ROCM_GUARD_ROCM_ALGORITHM_FIND_HPP
#define ROCM_GUARD_ROCM_ALGORITHM_FIND_HPP

#include <rocm/config.hpp>
#include <rocm/algorithm/find_if.hpp>

namespace rocm {
inline namespace ROCM_INLINE_NS {

template <class Iterator, class T>
constexpr Iterator find(Iterator first, Iterator last, const T& value)
{
return find_if(first, last, [&](const auto& x) { return x == value; });
}

} // namespace ROCM_INLINE_NS
} // namespace rocm
#endif // ROCM_GUARD_ROCM_ALGORITHM_FIND_HPP
24 changes: 24 additions & 0 deletions src/targets/gpu/kernels/include/rocm/algorithm/find_if.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef ROCM_GUARD_ROCM_ALGORITHM_FIND_IF_HPP
#define ROCM_GUARD_ROCM_ALGORITHM_FIND_IF_HPP

Check warning on line 2 in src/targets/gpu/kernels/include/rocm/algorithm/find_if.hpp

View workflow job for this annotation

GitHub Actions / tidy

invalid case style for macro definition 'ROCM_GUARD_ROCM_ALGORITHM_FIND_IF_HPP' [readability-identifier-naming,-warnings-as-errors]

Check warning on line 2 in src/targets/gpu/kernels/include/rocm/algorithm/find_if.hpp

View workflow job for this annotation

GitHub Actions / tidy

invalid case style for macro definition 'ROCM_GUARD_ROCM_ALGORITHM_FIND_IF_HPP' [readability-identifier-naming,-warnings-as-errors]

#include <rocm/config.hpp>

namespace rocm {
inline namespace ROCM_INLINE_NS {

template <class Iterator, class Predicate>
constexpr Iterator find_if(Iterator first, Iterator last, Predicate p)
{
for(; first != last; ++first)
{
if(p(*first))
{
return first;
}
}
return last;
}

} // namespace ROCM_INLINE_NS
} // namespace rocm
#endif // ROCM_GUARD_ROCM_ALGORITHM_FIND_IF_HPP
21 changes: 21 additions & 0 deletions src/targets/gpu/kernels/include/rocm/algorithm/for_each.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef ROCM_GUARD_ROCM_ALGORITHM_FOR_EACH_HPP
#define ROCM_GUARD_ROCM_ALGORITHM_FOR_EACH_HPP

#include <rocm/config.hpp>

namespace rocm {
inline namespace ROCM_INLINE_NS {

template <class Iterator, class F>
constexpr F for_each(Iterator first, Iterator last, F f)
{
for(; first != last; ++first)
{
f(*first);
}
return f;
}

} // namespace ROCM_INLINE_NS
} // namespace rocm
#endif // ROCM_GUARD_ROCM_ALGORITHM_FOR_EACH_HPP
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#ifndef ROCM_GUARD_ROCM_ALGORITHM_INNER_PRODUCT_HPP
#define ROCM_GUARD_ROCM_ALGORITHM_INNER_PRODUCT_HPP

#include <rocm/config.hpp>

namespace rocm {
inline namespace ROCM_INLINE_NS {

template <class InputIt1, class InputIt2, class T, class BinaryOperation1, class BinaryOperation2>
constexpr T inner_product(InputIt1 first1,
InputIt1 last1,
InputIt2 first2,
T init,
BinaryOperation1 op1,
BinaryOperation2 op2)
{
while(first1 != last1)
{
init = op1(init, op2(*first1, *first2));
++first1;
++first2;
}
return init;
}

template <class InputIt1, class InputIt2, class T>
constexpr T inner_product(InputIt1 first1, InputIt1 last1, InputIt2 first2, T init)
{
return inner_product(
first1,
last1,
first2,
init,
[](auto x, auto y) { return x + y; },
[](auto x, auto y) { return x * y; });
}

} // namespace ROCM_INLINE_NS
} // namespace rocm
#endif // ROCM_GUARD_ROCM_ALGORITHM_INNER_PRODUCT_HPP
18 changes: 18 additions & 0 deletions src/targets/gpu/kernels/include/rocm/algorithm/iota.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef ROCM_GUARD_ROCM_ALGORITHM_IOTA_HPP
#define ROCM_GUARD_ROCM_ALGORITHM_IOTA_HPP

#include <rocm/config.hpp>

namespace rocm {
inline namespace ROCM_INLINE_NS {

template <class Iterator, class T>
constexpr void iota(Iterator first, Iterator last, T value)
{
for(; first != last; ++first, ++value)
*first = value;
}

} // namespace ROCM_INLINE_NS
} // namespace rocm
#endif // ROCM_GUARD_ROCM_ALGORITHM_IOTA_HPP
25 changes: 25 additions & 0 deletions src/targets/gpu/kernels/include/rocm/algorithm/is_sorted.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef ROCM_GUARD_ROCM_ALGORITHM_IS_SORTED_HPP
#define ROCM_GUARD_ROCM_ALGORITHM_IS_SORTED_HPP

#include <rocm/config.hpp>
#include <rocm/functional/operations.hpp>
#include <rocm/algorithm/is_sorted_until.hpp>

namespace rocm {
inline namespace ROCM_INLINE_NS {

template <class Iterator, class Compare>
constexpr bool is_sorted(Iterator first, Iterator last, Compare comp)
{
return is_sorted_until(first, last, comp) == last;
}

template <class Iterator>
constexpr bool is_sorted(Iterator first, Iterator last)
{
return is_sorted(first, last, less<>{});
}

} // namespace ROCM_INLINE_NS
} // namespace rocm
#endif // ROCM_GUARD_ROCM_ALGORITHM_IS_SORTED_HPP
Loading
Loading