ΫνϟͱΈͳ͢͜ͱͰ͖Δɻ௨ৗϓϩάϥϚ͕ίϯϐϡʔλΛ੍ޚ͢Δࡍʹ༻͍ Δࣄ͕Ͱ͖Δ࠷Ϩϕϧͳ”ιϑτΣΞ”Ͱ͋Δɻ ISA ʹରͯ͠ɺISA Λ࣮ߦ͢ΔͨΊͷ෦ͷཧճ࿏ΛϚΠΫϩΞʔΩςΫνϟ (march) ͱݺͼɺ͜ΕϓϩηοαΛ෦͔ΒݟͨࡍͷΞʔΩςΫνϟͱ͍͏͜ͱ͕ Ͱ͖Δɻ ൚༻ੑͷ؍͔ΒҟͳΔϕϯμ͕ಉҰͷ ISA Λ࠾༻͍ͯ͠Δ CPU ͋Δɻྫ͑ɺ intel ࣾͱ AMD ࣾޓ͍ʹ͋Δఔͷޓੑ͕͋Δ ISA Λ࠾༻͍ͯ͠Δ͕ɺͦͷ march શ͘ҟͳΔɻ ຊεϥΠυͰ ISA ͱͯ͠ RISC-V ͱ x86 Λ༻͍ͯઆ໌Λߦ͏ɻ 30
// (1) ... e = (a + b) * d // (2) t = a + b // Ұ࣌มͱͯ͠ܭࢉ c = t // Ұ࣌มΛར༻1 ... e = t * d // Ұ࣌มΛར༻2 ڞ௨෦ࣜͷআʹҰൠʹҎԼͷ 3 ͭͷ͕݅ඞཁͰ͋Δɻ i. (1) ͱ (2) ͷ a+b ಉ͡ܗͷࣜͰ͋Δ ii. (2) ͷܭࢉͷલʹඞͣ (1) ͷܭࢉ͕ͳ͞Ε͍ͯΔ iii. (1) ͱ (2) ͷؒͰɺa ͱ b ͷ͕มΘΒͳ͍ 78
Motion ͷ؆୯ͳྫΛࣔ͢ɻ for i = 1, n ... a = b * c d = i * 2 ... end a = b * c for i = 1, n ... d = i * 2 ... end Loop Motion ʹΑͬͯݮ͞ΕΔܭࢉྔҰൠʹͦͷϧʔϓͷΠςϨʔγϣϯͱԋ ࢉࢠͷڧʹґଘ͢Δɻ্هͰ n-1 ճͷࢉ͕ݮ͞ΕΔɻ 80
tj = 1, n, t for tk = 1, n, t for i = ti , n, min(ti + t, n) for j = tj , n, min(tj + t, n) for k = tk , n, min(tk + t, n) C(i,j) += A(i,k) * B(j,k) end // k end // j end // i end // tk end // tj end // ti 84
2 αΠΫϧɺετΞ໋ྩ 1 αΠΫϧͰྃ͢Δ ҎԼʹɺϧʔϓ෦Ͱ୯७ͳܭࢉΛߦ͏ϓϩάϥϜͱͦͷΞηϯϒϦΛࣔ͢ɻ࣍ʹ͜ ͷϓϩάϥϜͷ֤ΠςϨʔγϣϯʹ͓͚Δ໋ྩ࣮ߦͷਪҠΛࣔ͢ɻ for i = 1, n A[i] = A[i] * b + c end 1: Load r1 A[i] 2: Mul r4 r1 r2 // b in r2 3: Add r5 r4 r3 // c in r3 4: Store A[i] r5 5: loop_check 89
ARM Edition. 1st. San Francisco, CA, USA: Morgan Kaufmann Publishers Inc., 2015. isbn: 0128000562, 9780128000564. John L. Hennessy and David A. Patterson. Computer Architecture, Sixth Edition: A Quantitative Approach. 6th. San Francisco, CA, USA: Morgan Kaufmann Publishers Inc., 2017. isbn: 0128119055, 9780128119051. David A. Patterson and John L. Hennessy. Computer Organization and Design RISC-V: The Hardware/Software Interface. 5th. San Francisco, CA, USA: Morgan Kaufmann Publishers Inc., 2017. isbn: 0124077269, 9780124077263. poyopoyo Reconf. LSI ͔ΒΘ͔Δࣗ࡞ CPU. 1st. 2018. url: https://booth.pm/ja/items/1046056. 97