}
#endif
-void core_hash_init(int process, int core_base, int base, int limit) {
- for (int i = base; i < limit; ++i) {
-#ifdef INDIRECT_CORE
- int core_block = core_table_mem[core_base + i];
-#else
- int core_block = core_base + i;
-#endif
- for (int j = 0; j < BLOCK_SIZE; ++j) {
- long long hash = process * 17 + i * 29 + j * 37;
- hash = (hash & 0xffffffffLL) + (hash >> 32);
- hash = (hash & 0xffffLL) + (hash >> 16);
- hash = (hash & 0xffLL) + (hash >> 8);
- hash = (hash & 0xffLL) + (hash >> 8);
- rassert(core_block_mem[core_block * BLOCK_SIZE + j] == 0xaa);
- core_block_mem[core_block * BLOCK_SIZE + j] = (uint8_t)hash;
- }
- }
-}
-
-void core_hash_verify(int process, int core_base, int base, int limit) {
- for (int i = base; i < limit; ++i) {
-#ifdef INDIRECT_CORE
- int core_block = core_table_mem[core_base + i];
-#else
- int core_block = core_base + i;
-#endif
- for (int j = 0; j < BLOCK_SIZE; ++j) {
- long long hash = process * 17 + i * 29 + j * 37;
- hash = (hash & 0xffffffffLL) + (hash >> 32);
- hash = (hash & 0xffffLL) + (hash >> 16);
- hash = (hash & 0xffLL) + (hash >> 8);
- hash = (hash & 0xffLL) + (hash >> 8);
- rassert(core_block_mem[core_block * BLOCK_SIZE + j] == (uint8_t)hash);
- }
- memset(
- core_block_mem + core_block * BLOCK_SIZE,
- 0xaa,
- BLOCK_SIZE
- );
- }
-}
#else
void core_init(int n_table);
#endif
-void core_hash_init(int process, int core_base, int base, int limit);
-void core_hash_verify(int process, int core_base, int base, int limit);
#endif
#include "rassert.h"
#include "swap.h"
+void core_hash_init(int process, int core_base, int base, int limit) {
+ for (int i = base; i < limit; ++i) {
+#ifdef INDIRECT_CORE
+ int core_block = core_table_mem[core_base + i];
+#else
+ int core_block = core_base + i;
+#endif
+ for (int j = 0; j < BLOCK_SIZE; ++j) {
+ long long hash = process * 17 + i * 29 + j * 37;
+ hash = (hash & 0xffffffffLL) + (hash >> 32);
+ hash = (hash & 0xffffLL) + (hash >> 16);
+ hash = (hash & 0xffLL) + (hash >> 8);
+ hash = (hash & 0xffLL) + (hash >> 8);
+ rassert(core_block_mem[core_block * BLOCK_SIZE + j] == 0xaa);
+ core_block_mem[core_block * BLOCK_SIZE + j] = (uint8_t)hash;
+ }
+ }
+}
+
+void core_hash_verify(int process, int core_base, int base, int limit) {
+ for (int i = base; i < limit; ++i) {
+#ifdef INDIRECT_CORE
+ int core_block = core_table_mem[core_base + i];
+#else
+ int core_block = core_base + i;
+#endif
+ for (int j = 0; j < BLOCK_SIZE; ++j) {
+ long long hash = process * 17 + i * 29 + j * 37;
+ hash = (hash & 0xffffffffLL) + (hash >> 32);
+ hash = (hash & 0xffffLL) + (hash >> 16);
+ hash = (hash & 0xffLL) + (hash >> 8);
+ hash = (hash & 0xffLL) + (hash >> 8);
+ rassert(core_block_mem[core_block * BLOCK_SIZE + j] == (uint8_t)hash);
+ }
+ memset(
+ core_block_mem + core_block * BLOCK_SIZE,
+ 0xaa,
+ BLOCK_SIZE
+ );
+ }
+}
+
+void swap_hash_verify(int process, int swap_base, int base, int limit) {
+ for (int i = base; i < limit; ++i) {
+#ifdef INDIRECT_SWAP
+ int swap_block = swap_table_mem[swap_base + i];
+#else
+ int swap_block = swap_base + i;
+#endif
+ for (int j = 0; j < BLOCK_SIZE; ++j) {
+ long long hash = process * 17 + i * 29 + j * 37;
+ hash = (hash & 0xffffffffLL) + (hash >> 32);
+ hash = (hash & 0xffffLL) + (hash >> 16);
+ hash = (hash & 0xffLL) + (hash >> 8);
+ hash = (hash & 0xffLL) + (hash >> 8);
+ rassert(swap_block_mem[swap_block * BLOCK_SIZE + j] == (uint8_t)hash);
+ }
+ memset(
+ swap_block_mem + swap_block * BLOCK_SIZE,
+ 0xaa,
+ BLOCK_SIZE
+ );
+ }
+}
+
int main(int argc, char **argv) {
if (argc < 5) {
#if defined(INDIRECT_CORE) && defined(INDIRECT_SWAP)
}
#endif
-#if 0 // not needed as always done in core before copying to swap
-void swap_hash_init(int process, int swap_base, int base, int limit) {
- for (int i = base; i < limit; ++i) {
-#ifdef INDIRECT_SWAP
- int swap_block = swap_table_mem[swap_base + i];
-#else
- int swap_block = swap_base + i;
-#endif
- for (int j = 0; j < BLOCK_SIZE; ++j) {
- long long hash = process * 17 + i * 29 + j * 37;
- hash = (hash & 0xffffffffLL) + (hash >> 32);
- hash = (hash & 0xffffLL) + (hash >> 16);
- hash = (hash & 0xffLL) + (hash >> 8);
- hash = (hash & 0xffLL) + (hash >> 8);
- rassert(swap_block_mem[swap_block * BLOCK_SIZE + j] == 0xaa);
- swap_block_mem[swap_block * BLOCK_SIZE + j] = (uint8_t)hash;
- }
- }
-}
-#endif
-
-void swap_hash_verify(int process, int swap_base, int base, int limit) {
- for (int i = base; i < limit; ++i) {
-#ifdef INDIRECT_SWAP
- int swap_block = swap_table_mem[swap_base + i];
-#else
- int swap_block = swap_base + i;
-#endif
- for (int j = 0; j < BLOCK_SIZE; ++j) {
- long long hash = process * 17 + i * 29 + j * 37;
- hash = (hash & 0xffffffffLL) + (hash >> 32);
- hash = (hash & 0xffffLL) + (hash >> 16);
- hash = (hash & 0xffLL) + (hash >> 8);
- hash = (hash & 0xffLL) + (hash >> 8);
- rassert(swap_block_mem[swap_block * BLOCK_SIZE + j] == (uint8_t)hash);
- }
- memset(
- swap_block_mem + swap_block * BLOCK_SIZE,
- 0xaa,
- BLOCK_SIZE
- );
- }
-}
-
void swap_read(int swap_base, int core_base, int size) {
printf("swap_read swap [%d,%d) to core [%d,%d)\n", swap_base, swap_base + size, core_base, core_base + size);
#if defined(INDIRECT_CORE) || defined(INDIRECT_SWAP)
#else
void swap_init(int n_table);
#endif
-//void swap_hash_init(int process, int swap_base, int base, int limit);
-void swap_hash_verify(int process, int swap_base, int base, int limit);
void swap_read(int swap_base, int core_base, int size);
void swap_write(int swap_base, int core_base, int size);