Skip to content

Commit

Permalink
save progress
Browse files Browse the repository at this point in the history
  • Loading branch information
clamchowder committed Oct 11, 2024
1 parent 2a5a540 commit be11ee8
Show file tree
Hide file tree
Showing 7 changed files with 253 additions and 27 deletions.
47 changes: 22 additions & 25 deletions AsmGen/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,33 @@ static void Main(string[] args)
{
List<IUarchTest> tests = new List<IUarchTest>();
tests.Add(new RobTest(12, 800, 1, initialDependentBranch: false));

// avx-512
tests.Add(new Stq512Test(16, 300, 1, differentLines: true));
tests.Add(new Stq512Test(16, 300, 1, differentLines: false));
tests.Add(new MaskRfTest(32, 256, 1));

tests.Add(new ZeroRobTest(12, 800, 1, initialDependentBranch: false));
tests.Add(new IntRfTest(60, 400, 1, initialDependentBranch: false));
tests.Add(new FpRfTest(60, 800, 1, initialDependentBranch: false));;
tests.Add(new FlagRfTest(8, 100, 1, initialDependentBranch: false));
tests.Add(new LdqTest(80, 250, 1, initialDependentBranch: false));
tests.Add(new StqTest(4, 300, 1, initialDependentBranch: false, spaced: true));
tests.Add(new IdrfTest(32, 192, 1));
tests.Add(new ZeroRobTest(12, 240, 1, initialDependentBranch: false));
tests.Add(new IntRfTest(32, 240, 1, initialDependentBranch: false));
tests.Add(new FpRfTest(32, 240, 1, initialDependentBranch: false));;
tests.Add(new FlagRfTest(8, 240, 1, initialDependentBranch: false));
tests.Add(new LdqTest(10, 240, 1, initialDependentBranch: false));
tests.Add(new StqTest(4, 240, 1, initialDependentBranch: false, spaced: true));
tests.Add(new MixIntVec128RfTest(4, 600, 1, initialDependentBranch: false));
tests.Add(new MixIntRfDepBranchTest(4, 100, 1, 2));
tests.Add(new MixIntRfDepBranchTest(4, 100, 1, 4));
tests.Add(new MixIntRfDepBranchTest(4, 100, 1, 8));
tests.Add(new MixIntRfDepBranchTest(4, 100, 1, 16));
tests.Add(new AddSchedTest(16, 100, 1));
tests.Add(new PdepSchedTest(10, 100, 1));
tests.Add(new RorSchedTest(10, 110, 1));
tests.Add(new ShlSchedTest(10, 100, 1));
tests.Add(new MulSchedTest(4, 64, 1));
tests.Add(new LeaSchedTest(4, 64, 1));
tests.Add(new MaddSchedTest(4, 64, 1));
tests.Add(new JumpSchedTest(4, 64, 1));
tests.Add(new MixJumpThenAddSched(20, 160, 1));
tests.Add(new JumpNsqTest(4, 80, 1));
tests.Add(new MixJumpStoreSchedTest(4, 100, 1));
tests.Add(new MixJumpStoreDataSched(4, 100, 1));
//tests.Add(new MixJumpThenAddSched(20, 160, 1));
tests.Add(new TakenJumpSchedTest(4, 64, 1));
tests.Add(new LoadSchedTest(4, 72, 1));
tests.Add(new StoreNsq(4, 100, 1));
tests.Add(new LoadNsq(10, 100, 1));
tests.Add(new MixLoadStoreSched(20, 150, 1));
tests.Add(new StoreSchedTest(4, 72, 1));
tests.Add(new StoreDataNsq(20, 70, 1));
tests.Add(new StoreDataSchedTest(4, 80, 1));
Expand All @@ -57,14 +56,14 @@ static void Main(string[] args)
tests.Add(new MixAddvJsCvtSched(8, 120, 1));
tests.Add(new AddvSched(8, 120, 1));
tests.Add(new FmovSched(8, 120, 1));
tests.Add(new FaddNsq(4, 140, 1, 200));
tests.Add(new FaddNsq(4, 64, 1, 110));
tests.Add(new AddNsq(4, 128, 1, 128));
tests.Add(new Fadd128SchedTest(4, 200, 1));
tests.Add(new Fadd256SchedTest(4, 200, 1));
tests.Add(new Fma256SchedTest(4, 200, 1));
tests.Add(new Fadd128SchedTest(4, 160, 1));
tests.Add(new Fadd256SchedTest(4, 160, 1));
tests.Add(new Fma256SchedTest(4, 160, 1));
tests.Add(new CvtSchedTest(4, 180, 1));
tests.Add(new Fadd128RfTest(200, 400, 1, false));
tests.Add(new Fadd256RfTest(200, 400, 1, Fadd256RfTest.TestMode.none));
tests.Add(new Fadd256RfTest(50, 300, 1, Fadd256RfTest.TestMode.none));
tests.Add(new BtbTest(4, BtbTest.BranchType.Unconditional));
tests.Add(new BtbTest(8, BtbTest.BranchType.Unconditional));
tests.Add(new BtbTest(16, BtbTest.BranchType.Unconditional));
Expand All @@ -74,19 +73,17 @@ static void Main(string[] args)
tests.Add(new BtbTest(8, BtbTest.BranchType.Conditional));
tests.Add(new BtbTest(16, BtbTest.BranchType.Conditional));
tests.Add(new BtbTest(32, BtbTest.BranchType.Conditional));
tests.Add(new ReturnStackTest(1, 256, 1));
tests.Add(new BranchBufferTest(4, 300, 1, initialDependentBranch: false));
tests.Add(new TakenBranchBufferTest(4, 300, 1, initialDependentBranch: false));
tests.Add(new ReturnStackTest(1, 128, 1));
tests.Add(new BranchBufferTest(4, 200, 1, initialDependentBranch: false));
tests.Add(new TakenBranchBufferTest(4, 200, 1, initialDependentBranch: false));
tests.Add(new MixBranchStoreTest(4, 100, 1, initialDependentBranch: true));
tests.Add(new IndirectBranchTest(false));
tests.Add(new BranchHistoryTest());
tests.Add(new NopLoopTest(512, 1));
tests.Add(new AddLoopTest(4, 100, 1));
tests.Add(new AeseSchedTest(4, 180, 1));
tests.Add(new VecMulNsq(4, 160, 1, 160));
tests.Add(new FpStoreDataNsqTest(20, 230, 1));
tests.Add(new FpStoreDataNsqTest(10, 115, 1));
tests.Add(new AesencNsq(4, 100, 1, 160));
tests.Add(new MmxRfTest(20, 200, 1));

List<Task> tasks = new List<Task>();
Expand Down
61 changes: 61 additions & 0 deletions AsmGen/tests/IdrfTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System.Collections.Generic;
using System.Text;

namespace AsmGen
{
public class IdrfTest : UarchTest
{
public IdrfTest(int low, int high, int step)
{
this.Counts = UarchTestHelpers.GenerateCountArray(low, high, step);
this.Prefix = "idrf";
this.Description = "Immediate/Displacement Register File";
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;
return false;
}

public override void GenerateAsm(StringBuilder sb, IUarchTest.ISA isa)
{
const string dummyBranchTargetName = "idrftest_badtarget";
if (isa == IUarchTest.ISA.amd64)
{
const int storeCount = 40;
const int addCount = 130;
List<string> testInstructions = new List<string>();
int storeIdx = 0, addIdx = 0;
for (int i = 0; i < this.Counts[this.Counts.Length - 1]; i++)
{
if (addIdx < addCount)
{
string addInstr = " add $" + (i + 1) + ", %r1" + (12 + (i % 4));
testInstructions.Add(addInstr);
addIdx++;
}
else if (storeIdx < storeCount)
{
string storeInstr = " mov %r11d, " + +(((i + 1) & 0xFF) * 4) + "(%r8)";
testInstructions.Add(storeInstr);
storeIdx++;
}
else
{
string branchInstr = " test %r11, %r11\n je {dummyBranchTargetName}";
testInstructions.Add(branchInstr);
}
}

string[] unrolledAdds = testInstructions.ToArray();
UarchTestHelpers.GenerateX86AsmStructureTestFuncs(sb, this.Counts, this.Prefix, unrolledAdds, unrolledAdds, includePtrChasingLoads: true);

sb.AppendLine($"{dummyBranchTargetName}:\n int3");
}
}
}
}
41 changes: 41 additions & 0 deletions AsmGen/tests/MixJumpStoreDataSched.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System.Text;

namespace AsmGen
{
public class MixJumpStoreDataSched : UarchTest
{
public MixJumpStoreDataSched(int low, int high, int step)
{
this.Counts = UarchTestHelpers.GenerateCountArray(low, high, step);
this.Prefix = "mixjumpstoredatasched";
this.Description = "Scheduler, Mixed Jumps and Store Data";
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;
// if (isa == IUarchTest.ISA.mips64) return true;
// if (isa == IUarchTest.ISA.riscv) return true;
return false;
}

public override void GenerateAsm(StringBuilder sb, IUarchTest.ISA isa)
{
if (isa == IUarchTest.ISA.amd64)
{
string[] unrolledJumps = new string[4];
unrolledJumps[0] = " cmp %rdi, %rsi\n je mixjumpstoredatasched_reallybadthing";
unrolledJumps[1] = " mov %rdi, (%r8)";
unrolledJumps[2] = " cmp %rdi, %rsi\n je mixjumpstoredatasched_reallybadthing";
unrolledJumps[3] = " mov %rdi, 64(%r8)";
UarchTestHelpers.GenerateX86AsmStructureTestFuncs(sb, this.Counts, this.Prefix, unrolledJumps, unrolledJumps, includePtrChasingLoads: true);

sb.AppendLine("mixjumpstoredatasched_reallybadthing:\n int3");
}
}
}
}
41 changes: 41 additions & 0 deletions AsmGen/tests/MixJumpStoreSchedTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System.Text;

namespace AsmGen
{
public class MixJumpStoreSchedTest : UarchTest
{
public MixJumpStoreSchedTest(int low, int high, int step)
{
this.Counts = UarchTestHelpers.GenerateCountArray(low, high, step);
this.Prefix = "mixjumpstoresched";
this.Description = "Scheduler, Mixed Jumps and Stores (Address Dependency)";
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;
// if (isa == IUarchTest.ISA.mips64) return true;
// if (isa == IUarchTest.ISA.riscv) return true;
return false;
}

public override void GenerateAsm(StringBuilder sb, IUarchTest.ISA isa)
{
if (isa == IUarchTest.ISA.amd64)
{
string[] unrolledJumps = new string[4];
unrolledJumps[0] = " cmp %rdi, %rsi\n je mixstorejumpsched_reallybadthing";
unrolledJumps[1] = " mov %r14, (%r8, %rdi, 2)";
unrolledJumps[2] = " cmp %rdi, %rsi\n je mixstorejumpsched_reallybadthing";
unrolledJumps[3] = " mov %r14, 64(%r8, %rdi, 2)";
UarchTestHelpers.GenerateX86AsmStructureTestFuncs(sb, this.Counts, this.Prefix, unrolledJumps, unrolledJumps, includePtrChasingLoads: true);

sb.AppendLine("mixstorejumpsched_reallybadthing:\n int3");
}
}
}
}
4 changes: 2 additions & 2 deletions AsmGen/tests/ReturnStackTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ public void GenerateX86GccAsm(StringBuilder sb)
{
string funcName = GetFunctionName(callDepth, callIdx);
sb.AppendLine($".global {funcName}");
sb.AppendLine(".align 64"); // https://github.com/clamchowder/Microbenchmarks/issues/14
sb.AppendLine(".align 128"); // https://github.com/clamchowder/Microbenchmarks/issues/14
sb.AppendLine($"{funcName}:");
if (callIdx < callDepth - 1)
{
sb.AppendLine($" add %rdi, %rax");
sb.AppendLine(" call " + GetFunctionName(callDepth, callIdx + 1));
}

sb.AppendLine(".align 64");
sb.AppendLine(".align 128");
sb.AppendLine(" ret");
}
}
Expand Down
43 changes: 43 additions & 0 deletions AsmGen/tests/RorSchedTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System.Text;

