From b095d4dc01365138e37a5282d157849a18061c79 Mon Sep 17 00:00:00 2001 From: Greg Colvin Date: Fri, 5 May 2017 20:52:53 -0400 Subject: [PATCH 1/3] Correct formula for division. --- EIPS/eip-EIPS/eip-616.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EIPS/eip-EIPS/eip-616.md b/EIPS/eip-EIPS/eip-616.md index 91f196a5..46de32e3 100644 --- a/EIPS/eip-EIPS/eip-616.md +++ b/EIPS/eip-EIPS/eip-616.md @@ -1,5 +1,5 @@ ``` -EIP: +EIP: 616 Title: SIMD Operations for the EVM Author: Greg Colvin, greg@colvin.org Type: Standard Track @@ -125,7 +125,7 @@ operation | cycles | N = 2 | N = 4 | N = 8 add | 10 _N_ + 6 | 26 | 46 | 86 subtract | 12 _N_ + 3 |27 | 51 | 99 multiply | 28 _N_**2 + 11 _N_ + 3 | 137 | 495 |1883 -divide | 30 _N_**2 + 119 _N_ + 111 | 469 | 1067 | 2983 +divide | 30 (_N_**2)/2 + 119 _N_ + 111 | 409 | 827 | 2023 The remaining operations are of about the same complexity as addition and subtraction, or less. Given that JUMPDEST is a no-op, and is assigned a gas price of 1, this can be taken as the overhead of the interpreter. All of the arithmetic operations are assigned the same gas price of 5, for a remaining runtime of 4. The interpreter loop itself takes about 6 to 8 C instructions, so ADD and SUB are reasonably priced, but MUL is some 5 to 21 times slower than ADD or SUB, and DIV is some 18 to 35 times slower, so they are clearly mispriced. From d31597eaa1134ba8b28e3acf2137c55c002227f2 Mon Sep 17 00:00:00 2001 From: Greg Colvin Date: Sat, 6 May 2017 14:55:51 -0400 Subject: [PATCH 2/3] Update eip-616.md --- EIPS/eip-EIPS/eip-616.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-EIPS/eip-616.md b/EIPS/eip-EIPS/eip-616.md index 46de32e3..6ed6755d 100644 --- a/EIPS/eip-EIPS/eip-616.md +++ b/EIPS/eip-EIPS/eip-616.md @@ -125,7 +125,7 @@ operation | cycles | N = 2 | N = 4 | N = 8 add | 10 _N_ + 6 | 26 | 46 | 86 subtract | 12 _N_ + 3 |27 | 51 | 99 multiply | 28 _N_**2 + 11 _N_ + 3 | 137 | 495 |1883 -divide | 30 (_N_**2)/2 + 119 _N_ + 111 | 409 | 827 | 2023 +divide | 15 _N_**2 + 119 _N_ + 111 | 409 | 827 | 2023 The remaining operations are of about the same complexity as addition and subtraction, or less. Given that JUMPDEST is a no-op, and is assigned a gas price of 1, this can be taken as the overhead of the interpreter. All of the arithmetic operations are assigned the same gas price of 5, for a remaining runtime of 4. The interpreter loop itself takes about 6 to 8 C instructions, so ADD and SUB are reasonably priced, but MUL is some 5 to 21 times slower than ADD or SUB, and DIV is some 18 to 35 times slower, so they are clearly mispriced. From 07b0caea587ec4323b639d0d0556b94352f246d5 Mon Sep 17 00:00:00 2001 From: Greg Colvin Date: Sat, 6 May 2017 15:09:14 -0400 Subject: [PATCH 3/3] Update eip-616.md --- EIPS/eip-EIPS/eip-616.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-EIPS/eip-616.md b/EIPS/eip-EIPS/eip-616.md index 6ed6755d..df54888a 100644 --- a/EIPS/eip-EIPS/eip-616.md +++ b/EIPS/eip-EIPS/eip-616.md @@ -127,7 +127,7 @@ subtract | 12 _N_ + 3 |27 | 51 | 99 multiply | 28 _N_**2 + 11 _N_ + 3 | 137 | 495 |1883 divide | 15 _N_**2 + 119 _N_ + 111 | 409 | 827 | 2023 -The remaining operations are of about the same complexity as addition and subtraction, or less. Given that JUMPDEST is a no-op, and is assigned a gas price of 1, this can be taken as the overhead of the interpreter. All of the arithmetic operations are assigned the same gas price of 5, for a remaining runtime of 4. The interpreter loop itself takes about 6 to 8 C instructions, so ADD and SUB are reasonably priced, but MUL is some 5 to 21 times slower than ADD or SUB, and DIV is some 18 to 35 times slower, so they are clearly mispriced. +The remaining operations are of about the same complexity as addition and subtraction, or less. Given that JUMPDEST is a no-op, and is assigned a gas price of 1, this can be taken as the overhead of the interpreter. All of the arithmetic operations are assigned the same gas price of 5, for a remaining runtime of 4. The interpreter loop itself takes about 6 to 8 C instructions, so ADD and SUB are reasonably priced, but MUL is some 5 to 21 times slower than ADD or SUB, and DIV is some 15 to 23 times slower, so they are clearly mispriced. By comparison, on most [Intel](https://software.intel.com/sites/landingpage/IntrinsicsGuide) and [ARM](https://developer.arm.com/docs/100166_0001/latest/programmers-model/instruction-set-summary/table-of-processor-instructions) SIMD units instructions take approximately the following cycle counts, independent of register width.