Skip to content

Commit

Permalink
Clean up pass for AWS tutorial (#25)
Browse files Browse the repository at this point in the history
* first clean up pass

* fix source file

* clean up pass

* clean up 4

* clean up pass

* clean up pass

* clean up 7

* clean up 8

* clean up 09

* clean up 10

* update 10 file

* clean up 11

* clean up pass

* fix twelve

* fix eight

* fixes for 08

* clean up pass

* clean up 5 and 6

* Update 06_raja_umpire_uvm_solution.cpp

* use global thread policies in examples
  • Loading branch information
artv3 authored Aug 12, 2024
1 parent dc4866e commit 484c8d2
Show file tree
Hide file tree
Showing 44 changed files with 67 additions and 68 deletions.
File renamed without changes.
4 changes: 2 additions & 2 deletions Intro_Tutorial/lessons/01_blt_cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
blt_add_executable(
NAME one
SOURCES one.cpp)
NAME 01_blt_cmake
SOURCES 01_blt_cmake.cpp)
8 changes: 4 additions & 4 deletions Intro_Tutorial/lessons/01_blt_cmake/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ all the source code files that make up your application:

```
blt_add_executable(
NAME one
SOURCES one.cpp)
NAME 01_blt_cmake
SOURCES 01_blt_cmake.cpp)
```

For now, we have filled these out for you, but in later lessons you will need to
Expand All @@ -53,14 +53,14 @@ practice when using CMake. Once you are in the build directory, you can use the
`make` command to compile the executable:

```
$ make one
$ make 01_blt_cmake
```

You will see some output as the code is compiled. You can then run the
executable:

```
$ ./bin/one
$ ./bin/01_blt_cmake
Hello, world!
```

Expand Down
4 changes: 2 additions & 2 deletions Intro_Tutorial/lessons/02_raja_umpire/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# TODO: Add the RAJA, umpire and cuda targets as DEPENDS_ON arguments
blt_add_executable(
NAME two
SOURCES two.cpp
NAME 02_raja_umpire
SOURCES 02_raja_umpire.cpp
DEPENDS_ON )
8 changes: 4 additions & 4 deletions Intro_Tutorial/lessons/02_raja_umpire/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use to list dependencies.

```
blt_add_executable(
NAME one
SOURCES one.cpp
NAME 01_blt_cmake
SOURCES 01_blt_cmake.cpp
DEPENDS_ON )
```

Expand All @@ -33,8 +33,8 @@ $ cd build
You can then compile and run the lesson:

```
$ make two
$ ./bin/two
$ make 02_raja_umpire
$ ./bin/02_raja_umpire
Hello, world (with RAJA and Umpire)!
```

Expand Down
4 changes: 2 additions & 2 deletions Intro_Tutorial/lessons/03_umpire_allocator/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
blt_add_executable(
NAME three
SOURCES three.cpp
NAME 03_umpire_allocator
SOURCES 03_umpire_allocator.cpp
DEPENDS_ON RAJA umpire cuda)
6 changes: 3 additions & 3 deletions Intro_Tutorial/lessons/03_umpire_allocator/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Lesson 3

In this lesson, you will learn how to use Umpire to allocate memory. The file
`three.cpp` contains some `TODO:` comments where you can add code to allocate and
`03_umpire_allocator.cpp` contains some `TODO:` comments where you can add code to allocate and
deallocate memory.

The fundamental concept for accessing memory through Umpire is the
Expand Down Expand Up @@ -38,7 +38,7 @@ https://umpire.readthedocs.io/en/develop/sphinx/tutorial/allocators.html
Once you have made your changes, you can compile and run the lesson:

```
$ make three
$ ./bin/three
$ make 03_umpire_allocator
$ ./bin/03_umpire_allocator
Address of data: 0x?????
```
4 changes: 2 additions & 2 deletions Intro_Tutorial/lessons/04_raja_forall/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
blt_add_executable(
NAME four
SOURCES four.cpp
NAME 04_raja_forall
SOURCES 04_raja_forall.cpp
DEPENDS_ON RAJA umpire cuda)
11 changes: 5 additions & 6 deletions Intro_Tutorial/lessons/04_raja_forall/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,16 @@ this example, we will use the `RAJA::seq_exec` policy to execute this loop on
the CPU. In later lessons, we will learn about other policies that allow us to
run code on a GPU.

In the file four.cpp, you will see a `TODO` comment where you can add a
`RAJA::forall` loop to initialize the array you allocated in the previous
In the file 04_raja_forall.cpp, you will see a `TODO` comment where you can add a
`RAJA::forall` loop to initialize the array you allocated in the previous
lesson.

