From e9745a413c1160a51147afe97b4a64a6c83322a7 Mon Sep 17 00:00:00 2001 From: ifdefelse Date: Thu, 15 Nov 2018 21:20:52 -0800 Subject: [PATCH] Shuffle lane->dag data mapping Based on suggestion from PR #13 --- README.md | 6 ++++-- libprogpow/ProgPow.cpp | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a1546f6e1..c6cec0c7d 100644 --- a/README.md +++ b/README.md @@ -329,10 +329,12 @@ void progPowLoop( // Lanes can execute in parallel and will be convergent for (int l = 0; l < PROGPOW_LANES; l++) { - // global load to sequential locations + // global load to the 256 byte DAG entry + // every lane can access every part of the entry uint32_t data_g[PROGPOW_DAG_LOADS]; + uint32_t offset_l = offset_g * PROGPOW_LANES + (l ^ loop) % PROGPOW_LANES; for (int i = 0; i < PROGPOW_DAG_LOADS; i++) - data_g[i] = dag[(offset_g*PROGPOW_LANES + l)*PROGPOW_DAG_LOADS + i]; + data_g[i] = dag[offset_l * PROGPOW_DAG_LOADS + i]; // initialize the seed and mix destination sequence int mix_seq_dst[PROGPOW_REGS]; diff --git a/libprogpow/ProgPow.cpp b/libprogpow/ProgPow.cpp index b55b14e36..066e09cd3 100644 --- a/libprogpow/ProgPow.cpp +++ b/libprogpow/ProgPow.cpp @@ -134,7 +134,7 @@ std::string ProgPow::getKern(uint64_t block_number, kernel_t kern) ret << "offset = share[group_id];\n"; } ret << "offset %= PROGPOW_DAG_ELEMENTS;\n"; - ret << "offset = offset * PROGPOW_LANES + lane_id;\n"; + ret << "offset = offset * PROGPOW_LANES + (lane_id ^ loop) % PROGPOW_LANES;\n"; ret << "data_dag = g_dag[offset];\n"; ret << "// hack to prevent compiler from reordering LD and usage\n"; if (kern == KERNEL_CUDA)