namespace AsmGen
{
public class RorSchedTest : UarchTest
{
public RorSchedTest(int low, int high, int step)
{
this.Counts = UarchTestHelpers.GenerateCountArray(low, high, step);
this.Prefix = "rorsched";
this.Description = "Scheduler, Integer Rotate by Immediate (1)";
this.FunctionDefinitionParameters = "uint64_t iterations, int *arr";
this.GetFunctionCallParameters = "structIterations, A";
this.DivideTimeByCount = false;
}

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

public override void GenerateAsm(StringBuilder sb, IUarchTest.ISA isa)
{
if (isa == IUarchTest.ISA.amd64)
{
string postLoadInstrs = " mov %rdi, %r15";
string postLoadInstrs2 = " mov %rsi, %r15";
string[] unrolledInstrs = new string[1];
unrolledInstrs[0] = " ror $1, %r15";
UarchTestHelpers.GenerateX86AsmStructureTestFuncs(
sb,
this.Counts,
this.Prefix,
unrolledInstrs,
unrolledInstrs,
postLoadInstrs1: postLoadInstrs,
postLoadInstrs2: postLoadInstrs2,
includePtrChasingLoads: false);
}
}
}
}
43 changes: 43 additions & 0 deletions AsmGen/tests/ShlSchedTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System.Text;

namespace AsmGen
{
public class ShlSchedTest : UarchTest
{
public ShlSchedTest(int low, int high, int step)
{
this.Counts = UarchTestHelpers.GenerateCountArray(low, high, step);
this.Prefix = "shlsched";
this.Description = "Scheduler, Integer Shift by Immediate (1)";
this.FunctionDefinitionParameters = "uint64_t iterations, int *arr";
this.GetFunctionCallParameters = "structIterations, A";
this.DivideTimeByCount = false;
}

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

public override void GenerateAsm(StringBuilder sb, IUarchTest.ISA isa)
{
if (isa == IUarchTest.ISA.amd64)
{
string postLoadInstrs = " mov %rdi, %r15";
string postLoadInstrs2 = " mov %rsi, %r15";
string[] unrolledInstrs = new string[1];
unrolledInstrs[0] = " shl $1, %r15";
UarchTestHelpers.GenerateX86AsmStructureTestFuncs(
sb,
this.Counts,
this.Prefix,
unrolledInstrs,
unrolledInstrs,
postLoadInstrs1: postLoadInstrs,
postLoadInstrs2: postLoadInstrs2,
includePtrChasingLoads: false);
}
}
}
}

0 comments on commit be11ee8

Please sign in to comment.