Skip to content
Open
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
19 changes: 14 additions & 5 deletions .github/workflows/github-pr-unix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ jobs:
-DCMAKE_INSTALL_PREFIX="${GITHUB_WORKSPACE}"/install-kokkos
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DKokkos_ENABLE_${{ matrix.backend }}=ON
-DKokkos_ENABLE_SERIAL=ON
-DKokkos_ENABLE_COMPILER_WARNINGS=ON

- name: Build & Install Kokkos
Expand All @@ -76,11 +78,18 @@ jobs:
run: cmake --build "${GITHUB_WORKSPACE}"/build-kokkos-kernels --config ${{ matrix.build_type }} --parallel 2 --target install

- name: Configure and Build Exercises
run: >
bash "${GITHUB_WORKSPACE}"/kokkos-tutorials/Scripts/ci-configure-build-test.sh
"${GITHUB_WORKSPACE}"/install-kokkos/lib/cmake/Kokkos
"${GITHUB_WORKSPACE}"/install-kokkos-kernels
"${GITHUB_WORKSPACE}"/kokkos-tutorials
${{ matrix.cpp_compiler}}
${{ matrix.build_type}}
${{ matrix.backend }}

- name: Run Solutions
run: |
bash "${GITHUB_WORKSPACE}"/kokkos-tutorials/Scripts/ci-configure-build-test.sh \
"${GITHUB_WORKSPACE}"/install-kokkos/lib/cmake/Kokkos \
"${GITHUB_WORKSPACE}"/install-kokkos-kernels \
bash "${GITHUB_WORKSPACE}"/kokkos-tutorials/Scripts/ci-run-solutions.sh \
"${GITHUB_WORKSPACE}"/kokkos-tutorials \
${{ matrix.cpp_compiler}} \
${{ matrix.build_type}} \
${{ matrix.backend }}

17 changes: 2 additions & 15 deletions Exercises/04/Solution/exercise_4_solution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,8 @@ int main( int argc, char* argv[] )
Kokkos::initialize( argc, argv );
{

#ifdef KOKKOS_ENABLE_CUDA
#define MemSpace Kokkos::CudaSpace
#endif
#ifdef KOKKOS_ENABLE_HIP
#define MemSpace Kokkos::Experimental::HIPSpace
#endif
#ifdef KOKKOS_ENABLE_OPENMPTARGET
#define MemSpace Kokkos::OpenMPTargetSpace
#endif

#ifndef MemSpace
#define MemSpace Kokkos::HostSpace
#endif

using ExecSpace = MemSpace::execution_space;
using ExecSpace = Kokkos::DefaultExecutionSpace;
using MemSpace = ExecSpace::memory_space;
using range_policy = Kokkos::RangePolicy<ExecSpace>;

// Allocate y, x vectors and Matrix A on device.
Expand Down
38 changes: 29 additions & 9 deletions Exercises/random_number/Begin/MC_DartSampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,28 @@ struct GenRandom {
// 1) cycle on the sample size and compare pi vs sample size.
// 2) integer bit-size variation (64 vs 1024).

void checkSizes(int& N, int& dart_groups);

int main(int argc, char* args[]) {

if ( argc < 2 ) {
printf("RNG Example: Need at least one argument (number darts) to run; second optional argument for serial_iterations\n");
return (-1);
int N = -1; // Number of darts, 2^N
int dart_groups = -1; // Number of darts to draw per thread

if ( argc > 1 ) {
N = std::atoi(args[1]);
printf("User N is %d\n", N);
}
if ( argc > 2 ) {
dart_groups = std::atoi(args[2]);
printf("User dart_groups is %d\n", dart_groups);
}

checkSizes(N, dart_groups);

Kokkos::initialize(argc,args);
{
const double rad = 1.0; // target radius (also box size)
const long N = atoi(args[1]); // exponent used to create number of darts, 2^N

const long dart_groups = argc > 2 ? atoi(args[2]) : 1 ;

const long darts = std::pow(2,N); // number of dart throws
const double rad = 1.0; // target radius (also box size)
const long darts = std::pow(2,N); // number of dart throws

const double pi = 3.14159265358979323846 ;
printf( "Reference Value for pi: %lf\n",pi);
Expand All @@ -194,3 +200,17 @@ int main(int argc, char* args[]) {
return 0;
}

void checkSizes(int& N, int& dart_groups)
{
if ( N == -1 && dart_groups == -1 ) {
printf("RNG Example Options:\n");
printf(" <int> : Number of darts 2^N (default: 2^22)\n");
printf(" <int> : Number of darts to draw per thread (default: 1)\n");
}
if ( N == -1 ) {
N = 22;
}
if ( dart_groups == -1 ) {
dart_groups = 1;
}
}
44 changes: 32 additions & 12 deletions Exercises/random_number/Solution/MC_DartSampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,22 +143,28 @@ struct GenRandom {
// 1) cycle on the sample size and compare pi vs sample size.
// 2) integer bit-size variation (64 vs 1024).

void checkSizes(int& N, int& dart_groups);

int main(int argc, char* args[]) {

if ( argc < 2 ) {
printf("RNG Example: Need at least one argument (number darts) to run; second optional argument for serial_iterations\n");
return (-1);
int N = -1; // Number of darts, 2^N
int dart_groups = -1; // Number of darts to draw per thread

if ( argc > 1 ) {
N = std::atoi(args[1]);
printf("User N is %d\n", N);
}
if ( argc > 2 ) {
dart_groups = std::atoi(args[2]);
printf("User dart_groups is %d\n", dart_groups);
}

checkSizes(N, dart_groups);

Kokkos::initialize(argc,args);
{
const double rad = 1.0; // target radius (also box size)
const long N = atoi(args[1]); // exponent used to create number of darts, 2^N

const long dart_groups = argc > 2 ? atoi(args[2]) : 1 ;

const long darts = std::pow(2,N); // number of dart throws
const double rad = 1.0; // target radius (also box size)
const long darts = std::pow(2,N); // number of dart throws

const double pi = 3.14159265358979323846 ;
printf( "Reference Value for pi: %lf\n",pi);
Expand All @@ -176,8 +182,22 @@ int main(int argc, char* args[]) {

printf( "darts = %ld hits = %ld pi est = %lf\n", darts, circHits, 4.0*double(circHits)/double(darts) );
}
Kokkos::finalize();

return 0;
Kokkos::finalize();
return 0;
}

void checkSizes(int& N, int& dart_groups)
{
if ( N == -1 && dart_groups == -1 ) {
printf("RNG Example Options:\n");
printf(" <int> : Number of darts 2^N (default: 2^22)\n");
printf(" <int> : Number of darts to draw per thread (default: 1)\n");
}
if ( N == -1 ) {
N = 22;
}
if ( dart_groups == -1 ) {
dart_groups = 1;
}
}
6 changes: 0 additions & 6 deletions Exercises/simd_warp/Begin/CMakeLists.txt

This file was deleted.

122 changes: 0 additions & 122 deletions Exercises/simd_warp/Begin/simd_warp_begin.cpp

This file was deleted.

6 changes: 0 additions & 6 deletions Exercises/simd_warp/Solution/CMakeLists.txt

This file was deleted.

Loading
Loading