Index: MultiSource/Benchmarks/Rodinia/CMakeLists.txt =================================================================== --- MultiSource/Benchmarks/Rodinia/CMakeLists.txt +++ MultiSource/Benchmarks/Rodinia/CMakeLists.txt @@ -0,0 +1 @@ +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,9 @@ +set(PROG pathfinder) + +list(APPEND CFLAGS -I${CMAKE_CURRENT_SOURCE_DIR}/../Common/) + +set(Source main.c pathfinderKernel.c ../Common/glibc_compat_rand.c) + +set(WORKDIR ${CMAKE_CURRENT_BINARY_DIR}) + +llvm_multisource() Index: MultiSource/Benchmarks/Rodinia/pathfinder/Makefile =================================================================== --- MultiSource/Benchmarks/Rodinia/pathfinder/Makefile +++ MultiSource/Benchmarks/Rodinia/pathfinder/Makefile @@ -0,0 +1,7 @@ +LEVEL = ../../../.. +LIBS += -lm + +CFLAGS += -I${PROJ_SRC_DIR}/../Common/ +PROG = hotspot + +include ../../Makefile.multisrc Index: MultiSource/Benchmarks/Rodinia/pathfinder/main.c =================================================================== --- MultiSource/Benchmarks/Rodinia/pathfinder/main.c +++ MultiSource/Benchmarks/Rodinia/pathfinder/main.c @@ -0,0 +1,39 @@ +#include "glibc_compat_rand.h" +#include +#include +#include "pathfinder.h" + +void pathFinderKernel(int data[ROWS][COLS], + int result[COLS], int src[COLS]); + +void initialize(int rows, int cols, int result[cols], int data[rows][cols]); +int main() { + typedef int matrix[ROWS][COLS]; + typedef int res[COLS]; + + matrix *data = (matrix *)malloc(sizeof(matrix)); + + res *result = (res *)malloc(sizeof(res)); + res *src = (res *)malloc(sizeof(res)); + + initialize(ROWS, COLS, *result, *data); + for (int j = 0; j < COLS; j++) { + (*result)[j] = (*data)[0][j]; + } + + pathFinderKernel(*data, *result, *src); + + for (int i = 0; i < COLS; i++) { + printf("%d %d\n", (*data)[0][i], (*result)[i]); + } + return 0; +} + +void initialize(int rows, int cols, int result[cols], int data[rows][cols]) { + glibc_compat_srand(SEED); + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + data[i][j] = glibc_compat_rand() % 10; + } + } +} 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,501 @@ +5 133229 +4 133230 +5 133234 +7 133232 +0 133233 +3 133231 +0 133239 +8 133234 +2 133238 +2 133237 +6 133234 +3 133241 +8 133234 +9 133235 +7 133232 +5 133231 +9 133236 +0 133239 +6 133232 +9 133230 +5 133232 +0 133229 +1 133240 +5 133236 +9 133231 +4 133236 +4 133243 +3 133228 +9 133226 +9 133229 +0 133235 +4 133234 +3 133236 +7 133237 +3 133237 +6 133236 +0 133240 +5 133241 +6 133240 +4 133239 +7 133236 +3 133238 +9 133231 +5 133237 +4 133234 +9 133231 +0 133224 +3 133226 +9 133238 +9 133239 +5 133231 +4 133238 +1 133235 +6 133233 +9 133235 +2 133238 +1 133231 +6 133228 +5 133227 +2 133227 +5 133233 +7 133233 +8 133225 +0 133228 +6 133217 +1 133216 +8 133214 +7 133216 +6 133216 +5 133220 +1 133223 +5 133221 +0 133217 +3 133220 +2 133209 +4 133204 +2 133210 +5 133212 +8 133206 +1 133205 +6 133199 +5 133204 +7 133200 +7 133202 +3 133203 +9 133194 +0 133201 +6 133195 +5 133201 +7 133195 +8 133198 +0 133201 +7 133195 +8 133197 +2 133195 +3 133197 +1 133195 +1 133205 +2 133187 +9 133187 +6 133187 +6 133185 +4 133182 +6 133179 +9 133182 +9 133178 +2 133180 +1 133181 +4 133182 +2 133178 +4 133184 +0 133186 +7 133189 +1 133192 +9 133189 +1 133193 +2 133186 +9 133189 +7 133182 +7 133185 +9 133180 +8 133181 +9 133182 +6 133188 +6 133179 +2 133180 +1 133184 +8 133181 +3 133179 +4 133175 +7 133171 +9 133172 +0 133179 +4 133177 +7 133171 +1 133171 +5 133164 +9 133165 +2 133175 +1 133175 +2 133173 +8 133180 +1 133167 +1 133163 +9 133159 +2 133160 +4 133168 +2 133161 +4 133165 +2 133165 +1 133162 +3 133165 +2 133161 +1 133168 +1 133160 +8 133164 +3 133164 +4 133163 +8 133153 +6 133154 +8 133153 +8 133160 +7 133165 +0 133164 +4 133167 +4 133170 +1 133167 +9 133170 +5 133172 +5 133174 +0 133171 +9 133171 +3 133168 +3 133173 +3 133171 +5 133162 +7 133160 +7 133157 +9 133158 +1 133161 +1 133166 +0 133163 +4 133168 +3 133175 +3 133169 +7 133167 +4 133170 +6 133174 +2 133167 +4 133170 +4 133164 +2 133167 +4 133169 +1 133174 +5 133173 +0 133170 +7 133164 +6 133171 +9 133164 +5 133176 +2 133177 +1 133174 +6 133171 +7 133178 +6 133176 +9 133174 +2 133181 +4 133176 +7 133174 +3 133175 +5 133174 +0 133173 +4 133180 +2 133175 +6 133174 +9 133177 +1 133174 +0 133171 +6 133167 +3 133170 +6 133168 +0 133169 +8 133161 +1 133165 +4 133163 +3 133168 +1 133159 +1 133163 +1 133164 +3 133160 +8 133160 +5 133160 +6 133162 +5 133162 +3 133162 +5 133152 +4 133155 +7 133152 +9 133156 +3 133150 +1 133167 +6 133162 +4 133162 +7 133169 +8 133163 +0 133162 +6 133157 +0 133162 +2 133163 +4 133165 +5 133155 +8 133161 +5 133155 +5 133155 +1 133158 +1 133160 +8 133144 +5 133152 +2 133147 +0 133148 +0 133151 +3 133152 +5 133161 +8 133157 +8 133163 +0 133155 +3 133168 +2 133170 +8 133162 +2 133160 +6 133164 +1 133165 +9 133171 +2 133167 +0 133167 +9 133167 +2 133171 +6 133171 +1 133174 +6 133174 +1 133178 +9 133183 +6 133186 +8 133190 +4 133186 +0 133199 +9 133197 +5 133203 +7 133204 +3 133196 +7 133201 +7 133200 +6 133200 +4 133197 +5 133208 +6 133204 +5 133203 +1 133205 +9 133197 +5 133197 +3 133189 +7 133198 +8 133195 +4 133199 +9 133193 +8 133201 +6 133195 +3 133205 +4 133202 +9 133197 +1 133190 +7 133190 +8 133192 +7 133182 +7 133184 +5 133182 +7 133186 +8 133186 +2 133192 +6 133188 +2 133189 +9 133185 +3 133186 +0 133185 +3 133184 +1 133186 +7 133184 +0 133182 +2 133182 +8 133182 +5 133176 +7 133175 +7 133176 +3 133178 +4 133177 +6 133176 +3 133173 +0 133176 +1 133176 +8 133170 +1 133164 +4 133158 +7 133158 +2 133159 +1 133152 +5 133155 +7 133151 +1 133156 +3 133154 +1 133170 +7 133170 +7 133168 +0 133163 +3 133168 +0 133163 +5 133160 +6 133165 +9 133170 +6 133171 +0 133167 +7 133166 +3 133164 +9 133165 +4 133166 +9 133161 +3 133171 +2 133165 +2 133170 +5 133174 +5 133174 +2 133171 +7 133170 +9 133176 +0 133176 +1 133184 +2 133183 +7 133185 +8 133183 +5 133184 +2 133179 +1 133184 +5 133190 +0 133186 +1 133178 +0 133183 +2 133179 +8 133178 +6 133179 +1 133182 +4 133186 +8 133185 +8 133184 +0 133177 +7 133180 +4 133182 +9 133180 +3 133177 +8 133181 +3 133182 +0 133174 +3 133173 +6 133176 +9 133176 +4 133177 +8 133171 +0 133170 +6 133175 +7 133175 +0 133182 +2 133175 +9 133177 +1 133183 +9 133177 +9 133179 +2 133175 +9 133182 +3 133188 +1 133191 +7 133193 +4 133192 +7 133194 +5 133194 +4 133194 +7 133195 +4 133193 +0 133194 +8 133191 +7 133194 +8 133193 +4 133190 +0 133196 +1 133191 +2 133196 +9 133191 +7 133190 +2 133187 +0 133191 +4 133191 +9 133182 +0 133186 +8 133178 +8 133190 +2 133187 +7 133187 +0 133193 +6 133196 +8 133180 +3 133179 +9 133176 +5 133169 +8 133173 +9 133167 +2 133168 +4 133172 +8 133177 +6 133170 +5 133175 +9 133169 +6 133161 +3 133163 +3 133166 +8 133170 +7 133169 +7 133167 +7 133168 +4 133171 +9 133162 +7 133168 +0 133165 +8 133168 +0 133167 +0 133165 +6 133165 +2 133175 +9 133171 +8 133171 +0 133175 +7 133183 +2 133178 +0 133180 +4 133180 +2 133187 +1 133183 +6 133178 +6 133177 +9 133177 +5 133193 +3 133187 +8 133190 +3 133189 +9 133184 +3 133180 +1 133188 +8 133188 +0 133184 +8 133183 +4 133177 +9 133186 +8 133183 +5 133185 +exit 0 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" +#define MIN(a, b) ((a) <= (b) ? (a) : (b)) +void pathFinderKernel(int data[ROWS][COLS], + int result[COLS], int src[COLS]) { + + for (int t = 0; t < ROWS - 1; t++) { + for (int n = 0; n < COLS; n++) { + src[n] = result[n]; + } + result[0] = data[t + 1][0] + MIN(src[0], src[1]); + int min = 0; + for (int n = 1; n < COLS - 1; n++) { + min = MIN(src[n], MIN(src[n - 1], src[n + 1])); + result[n] = data[t + 1][n] + min; + } + result[COLS - 1] = 0; + result[COLS - 1] = + data[t + 1][COLS - 1] + MIN(src[COLS - 2], src[COLS - 1]); + } +}