Skip to content

Commit

Permalink
resolve merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
clamchowder committed Jul 13, 2024
2 parents 949942e + 9066289 commit 206c032
Show file tree
Hide file tree
Showing 19 changed files with 648 additions and 93 deletions.
16 changes: 9 additions & 7 deletions AsmGen/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static void Main(string[] args)
tests.Add(new IntRfTest(96, 256, 1));
tests.Add(new FpRfTest(256, 512, 1));
tests.Add(new MixIntVec128RfTest(96, 300, 1));
tests.Add(new Fadd256RfTest(64, 256, 1));
tests.Add(new Fadd256RfTest(32, 256, 1));
tests.Add(new MixFAdd256and32RfTest(64, 256, 1));
tests.Add(new FlagRfTest(64, 256, 1));
tests.Add(new LdqTest(150, 250, 1));
Expand All @@ -37,9 +37,10 @@ static void Main(string[] args)
tests.Add(new LoadSchedTest(4, 72, 1));
tests.Add(new StoreSchedTest(4, 72, 1));
tests.Add(new StoreDataSchedTest(4, 80, 1));
tests.Add(new MixAddJumpSchedTest(64, 180, 1));
tests.Add(new FaddSchedTest(32, 180, 1));
tests.Add(new FcmpSchedTest(32, 120, 1));
tests.Add(new MixAddJumpSchedTest(64, 100, 1));
tests.Add(new FaddSchedTest(10, 80, 1));
tests.Add(new FmulSchedTest(10, 80, 1));
tests.Add(new FcmpSchedTest(10, 60, 1));
tests.Add(new JsCvtSched(8, 120, 1));
tests.Add(new MixAddvJsCvtSched(8, 120, 1));
tests.Add(new AddvSched(8, 120, 1));
Expand Down Expand Up @@ -79,8 +80,9 @@ static void Main(string[] args)
tests.Add(new LoadNsq(8, 70, 1)); // x2
tests.Add(new JumpNsqTest(8, 100, 1));
tests.Add(new StoreDataDivNsqTest(4, 48, 1));
tests.Add(new StoreDivNsqTest(4, 48, 1));
tests.Add(new FpStoreDataNsqTest(4, 80, 1));
tests.Add(new StoreDivSchedTest(4, 50, 1));
tests.Add(new StoreDivNsqTest(4, 60, 1));
tests.Add(new MixStoreDivSchedTest(4, 50, 1));

// avx-512
tests.Add(new Vec512RfTest(128, 600, 1));
Expand Down Expand Up @@ -171,7 +173,7 @@ static void GenerateMakefile()
sb.AppendLine(isa.ToString() + ":");
if (isa == IUarchTest.ISA.aarch64)
{
sb.AppendLine($"\tgcc -march=armv8.5-a+aes clammicrobench_{isa.ToString()}.c clammicrobench_{isa.ToString()}.s -o cb");
sb.AppendLine($"\tgcc -march=armv8.5-a+aes clammicrobench_{isa.ToString()}.c clammicrobench_{isa.ToString()}.s -o cb -static");
// hack for stupid compilers that need a ton of flags to do basic things
sb.AppendLine("android:");
sb.AppendLine("\tclang -march=armv8.3-a -mfpu=neon-fp-armv8 clammicrobench_aarch64.c clammicrobench_aarch64.s -o cb");
Expand Down
82 changes: 82 additions & 0 deletions AsmGen/UarchTestHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,88 @@ public static void GenerateArmAsmFpSchedTestFuncs(StringBuilder sb, int[] counts
}
}

