-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from LLNL/artv3/Intermediate_Tutorial_edits
Update readmes for intermediate tutorial
- Loading branch information
Showing
24 changed files
with
316 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
=============================================== | ||
Fractal Tutorial - Base (Sequential) Execution | ||
=============================================== | ||
|
||
This file has no exercises but it | ||
is used as a base reference implementation. | ||
|
||
Use the code to compare implementations | ||
between the RAJA kernel and launch abstractions. | ||
|
||
Compile and run the code: | ||
|
||
``` | ||
$ make fractal-ex0-c-loop | ||
$ ./bin/fractal-ex0-c-loop | ||
``` | ||
|
||
Before starting, be sure to study the seq-exec implementation of the fractal. | ||
It is important to note: | ||
* Read-only, write-only, and read-write variables used in the main computation | ||
* The main data structure that holds the values of the fractal pixels | ||
* Any data dependencies, if any, throughout the computation of the pixels | ||
|
||
Also note that this is a sequential implementation. Timing information will be output to the screen. As we add RAJA and Umpire, it will be interesting to see how performance improves. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#include <malloc.h> | ||
#include <sys/time.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
#include "../../tpl/writeBMP.hpp" | ||
|
||
#define xMin 0.74395 | ||
#define xMax 0.74973 | ||
#define yMin 0.11321 | ||
#define yMax 0.11899 | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
|
||
double dx, dy; | ||
int width; | ||
const int maxdepth = 256; | ||
struct timeval start, end; | ||
writebmp wbmp; | ||
|
||
/* check command line */ | ||
if(argc != 2) {fprintf(stderr, "usage: exe <width> \n"); exit(-1);} | ||
width = atoi(argv[1]); | ||
if (width < 10) {fprintf(stderr, "edge_length must be at least 10\n"); exit(-1);} | ||
|
||
dx = (xMax - xMin) / width; | ||
dy = (yMax - yMin) / width; | ||
|
||
printf("computing %d by %d fractal with a maximum depth of %d\n", width, width, maxdepth); | ||
|
||
unsigned char *cnt = (unsigned char*)malloc(width * width * sizeof(unsigned char)); | ||
|
||
/* start time */ | ||
gettimeofday(&start, NULL); | ||
|
||
for(int row = 0; row < width; ++row) { | ||
for(int col = 0; col < width; ++col) { | ||
|
||
double x2, y2, x, y, cx, cy; | ||
int depth; | ||
|
||
cy = yMin + row * dy; //compute row # | ||
cx = xMin + col * dx; //compute column # | ||
x = -cx; | ||
y = -cy; | ||
depth = maxdepth; | ||
do { | ||
x2 = x * x; | ||
y2 = y * y; | ||
y = 2 * x * y - cy; | ||
x = x2 - y2 - cx; | ||
depth--; | ||
} while ((depth > 0) && ((x2 + y2) <= 5.0)); | ||
cnt[row * width + col] = depth & 255; | ||
|
||
} | ||
} | ||
|
||
/* end time */ | ||
gettimeofday(&end, NULL); | ||
printf("compute time: %.8f s\n", end.tv_sec + end.tv_usec / 1000000.0 - start.tv_sec - start.tv_usec / 1000000.0); | ||
|
||
/* verify result by writing it to a file */ | ||
if (width <= 2048) { | ||
wbmp.WriteBMP(width, width, cnt, "fractal.bmp"); | ||
} | ||
|
||
free(cnt); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
================================= | ||
Fractal Tutorial - CUDA Execution | ||
================================= | ||
|
||
Look for the `TODO` comments in the source code. Here you will have to choose | ||
two RAJA CUDA policies for the kernel API. | ||
|
||
A complete description of the different policies is available in the online RAJA | ||
documentation: | ||
https://raja.readthedocs.io/en/develop/sphinx/user_guide/tutorial/kernel_exec_pols.html# | ||
|
||
Once you are ready, uncomment the COMPILE define on on top of the file and do | ||
|
||
``` | ||
$ make fractal-ex2-RAJA-CUDA | ||
$ ./bin/fractal-ex2-RAJA-CUDA | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.