Index: MultiSource/Benchmarks/Rodinia/CMakeLists.txt =================================================================== --- MultiSource/Benchmarks/Rodinia/CMakeLists.txt +++ MultiSource/Benchmarks/Rodinia/CMakeLists.txt @@ -1,2 +1,3 @@ add_subdirectory(hotspot) add_subdirectory(srad) +add_subdirectory(pathfinder) Index: MultiSource/Benchmarks/Rodinia/pathfinder/CMakeLists.txt =================================================================== --- MultiSource/Benchmarks/Rodinia/pathfinder/CMakeLists.txt +++ MultiSource/Benchmarks/Rodinia/pathfinder/CMakeLists.txt @@ -0,0 +1,8 @@ +set(PROG pathfinder) +list(APPEND CFLAGS -I${CMAKE_CURRENT_SOURCE_DIR}/../Common/) +set(HASH_PROGRAM_OUTPUT 1) +llvm_multisource(pathfinder + main.c + pathfinderKernel.c + ../Common/glibc_compat_rand.c +) Index: MultiSource/Benchmarks/Rodinia/pathfinder/main.c =================================================================== --- MultiSource/Benchmarks/Rodinia/pathfinder/main.c +++ MultiSource/Benchmarks/Rodinia/pathfinder/main.c @@ -0,0 +1,41 @@ +#include "glibc_compat_rand.h" +#include "pathfinder.h" +#include +#include + +void pathFinderKernel(int rows, int cols, int *data, int *result, int *src); +void initialize(int rows, int cols, int *result, int *data); +void printResult(int len, int *result); + +int main() { + + int *data = (int *)malloc(sizeof(int) * ROWS * COLS); + int *result = (int *)malloc(sizeof(int) * COLS); + int *src = (int *)malloc(sizeof(int) * COLS); + + initialize(ROWS, COLS, result, data); + + pathFinderKernel(ROWS, COLS, data, result, src); + + printResult(COLS, result); + + return 0; +} + +void initialize(int rows, int cols, int *result, int *data) { + glibc_compat_srand(SEED); + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + data[i * cols + j] = glibc_compat_rand() % 10; + } + } + for (int j = 0; j < COLS; j++) { + result[j] = data[j]; + } +} + +void printResult(int len, int *result) { + for (int i = 0; i < len; i++) { + printf("%d\n", result[i]); + } +} Index: MultiSource/Benchmarks/Rodinia/pathfinder/pathfinder.h =================================================================== --- MultiSource/Benchmarks/Rodinia/pathfinder/pathfinder.h +++ MultiSource/Benchmarks/Rodinia/pathfinder/pathfinder.h @@ -0,0 +1,8 @@ +#ifndef _PATHFINDER_H_ +#define _PATHFINDER_H_ + +#define ROWS 100000 +#define COLS 500 +#define SEED 9 + +#endif \ No newline at end of file Index: MultiSource/Benchmarks/Rodinia/pathfinder/pathfinder.reference_output =================================================================== --- MultiSource/Benchmarks/Rodinia/pathfinder/pathfinder.reference_output +++ MultiSource/Benchmarks/Rodinia/pathfinder/pathfinder.reference_output @@ -0,0 +1 @@ +38b47b2426f6fc1af9d4d0e2066f834d Index: MultiSource/Benchmarks/Rodinia/pathfinder/pathfinderKernel.c =================================================================== --- MultiSource/Benchmarks/Rodinia/pathfinder/pathfinderKernel.c +++ MultiSource/Benchmarks/Rodinia/pathfinder/pathfinderKernel.c @@ -0,0 +1,20 @@ +#include "pathfinder.h" +#include +#define MIN(a, b) ((a) <= (b) ? (a) : (b)) +void pathFinderKernel(int row, int col, int data[row][col], int result[col], + int src[col]) { + for (int t = 0; t < row - 1; t++) { + for (int n = 0; n < col; n++) { + src[n] = result[n]; + } + for (int n = 0; n < col; n++) { + if (n == 0) { + result[n] = data[t + 1][n] + MIN(src[n], src[n + 1]); + } else if (n == col - 1) { + result[n] = data[t + 1][n] + MIN(src[n], src[col - 2]); + } else { + result[n] = data[t + 1][n] + MIN(src[n], MIN(src[n - 1], src[n + 1])); + } + } + } +}