When you have made your changes, compile and run the code in the same way as the
other lessons:

```
$ make four
$ ./bin/four
Address of data:
$ make 04_raja_forall
$ ./bin/04_raja_forall
Address of data:
data[50] = 50
```

4 changes: 2 additions & 2 deletions Intro_Tutorial/lessons/05_raja_reduce/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
blt_add_executable(
NAME five
SOURCES five.cpp
NAME 05_raja_reduce
SOURCES 05_raja_reduce.cpp
DEPENDS_ON RAJA umpire)
6 changes: 3 additions & 3 deletions Intro_Tutorial/lessons/05_raja_reduce/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ https://raja.readthedocs.io/en/develop/sphinx/user_guide/feature/policies.html#r
The second parameter, the `TYPE` parameter, is just the data type of the
variable, such as `int`.

In the file `five.cpp`, follow the instruction in the `TODO` comment to create
In the file `05_raja_reduce.cpp`, follow the instruction in the `TODO` comment to create
a RAJA Reduction using `seq_exec`.


Once you have filled in the correct reduction statement, compile and run:

```
$ make five
$ ./bin/five
$ make 05_raja_reduce
$ ./bin/05_raja_reduce
```
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ int main()
}
);

std::cout << "dot product is "<< dot << std::endl;
std::cout << "dot product is "<< dot.get() << std::endl;

allocator.deallocate(a);
allocator.deallocate(b);
Expand Down
4 changes: 2 additions & 2 deletions Intro_Tutorial/lessons/06_raja_umpire_uvm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
if (ENABLE_CUDA)
blt_add_executable(
NAME six
SOURCES six.cpp
NAME 06_raja_umpire_uvm
SOURCES 06_raja_umpire_uvm.cpp
DEPENDS_ON RAJA umpire cuda)
endif()

6 changes: 3 additions & 3 deletions Intro_Tutorial/lessons/06_raja_umpire_uvm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ as a template parameter. Finally, as we are filling in the lambda portion of
the `RAJA::forall`, we need to specify where it will reside in GPU memory.
This can be done directly or by using the `RAJA_DEVICE` macro.

There are several `TODO` comments in the `six.cpp` exercise file where you
There are several `TODO` comments in the `06_raja_umpire_uvm.cpp` exercise file where you
can modify the code to work on a GPU. When you are done, build
and run the example:

```
$ make six
$ ./bin/six
$ make 06_raja_umpire_uvm
$ ./bin/06_raja_umpire_uvm
```

For more information on Umpire's resources, see our documentation:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
if (ENABLE_CUDA)
blt_add_executable(
NAME seven
SOURCES seven.cpp
NAME 07_raja_umpire_host_device
SOURCES 07_raja_umpire_host_device.cpp
DEPENDS_ON RAJA umpire cuda)
endif()
8 changes: 4 additions & 4 deletions Intro_Tutorial/lessons/07_raja_umpire_host_device/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
In this lesson, you will learn how to use Umpire's operations to copy data
between CPU and GPU memory in a portable way.

In `seven.cpp`, we create an allocator for the GPU with:
In `07_raja_umpire_host_device.cpp`, we create an allocator for the GPU with:
```
auto allocator = rm.getAllocator("DEVICE");
```
Expand All @@ -30,12 +30,12 @@ void umpire::ResourceManager::copy (void* dst_ptr, void * src_ptr, std::size_t s

*Note:* The destination is the first argument.

In the file `seven.cpp`, there is a `TODO` comment where you should insert two copy
In the file `07_raja_umpire_host_device.cpp`, there is a `TODO` comment where you should insert two copy
calls to copy data from the CPU memory to the DEVICE memory.

When you are done editing the file, compile and run it:

```
$ make seven
$ ./bin/seven
$ make 07_raja_umpire_host_device
$ ./bin/07_raja_umpire_host_device
```
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
if (ENABLE_CUDA)
blt_add_executable(
NAME eight
SOURCES eight.cpp
NAME 08_raja_umpire_quick_pool
SOURCES 08_raja_umpire_quick_pool.cpp
DEPENDS_ON RAJA umpire cuda)
endif()
6 changes: 3 additions & 3 deletions Intro_Tutorial/lessons/08_raja_umpire_quick_pool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ To create a new memory pool allocator using the `QuickPool` strategy, we can use

This newly created `pool` is an `umpire::Allocator` using the `QuickPool` strategy. As you can see above, we can use the `ResourceManager::makeAllocator` function to create the pool allocator. We just need to pass
in: (1) the name we would like the pool to have, and (2) the allocator we previously created with the `ResourceManager` (see line 17 in the
file `eight.cpp`). Remember that you will also need to include the `umpire/strategy/QuickPool.hpp` header file.
file `08_raja_umpire_quick_pool.cpp`). Remember that you will also need to include the `umpire/strategy/QuickPool.hpp` header file.

