[PATCH] D103065: [AIX][test-suite] Utilize `INT_MAX` instead of `RAND_MAX` on AIX (ocean and srad benchmarks)
Amy Kwan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 15 18:35:15 PDT 2021
amyk updated this revision to Diff 372848.
amyk added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Address @stevewan's review comment to use 2147483647 instead of including a new header.
I have tried to define a macro to represent 2147483647 on AIX.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D103065/new/
https://reviews.llvm.org/D103065
Files:
MultiSource/Benchmarks/Prolangs-C++/ocean/ocean.cpp
MultiSource/Benchmarks/Rodinia/srad/main.c
Index: MultiSource/Benchmarks/Rodinia/srad/main.c
===================================================================
--- MultiSource/Benchmarks/Rodinia/srad/main.c
+++ MultiSource/Benchmarks/Rodinia/srad/main.c
@@ -4,6 +4,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifdef _AIX
+#define AIX_RAND_MAX 2147483647
+#endif
void random_matrix(float I[ROWS][COLS]);
void srad_kernel(float dN[ROWS][COLS], float dS[ROWS][COLS],
float dW[ROWS][COLS], float dE[ROWS][COLS],
@@ -80,7 +83,11 @@
glibc_compat_srand(SEED);
for (int i = 0; i < ROWS; i++) {
for (int j = 0; j < COLS; j++) {
+ #ifdef _AIX
+ I[i][j] = glibc_compat_rand() / (float)AIX_RAND_MAX;
+ #else
I[i][j] = glibc_compat_rand() / (float)RAND_MAX;
+ #endif
}
}
}
Index: MultiSource/Benchmarks/Prolangs-C++/ocean/ocean.cpp
===================================================================
--- MultiSource/Benchmarks/Prolangs-C++/ocean/ocean.cpp
+++ MultiSource/Benchmarks/Prolangs-C++/ocean/ocean.cpp
@@ -12,6 +12,9 @@
#if defined(__XS1B__)
#include "xcoretestsuite.h"
#endif
+#ifdef _AIX
+#define AIX_RAND_MAX 2147483647
+#endif
//cell.cc
Cell *Cell::getCellAt(Coordinate aCoord) {
@@ -127,11 +130,19 @@
#define MAX 32767
float Random::randReal(void) {
+#ifdef _AIX
+ return random()/(float)AIX_RAND_MAX;
+#else
return random()/(float)RAND_MAX;
+#endif
}
unsigned Random::nextIntBetween(int low, int high) {
+#ifdef _AIX
+ return (long long)(random())* high / AIX_RAND_MAX;
+#else
return (long long)(random())* high / RAND_MAX;
+#endif
}
//ocean.cc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103065.372848.patch
Type: text/x-patch
Size: 1624 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210916/ed3360ac/attachment.bin>
More information about the llvm-commits
mailing list