public static void GenerateArmAsmDivNsqTestFuncs(StringBuilder sb,
int maxSize,
int[] counts,
string funcNamePrefix,
string[] depInstrs,
string[] indepInstrs,
bool divsInSq = false,
string initInstrs = null)
{
for (int i = 0; i < counts.Length; i++)
{
string funcName = funcNamePrefix + counts[i];

// args in x0 = iterations, x1 = list size, x2 = list (sink)
sb.AppendLine("\n" + funcName + ":");
sb.AppendLine(" sub sp, sp, #0x50");
sb.AppendLine(" stp x14, x15, [sp, #0x10]");
sb.AppendLine(" stp x12, x13, [sp, #0x20]");
sb.AppendLine(" stp x10, x11, [sp, #0x30]");
sb.AppendLine(" stp x25, x26, [sp, #0x40]");
sb.AppendLine(" mov x15, 1");
sb.AppendLine(" mov x14, 2");
sb.AppendLine(" mov x13, 3");
sb.AppendLine(" mov x12, 4");
sb.AppendLine(" mov x11, 5");
if (initInstrs != null) sb.AppendLine(initInstrs);
sb.AppendLine(" mov w25, 0x0");
sb.AppendLine(" mov w26, 0x40");
sb.AppendLine("\n" + funcName + "start:");
sb.AppendLine(" mov w25, w1");
sb.AppendLine(" udiv w25, w25, w13");
sb.AppendLine(" udiv w25, w25, w13");
sb.AppendLine(" udiv w25, w25, w13");
sb.AppendLine(" udiv w25, w25, w13");
sb.AppendLine(" udiv w25, w25, w13");
int fillerInstrCount = divsInSq ? counts[i] - 6 : counts[i];
for (int fillerIdx = 0, depInstrIdx = 0, indepInstrIdx = 0; fillerIdx < maxSize; fillerIdx++)
{
if (fillerIdx < fillerInstrCount)
{
sb.AppendLine(depInstrs[depInstrIdx]);
depInstrIdx = (depInstrIdx + 1) % depInstrs.Length;
}
else
{
sb.AppendLine(indepInstrs[indepInstrIdx]);
indepInstrIdx = (indepInstrIdx + 1) % indepInstrs.Length;
}
}
sb.AppendLine(" mov w26, w1");
sb.AppendLine(" udiv w26, w26, w13");
sb.AppendLine(" udiv w26, w26, w13");
sb.AppendLine(" udiv w26, w26, w13");
sb.AppendLine(" udiv w26, w26, w13");
sb.AppendLine(" udiv w26, w26, w13");
sb.AppendLine(" mov w25, w26");

for (int fillerIdx = 0, depInstrIdx = 0, indepInstrIdx = 0; fillerIdx < maxSize; fillerIdx++)
{
if (fillerIdx < fillerInstrCount)
{
sb.AppendLine(depInstrs[depInstrIdx]);
depInstrIdx = (depInstrIdx + 1) % depInstrs.Length;
}
else
{
sb.AppendLine(indepInstrs[indepInstrIdx]);
indepInstrIdx = (indepInstrIdx + 1) % indepInstrs.Length;
}
}

sb.AppendLine(" sub x0, x0, 1");
sb.AppendLine(" cbnz x0, " + funcName + "start");
sb.AppendLine(" ldp x25, x26, [sp, #0x40]");
sb.AppendLine(" ldp x10, x11, [sp, #0x30]");
sb.AppendLine(" ldp x12, x13, [sp, #0x20]");
sb.AppendLine(" ldp x14, x15, [sp, #0x10]");
sb.AppendLine(" add sp, sp, #0x50");
sb.AppendLine(" ret\n\n");
}
}