There are other arguments that could be passed to the pool constructor if needed. These additional option arguments are a bit advanced and are beyond the scope of this tutorial. However, you can visit the documentation page for more: https://umpire.readthedocs.io/en/develop/doxygen/html/index.html

When you have created your QuickPool allocator, uncomment the COMPILE define on line 7;
then compile and run the code:
```
$ make eight
$ ./bin/eight
$ make 08_raja_umpire_quick_pool
$ ./bin/08_raja_umpire_quick_pool
```
4 changes: 2 additions & 2 deletions Intro_Tutorial/lessons/09_raja_view/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
blt_add_executable(
NAME nine
SOURCES nine.cpp
NAME 09_raja_view
SOURCES 09_raja_view.cpp
DEPENDS_ON cuda RAJA umpire)
6 changes: 3 additions & 3 deletions Intro_Tutorial/lessons/09_raja_view/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ RAJA::View<double, RAJA::Layout<2, int>> view(data, N, N);
where `data` is a `double*`, and `N` is the size of each dimension. The size of
`data` should be at least `N*N`.

In the file `nine.cpp`, there is a `TODO` comment where you should create three
In the file `09_raja_view.cpp`, there is a `TODO` comment where you should create three
views, A, B, and C. You will notice that we are doing the same dot product
calculation, but this time for matrices. Thus, we are now doing a matrix
multiplication. When you are ready, uncomment the COMPILE define on line 7;
then you can compile and run the code:

```
$ make nine
$ ./bin/nine
$ make 09_raja_view
$ ./bin/09_raja_view
```

For more information on Views and Layouts, see the RAJA
Expand Down
4 changes: 2 additions & 2 deletions Intro_Tutorial/lessons/10_raja_kernel/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
blt_add_executable(
NAME ten
SOURCES ten.cpp
NAME 10_raja_kernel
SOURCES 10_raja_kernel.cpp
DEPENDS_ON cuda RAJA umpire)
4 changes: 2 additions & 2 deletions Intro_Tutorial/lessons/10_raja_kernel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ When you have finished making your changes, uncomment the COMPILE define on line
then compile and run the code:

```
$ make ten
$ ./bin/ten
$ make 10_raja_kernel
$ ./bin/10_raja_kernel
```
4 changes: 2 additions & 2 deletions Intro_Tutorial/lessons/11_raja_device_kernel/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
if (ENABLE_CUDA)
blt_add_executable(
NAME eleven
SOURCES eleven.cpp
NAME 11_raja_device_kernel
SOURCES 11_raja_device_kernel.cpp
DEPENDS_ON RAJA umpire cuda)
endif()
4 changes: 2 additions & 2 deletions Intro_Tutorial/lessons/11_raja_device_kernel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ before this will work!
Once you are ready, uncomment the COMPILE define on line 7; then you can build and run the example:

```
$ make eleven
$ ./bin/eleven
$ make 11_raja_device_kernel
$ ./bin/11_raja_device_kernel
```

For reference, lesson 12 contains the solution, so don't worry if you get stuck!
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ int main()
// TODO: convert EXEC_POL to use CUDA
using EXEC_POL =
RAJA::KernelPolicy<
RAJA::statement::CudaKernel<
RAJA::statement::For<1, RAJA::cuda_block_x_loop,
RAJA::statement::For<0, RAJA::cuda_thread_x_loop,
RAJA::statement::CudaKernelFixed<256,
RAJA::statement::For<1, RAJA::cuda_global_size_y_direct<16>,
RAJA::statement::For<0, RAJA::cuda_global_size_x_direct<16>,
RAJA::statement::Lambda<0>
>
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ int main()

using EXEC_POL =
RAJA::KernelPolicy<
RAJA::statement::CudaKernel<
RAJA::statement::For<1, RAJA::cuda_block_x_loop,
RAJA::statement::For<0, RAJA::cuda_thread_x_loop,
RAJA::statement::CudaKernelFixed<256,
RAJA::statement::For<1, RAJA::cuda_global_size_y_direct<16>,
RAJA::statement::For<0, RAJA::cuda_global_size_x_direct<16>,
RAJA::statement::Lambda<0>
>
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
if (ENABLE_CUDA)
blt_add_executable(
NAME twelve
SOURCES twelve.cpp
NAME 12_raja_device_kernel_complete
SOURCES 12_raja_device_kernel_complete.cpp
DEPENDS_ON RAJA umpire cuda)
endif()

0 comments on commit 484c8d2

Please sign in to comment.