Skip to content

Commit

Permalink
add dot wiki example
Browse files Browse the repository at this point in the history
Signed-off-by: Carl Pearson <[email protected]>
  • Loading branch information
cwpearson committed Dec 17, 2024
1 parent e4827e5 commit c6d6ccb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions example/wiki/blas/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ KOKKOSKERNELS_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})

KOKKOSKERNELS_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../../test_common)

KOKKOSKERNELS_ADD_EXECUTABLE_AND_TEST(
wiki_blas1_dot
SOURCES KokkosBlas1_wiki_dot.cpp
)

KOKKOSKERNELS_ADD_EXECUTABLE_AND_TEST(
wiki_blas1_iamax
SOURCES KokkosBlas1_wiki_iamax.cpp
Expand Down
24 changes: 24 additions & 0 deletions example/wiki/blas/KokkosBlas1_wiki_dot.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <iostream>
#include <Kokkos_Core.hpp>
#include <KokkosBlas1_dot.hpp>

int main(int argc, char* argv[]) {
Kokkos::initialize();
{
int N = 100;
if (argc >= 2) {
N = atoi(argv[1]);
}

Kokkos::View<double*> x("X", N);
Kokkos::View<double*> y("Y", N);
Kokkos::deep_copy(x, 3.0);
Kokkos::deep_copy(y, 2.0);

double x_y = KokkosBlas::dot(x, y);

std::cout << "X_dot_Y: " << x_y << " Expected: " << 1.0 * N * (3.0 * 2.0)
<< " Diff: " << x_y - 1.0 * N * (3.0 * 2.0) << std::endl;
}
Kokkos::finalize();
}

0 comments on commit c6d6ccb

Please sign in to comment.