public static void GenerateMipsAsmStructureTestFuncs(StringBuilder sb,
int[] counts,
string funcNamePrefix,
Expand Down
58 changes: 58 additions & 0 deletions AsmGen/tests/FmulSchedTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System.Text;

namespace AsmGen
{
public class FmulSchedTest : UarchTest
{
public FmulSchedTest(int low, int high, int step)
{
this.Counts = UarchTestHelpers.GenerateCountArray(low, high, step);
this.Prefix = "fmulsched";
this.Description = "FP (32-bit multiply) Scheduler Capacity Test";
this.FunctionDefinitionParameters = "uint64_t iterations, int *arr, float *floatArr";
this.GetFunctionCallParameters = "structIterations, A, fpArr";
this.DivideTimeByCount = false;
}

public override bool SupportsIsa(IUarchTest.ISA isa)
{
if (isa == IUarchTest.ISA.amd64) return true;
if (isa == IUarchTest.ISA.aarch64) return true;
return false;
}

public override void GenerateAsm(StringBuilder sb, IUarchTest.ISA isa)
{
if (isa == IUarchTest.ISA.amd64)
{
GenerateX86Asm(sb);
}
else if (isa == IUarchTest.ISA.aarch64)
{
GenerateArmAsm(sb);
}
}

public void GenerateX86Asm(StringBuilder sb)
{
// xmm0 is dependent on ptr chasing load
string[] unrolledAdds = new string[4];
unrolledAdds[0] = " mulss %xmm0, %xmm1";
unrolledAdds[1] = " mulss %xmm0, %xmm2";
unrolledAdds[2] = " mulss %xmm0, %xmm3";
unrolledAdds[3] = " mulss %xmm0, %xmm4";

UarchTestHelpers.GenerateX86AsmFpSchedTestFuncs(sb, this.Counts, this.Prefix, unrolledAdds, unrolledAdds);
}

public void GenerateArmAsm(StringBuilder sb)
{
string[] unrolledAdds = new string[4];
unrolledAdds[0] = " fmul s17, s17, s16";
unrolledAdds[1] = " fmul s18, s18, s16";
unrolledAdds[2] = " fmul s19, s19, s16";
unrolledAdds[3] = " fmul s20, s20, s16";
UarchTestHelpers.GenerateArmAsmFpSchedTestFuncs(sb, this.Counts, this.Prefix, unrolledAdds, unrolledAdds);
}
}
}
8 changes: 5 additions & 3 deletions AsmGen/tests/MixAddJumpSched.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public MixAddJumpSchedTest(int low, int high, int step)
{
this.Counts = UarchTestHelpers.GenerateCountArray(low, high, step);
this.Prefix = "mixaddjumpsched";
this.Description = "Scheduler, Mixed Adds and Not-Taken Jumps in 2:1 ratio";
this.Description = "Scheduler, Mixed Adds and Not-Taken Jumps in 3:1 ratio";
this.FunctionDefinitionParameters = "uint64_t iterations, int *arr";
this.GetFunctionCallParameters = "structIterations, A";
this.DivideTimeByCount = false;
Expand All @@ -27,20 +27,22 @@ public override void GenerateAsm(StringBuilder sb, IUarchTest.ISA isa)
{
if (isa == IUarchTest.ISA.amd64)
{
string[] unrolledJumps = new string[3];
string[] unrolledJumps = new string[4];
unrolledJumps[0] = " cmp %rdi, %rsi\n je mixaddjumpsched_reallybadthing";
unrolledJumps[1] = " add %rsi, %r15";
unrolledJumps[2] = " add %rsi, %r14";
unrolledJumps[3] = " add %rsi, %r14";
UarchTestHelpers.GenerateX86AsmStructureTestFuncs(sb, this.Counts, this.Prefix, unrolledJumps, unrolledJumps, includePtrChasingLoads: true);

sb.AppendLine("mixaddjumpsched_reallybadthing:\n int3");
}
else if (isa == IUarchTest.ISA.aarch64)
{
string[] unrolledJumps = new string[3];
string[] unrolledJumps = new string[4];
unrolledJumps[0] = " cmp x25, x26\n b.eq mixaddjumpsched_reallybadthing";
unrolledJumps[1] = " add x15, x15, x25";
unrolledJumps[2] = " add x14, x14, x25";
unrolledJumps[3] = " add x14, x14, x25";
UarchTestHelpers.GenerateArmAsmStructureTestFuncs(sb, this.Counts, this.Prefix, unrolledJumps, unrolledJumps, includePtrChasingLoads: true);
sb.AppendLine("mixaddjumpsched_reallybadthing:\n .word 0xf7f0a000");
}
Expand Down
58 changes: 58 additions & 0 deletions AsmGen/tests/MixLoadStoreDivSchedTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System.Text;

namespace AsmGen
{
public class MixLoadStoreDivSchedTest : UarchTest
{
public MixLoadStoreDivSchedTest(int low, int high, int step)
{
this.Counts = UarchTestHelpers.GenerateCountArray(low, high, step);
this.Prefix = "mixloadstoredivsched";
this.Description = "Load/Store Scheduler Capacity Test, using divs to block retirement";
this.FunctionDefinitionParameters = "uint64_t iterations, int count, int *arr2, int *arr3";
this.GetFunctionCallParameters = "structIterations, list_size, B, A";
this.DivideTimeByCount = false;
}

public override bool SupportsIsa(IUarchTest.ISA isa)
{
if (isa == IUarchTest.ISA.amd64) return true;
if (isa == IUarchTest.ISA.aarch64) return true;
return false;
}

public override void GenerateAsm(StringBuilder sb, IUarchTest.ISA isa)
{
if (isa == IUarchTest.ISA.amd64)
{
GenerateX86Asm(sb);
}
else if (isa == IUarchTest.ISA.aarch64)
{
GenerateArmAsm(sb);
}
}

public void GenerateX86Asm(StringBuilder sb)
{
string[] dependentLoads = new string[2];
dependentLoads[0] = " mov (%r9, %rdx, 4), %r15";
dependentLoads[1] = " mov %r14, (%r8, %rdx, 4)";

UarchTestHelpers.GenerateX86AsmDivStructureTestFuncs(sb, this.Counts, this.Prefix, dependentLoads, dependentLoads, false);
}

public void GenerateArmAsm(StringBuilder sb)
{
string[] dependentLoads = new string[2];
dependentLoads[0] = " ldr w15, [x3, w25, uxtw #2]";
dependentLoads[1] = " str w14, [x2, w25, uxtw #2]";

string[] dependentLoads1 = new string[2];
dependentLoads1[0] = " ldr w15, [x3, w26, uxtw #2]";
dependentLoads1[1] = " str w14, [x2, w26, uxtw #2]";

UarchTestHelpers.GenerateArmAsmDivStructureTestFuncs(sb, this.Counts, this.Prefix, dependentLoads, dependentLoads1, false);
}
}
}
68 changes: 68 additions & 0 deletions AsmGen/tests/MixStoreDivSchedTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using System.Text;

namespace AsmGen
{
public class MixStoreDivSchedTest : UarchTest
{
public MixStoreDivSchedTest(int low, int high, int step)
{
this.Counts = UarchTestHelpers.GenerateCountArray(low, high, step);
this.Prefix = "mixstoresched";
this.Description = "Store (Mixed Data/Address) Scheduler Capacity Test";
this.FunctionDefinitionParameters = "uint64_t iterations, int count, int *arr2";
this.GetFunctionCallParameters = "structIterations, list_size, B";
this.DivideTimeByCount = false;
}

public override bool SupportsIsa(IUarchTest.ISA isa)
{
if (isa == IUarchTest.ISA.amd64) return true;
if (isa == IUarchTest.ISA.aarch64) return true;
return false;
}

public override void GenerateAsm(StringBuilder sb, IUarchTest.ISA isa)
{
if (isa == IUarchTest.ISA.amd64)
{
GenerateX86Asm(sb);
}
else if (isa == IUarchTest.ISA.aarch64)
{
GenerateArmAsm(sb);
}
}

public void GenerateX86Asm(StringBuilder sb)
{
string[] dependentStores = new string[4];
dependentStores[0] = " mov %rdx, (%r8, %r15, 4)";
dependentStores[1] = " mov %r15, (%r8, %rdx, 4)";
dependentStores[2] = " mov %rdx, (%r8, %r15, 4)";
dependentStores[3] = " mov %r15, (%r8, %rdx, 4)";

string[] dependentStores1 = new string[4];
dependentStores1[0] = " mov %rdx, (%r8, %r11, 4)";
dependentStores1[1] = " mov %r11, (%r8, %rdx, 4)";
dependentStores1[2] = " mov %rdx, (%r8, %r11, 4)";
dependentStores1[3] = " mov %r11, (%r8, %rdx, 4)";
UarchTestHelpers.GenerateX86AsmDivStructureTestFuncs(sb, this.Counts, this.Prefix, dependentStores, dependentStores1, false);
}

public void GenerateArmAsm(StringBuilder sb)
{
string[] dependentStores = new string[4];
dependentStores[0] = " str w25, [x2, w15, uxtw #2]";
dependentStores[1] = " str w15, [x2, w25, uxtw #2]";
dependentStores[2] = " str w25, [x2, w15, uxtw #2]";
dependentStores[3] = " str w15, [x2, w25, uxtw #2]";

string[] dependentStores1 = new string[4];
dependentStores1[0] = " str w26, [x2, w15, uxtw #2]";
dependentStores1[1] = " str w15, [x2, w26, uxtw #2]";
dependentStores1[2] = " str w26, [x2, w15, uxtw #2]";
dependentStores1[3] = " str w15, [x2, w26, uxtw #2]";
UarchTestHelpers.GenerateArmAsmDivStructureTestFuncs(sb, this.Counts, this.Prefix, dependentStores, dependentStores1, false);
}
}
}
11 changes: 11 additions & 0 deletions AsmGen/tests/StoreDataDivNsqTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public StoreDataDivNsqTest(int low, int high, int step)
public override bool SupportsIsa(IUarchTest.ISA isa)
{
if (isa == IUarchTest.ISA.amd64) return true;
if (isa == IUarchTest.ISA.aarch64) return true;
return false;
}

Expand All @@ -38,6 +39,16 @@ public override void GenerateAsm(StringBuilder sb, IUarchTest.ISA isa)
independentStores[3] = " mov %r14, (%r8, %r11, 4)";
UarchTestHelpers.GenerateX86AsmDivNsqTestFuncs(sb, this.Counts[this.Counts.Length - 1], this.Counts, this.Prefix, dependentStores, independentStores);
}
else if (isa == IUarchTest.ISA.aarch64)
{
string[] dependentStores = new string[1];
dependentStores[0] = " str w25, [x2, w15, uxtw #2]";

string[] independentStores = new string[1];
independentStores[0] = " str w15, [x2, w15, uxtw #2]";

UarchTestHelpers.GenerateArmAsmDivNsqTestFuncs(sb, this.Counts[this.Counts.Length - 1], this.Counts, this.Prefix, dependentStores, independentStores);
}
}
}
}
Loading

0 comments on commit 206c032

Please sign in to comment.