This commit is contained in:
Lily Tsuru 2008-11-17 18:29:00 -05:00
parent 4e1c631ec8
commit db9d77760c
3886 changed files with 520398 additions and 153198 deletions

Binary file not shown.

BIN
Release notes.pdf Normal file

Binary file not shown.

View File

@ -1,8 +1,6 @@
<!-- <!--
############################################################################### ###############################################################################
# #
# Microsoft Research Singularity
#
# Copyright (c) Microsoft Corporation. All rights reserved. # Copyright (c) Microsoft Corporation. All rights reserved.
# #
############################################################################### ###############################################################################

View File

@ -1,7 +1,8 @@
/////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// //
// ----------------------------------------------------------------------------
using System; using System;
using System.Text; using System.Text;

View File

@ -5,9 +5,7 @@
Copyright (c) Microsoft Corporation. All rights reserved. Copyright (c) Microsoft Corporation. All rights reserved.
File: Applications\Applications.proj
Note: This file is a convenience project for building all projects under
Applications. This file is not involved in building "distro" projects. Applications. This file is not involved in building "distro" projects.
############################################################################## ##############################################################################
@ -18,7 +16,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="Runtime\AppRuntime.proj"/> <ProjectReference Include="Runtime\AppRuntime.proj"/>
<ProjectReference Include="*\*.proj;*\*.csproj" Exclude="Runtime\*;Pong\Pong.csproj"/> <ProjectReference Include="*\*.proj;*\*.csproj" Exclude="cassinin\cassinin.csproj;Runtime\*;Pong\Pong.csproj;Namespace\AtomicTestDSP\AtomicTestDSP.csproj"/>
</ItemGroup> </ItemGroup>
<Import Project="$(SINGULARITY_ROOT)\Targets\Dirs.targets"/> <Import Project="$(SINGULARITY_ROOT)\Targets\Dirs.targets"/>

View File

@ -1,5 +1,4 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Copyright (c) Microsoft Corporation. All rights reserved. -->
<Import Project="..\..\..\..\Paths.targets" /> <Import Project="..\..\..\..\Paths.targets" />
<PropertyGroup> <PropertyGroup>

View File

@ -4,8 +4,6 @@
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// //
// File: BartokP.sg
//
// Note: Compiler Phase // Note: Compiler Phase
// //
@ -95,10 +93,9 @@ namespace Bartok.Child
uint region; uint region;
regionSize = (uint)bytes.Length; regionSize = (uint)bytes.Length;
unsafe { unsafe {
fixed (byte *pdst = &bytes[0]) { byte *pdst = &bytes[0];
region = (uint)pdst; region = (uint)pdst;
cs.ReadOpen(region, regionSize); cs.ReadOpen(region, regionSize);
}
} }
} }
@ -119,10 +116,9 @@ namespace Bartok.Child
uint region; uint region;
regionSize = (uint)bytes.Length; regionSize = (uint)bytes.Length;
unsafe { unsafe {
fixed (byte *pdst = &bytes[0]) { byte *pdst = &bytes[0];
region = (uint)pdst; region = (uint)pdst;
cs.WriteOpen(region, regionSize); cs.WriteOpen(region, regionSize);
}
} }
} }

View File

@ -1,5 +1,4 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Copyright (c) Microsoft Corporation. All rights reserved. -->
<Import Project="..\..\..\..\Paths.targets" /> <Import Project="..\..\..\..\Paths.targets" />
<PropertyGroup> <PropertyGroup>

View File

@ -4,8 +4,6 @@
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// //
// File: CompilerPhaseContract.sg
//
using Microsoft.Singularity.Channels; using Microsoft.Singularity.Channels;
using Microsoft.Singularity.Endpoint; using Microsoft.Singularity.Endpoint;

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,8 @@
Hosted Bartok requires the following change to System\RuntimeType.cs:
public override int GetHashCode() {
return unchecked((int)(
(int)Magic.addressOf(this.classVtable)
+ ((int)this.classVtable.arrayOf << 8 + rank)
+ (int)this.classVtable.structuralView));
}

View File

@ -1,5 +1,5 @@
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// //
#define NONONNULLTYPECHECK // required on Singularity, no affect on other Windows. #define NONONNULLTYPECHECK // required on Singularity, no affect on other Windows.
@ -422,25 +422,25 @@ namespace Bartok {
analysisRegistry)); analysisRegistry));
} }
/* //
phases.Add //phases.Add
(new DynamicCount // (new DynamicCount
("VirtualCallsStart", // ("VirtualCallsStart",
new DynamicCount.OpcodeFilter // new DynamicCount.OpcodeFilter
(Operator.OpCodes.CallVirtual, // (Operator.OpCodes.CallVirtual,
Operator.OpCodes.InterfaceCall), // Operator.OpCodes.InterfaceCall),
DynamicCount.Granularity.PerSite)); // DynamicCount.Granularity.PerSite));
*/ //
/* //
phases.Add //phases.Add
(new DynamicCount // (new DynamicCount
("ASCstart", // ("ASCstart",
new DynamicCount.OpcodeFilter // new DynamicCount.OpcodeFilter
(Operator.OpCodes.CheckArrayStore, // (Operator.OpCodes.CheckArrayStore,
Operator.OpCodes.CheckVectorStore), // Operator.OpCodes.CheckVectorStore),
DynamicCount.Granularity.PerSite)); // DynamicCount.Granularity.PerSite));
*/ //
if (StageControl.PtrAnalysis) { if (StageControl.PtrAnalysis) {
phases.Add(PtrTypeSimpleSystem.CreateAnalysis()); phases.Add(PtrTypeSimpleSystem.CreateAnalysis());
@ -467,23 +467,23 @@ namespace Bartok {
phases.Add(new Convert.ToMir(mask)); phases.Add(new Convert.ToMir(mask));
} }
/* SPOONS: region related phases: // SPOONS: region related phases:
// A temporary pass that cleans up the scratch objects so that the //// A temporary pass that cleans up the scratch objects so that the
// DemandAnalysis is not confused by the randomness that the tree //// DemandAnalysis is not confused by the randomness that the tree
// shaker leaves behind. //// shaker leaves behind.
phases.Add(new CleanScratch()); //phases.Add(new CleanScratch());
//
// Build a "Foo_layout" for each class "Foo"; other setup required //// Build a "Foo_layout" for each class "Foo"; other setup required
// by DemandAnalysis. //// by DemandAnalysis.
phases.Add(new LayoutBuilder()); //phases.Add(new LayoutBuilder());
//
// Perform first- and last-use analysis; add explicit region //// Perform first- and last-use analysis; add explicit region
// variables and effects. //// variables and effects.
phases.Add(new DemandAnalysis()); //phases.Add(new DemandAnalysis());
//
// Print the code //// Print the code
phases.Add(new TypeDataPrettyPhase("After Demand:")); //phases.Add(new TypeDataPrettyPhase("After Demand:"));
*/ //
// Perform first- and last-use analysis; add explicit region // Perform first- and last-use analysis; add explicit region
// variables and effects. // variables and effects.
@ -774,67 +774,67 @@ namespace Bartok {
(new Convert.ToMir(Convert.ToMir.Mask.Vararg2))); (new Convert.ToMir(Convert.ToMir.Mask.Vararg2)));
} }
/* //
// We do not know where all of the calls will be because lowering can //// We do not know where all of the calls will be because lowering can
// introduce calls. We make a best guess here. If we moved all //// introduce calls. We make a best guess here. If we moved all
// call-generating lowering to HIR (via ToMir or equivalent), then //// call-generating lowering to HIR (via ToMir or equivalent), then
// this could be easily done. We are currently missing calls for the //// this could be easily done. We are currently missing calls for the
// following: //// following:
// - pinvoke, stubs, etc //// - pinvoke, stubs, etc
// - some arithmetic conversions //// - some arithmetic conversions
// - casts - can't add because not all are calls //// - casts - can't add because not all are calls
// - RC, tryall, atomic //// - RC, tryall, atomic
// - others? //// - others?
phases.Add //phases.Add
(new DynamicCount // (new DynamicCount
("Calls", // ("Calls",
new DynamicCount.OpcodeFilter // new DynamicCount.OpcodeFilter
(Operator.OpCodes.Call, // (Operator.OpCodes.Call,
Operator.OpCodes.CallIndirect, // Operator.OpCodes.CallIndirect,
Operator.OpCodes.CallVirtual, // Operator.OpCodes.CallVirtual,
Operator.OpCodes.InterfaceCall, // Operator.OpCodes.InterfaceCall,
Operator.OpCodes.MonitorEnter, // Operator.OpCodes.MonitorEnter,
Operator.OpCodes.MonitorExit, // Operator.OpCodes.MonitorExit,
Operator.OpCodes.IndirectToData, // Operator.OpCodes.IndirectToData,
Operator.OpCodes.CustomGetSize, // Operator.OpCodes.CustomGetSize,
Operator.OpCodes.CheckVectorStore, // Operator.OpCodes.CheckVectorStore,
Operator.OpCodes.CheckVectorElementAddress, // Operator.OpCodes.CheckVectorElementAddress,
Operator.OpCodes.InitVector, // Operator.OpCodes.InitVector,
Operator.OpCodes.CheckArrayStore, // Operator.OpCodes.CheckArrayStore,
Operator.OpCodes.CheckArrayElementAddress, // Operator.OpCodes.CheckArrayElementAddress,
Operator.OpCodes.InitArray, // Operator.OpCodes.InitArray,
Operator.OpCodes.InitType, // Operator.OpCodes.InitType,
Operator.OpCodes.GetITable, // Operator.OpCodes.GetITable,
Operator.OpCodes.NewObject, // Operator.OpCodes.NewObject,
Operator.OpCodes.NewVector, // Operator.OpCodes.NewVector,
Operator.OpCodes.NewArray), // Operator.OpCodes.NewArray),
DynamicCount.Granularity.Global)); // DynamicCount.Granularity.Global));
phases.Add(new TypeDataDummyPhase()); //phases.Add(new TypeDataDummyPhase());
phases.Add //phases.Add
(new DynamicCount // (new DynamicCount
("VirtualCallsEnd", // ("VirtualCallsEnd",
new DynamicCount.OpcodeFilter // new DynamicCount.OpcodeFilter
(Operator.OpCodes.CallVirtual, // (Operator.OpCodes.CallVirtual,
Operator.OpCodes.InterfaceCall), // Operator.OpCodes.InterfaceCall),
DynamicCount.Granularity.PerSite)); // DynamicCount.Granularity.PerSite));
//
phases.Add //phases.Add
(new DynamicCount // (new DynamicCount
("ASCend", // ("ASCend",
new DynamicCount.OpcodeFilter // new DynamicCount.OpcodeFilter
(Operator.OpCodes.CheckArrayStore, // (Operator.OpCodes.CheckArrayStore,
Operator.OpCodes.CheckVectorStore), // Operator.OpCodes.CheckVectorStore),
DynamicCount.Granularity.PerSite)); // DynamicCount.Granularity.PerSite));
phases.Add(new TypeDataDummyPhase()); //phases.Add(new TypeDataDummyPhase());
//
phases.Add //phases.Add
(new DynamicCount // (new DynamicCount
("WB", // ("WB",
new DynamicCount.OpcodeFilter // new DynamicCount.OpcodeFilter
(Operator.OpCodes.LocWriteBarrier), // (Operator.OpCodes.LocWriteBarrier),
DynamicCount.Granularity.Global)); // DynamicCount.Granularity.Global));
phases.Add(new TypeDataDummyPhase()); //phases.Add(new TypeDataDummyPhase());
*/ //
if (StageControl.WholeProgram && StageControl.OptRuntimeData) { if (StageControl.WholeProgram && StageControl.OptRuntimeData) {
phases.Add(new RuntimeData()); phases.Add(new RuntimeData());

View File

@ -1,5 +1,4 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Copyright (c) Microsoft Corporation. All rights reserved. -->
<Import Project="..\..\..\..\Paths.targets" /> <Import Project="..\..\..\..\Paths.targets" />
<PropertyGroup> <PropertyGroup>

View File

@ -4,8 +4,6 @@
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// //
// File: Proxy.sg
//
// Note: Compiler Phase // Note: Compiler Phase
// //
@ -57,10 +55,9 @@ namespace Bartok.Regalloc
uint region; uint region;
regionSize = (uint)bytes.Length; regionSize = (uint)bytes.Length;
unsafe { unsafe {
fixed (byte *pdst = &bytes[0]) { byte *pdst = &bytes[0];
region = (uint)pdst; region = (uint)pdst;
cs.ReadOpen(region, regionSize); cs.ReadOpen(region, regionSize);
}
} }
} }
@ -81,10 +78,9 @@ namespace Bartok.Regalloc
uint region; uint region;
regionSize = (uint)bytes.Length; regionSize = (uint)bytes.Length;
unsafe { unsafe {
fixed (byte *pdst = &bytes[0]) { byte *pdst = &bytes[0];
region = (uint)pdst; region = (uint)pdst;
cs.WriteOpen(region, regionSize); cs.WriteOpen(region, regionSize);
}
} }
} }
@ -131,7 +127,7 @@ namespace Bartok.Regalloc
// Start up our child // Start up our child
string[] args = new string[3]; string[] args = new string[3];
args[0] = "BartokP.x86"; args[0] = "BartokP";
args[1] = "-where"; args[1] = "-where";
args[2] = "!"; args[2] = "!";
Process cproc = new Process(args, (Endpoint * in ExHeap)ep); Process cproc = new Process(args, (Endpoint * in ExHeap)ep);
@ -388,5 +384,5 @@ namespace Bartok.Regalloc
private const string coloringName = "Back End Coloring Coloring"; private const string coloringName = "Back End Coloring Coloring";
private static int coloringId; private static int coloringId;
#endif #endif
} /* class GraphColoring */ } // class GraphColoring
} }

View File

@ -1,3 +1,11 @@
<!--
###############################################################################
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
###############################################################################
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\Paths.targets"/> <Import Project="..\..\Paths.targets"/>

View File

@ -4,8 +4,6 @@
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// //
// File: CreateProcess.cs
//
// Note: Singularity micro-benchmark program. // Note: Singularity micro-benchmark program.
// //
using Microsoft.Singularity; using Microsoft.Singularity;
@ -175,7 +173,7 @@ namespace Microsoft.Singularity.Applications
public void Start() public void Start()
{ {
if (!AtRing3) { if (!AtRing3) {
disabled = Processor.DisableInterrupts(); disabled = Processor.DisableLocalPreemption();
} }
int collectorCount; int collectorCount;
@ -218,7 +216,8 @@ namespace Microsoft.Singularity.Applications
Reset(1, PerfEvtSel.COUNT | PerfEvtSel.RetiredInstructions); Reset(1, PerfEvtSel.COUNT | PerfEvtSel.RetiredInstructions);
Reset(2, PerfEvtSel.COUNT | PerfEvtSel.RetiredBranchInstructions); Reset(2, PerfEvtSel.COUNT | PerfEvtSel.RetiredBranchInstructions);
Reset(3, PerfEvtSel.COUNT | PerfEvtSel.RequestsToL2Cache | 0x400); Reset(3, PerfEvtSel.COUNT | PerfEvtSel.RequestsToL2Cache | 0x400);
} else { }
else {
// We're not allowed to reset the perf counters, so take note // We're not allowed to reset the perf counters, so take note
// of their current values; we will subtract from this later. // of their current values; we will subtract from this later.
x64_i0 = Processor.ReadPmc(0); x64_i0 = Processor.ReadPmc(0);
@ -275,7 +274,7 @@ namespace Microsoft.Singularity.Applications
endStackRets = stackRets; endStackRets = stackRets;
if (!AtRing3) { if (!AtRing3) {
Processor.RestoreInterrupts(disabled); Processor.RestoreLocalPreemption(disabled);
} }
this.iterations = iterations; this.iterations = iterations;
@ -327,7 +326,8 @@ namespace Microsoft.Singularity.Applications
EvtSelToString(e1), EvtSelToString(e1),
EvtSelToString(e2), EvtSelToString(e2),
EvtSelToString(e3))); EvtSelToString(e3)));
} else { }
else {
// Subtract from the initial perf-counter values to // Subtract from the initial perf-counter values to
// get the delta we want // get the delta we want
x64_p0 -= x64_i0; x64_p0 -= x64_i0;
@ -353,7 +353,7 @@ namespace Microsoft.Singularity.Applications
string [] arguments; string [] arguments;
for (long i = 0; i < repetitions; i++) { for (long i = 0; i < repetitions; i++) {
arguments = new string[2]; arguments = new string[2];
arguments[0] = "testpe.x86"; arguments[0] = "testpe";
arguments[1] = "!"; // Special flag to not notify debugger. arguments[1] = "!"; // Special flag to not notify debugger.
TimeProcess(arguments, runQuiet); TimeProcess(arguments, runQuiet);
} }

View File

@ -1,8 +1,6 @@
<!-- <!--
############################################################################### ###############################################################################
# #
# Microsoft Research Singularity
#
# Copyright (c) Microsoft Corporation. All rights reserved. # Copyright (c) Microsoft Corporation. All rights reserved.
# #
############################################################################### ###############################################################################

View File

@ -0,0 +1,297 @@
///////////////////////////////////////////////////////////////////////////////
//
// Microsoft Research Singularity
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Note: Performance measurer for Singularity Benchmark
//
using System;
using Microsoft.Singularity.V1.Services;
namespace Microsoft.Singularity.Applications
{
public struct PerfSnap
{
// Global options for all instances
static bool xmlOutput = false;
static bool atRing3 = false;
private bool disabled;
private long begCycleCount;
private long endCycleCount;
private long begSwitchCount;
private long endSwitchCount;
private long begInterruptCount;
private long endInterruptCount;
private long begKernelGcCount;
private long endKernelGcCount;
private long begProcessGcCount;
private long endProcessGcCount;
private long iterations;
private ulong begAllocatedCount;
private ulong begAllocatedBytes;
private ulong begFreedCount;
private ulong begFreedBytes;
private ulong endAllocatedCount;
private ulong endAllocatedBytes;
private ulong endFreedCount;
private ulong endFreedBytes;
private ulong begStackGets;
private ulong begStackRets;
private ulong endStackGets;
private ulong endStackRets;
private long begTicks;
private long endTicks;
public long Cycles { get { return endCycleCount - begCycleCount; } }
public long Interrupts { get { return endInterruptCount - begInterruptCount; } }
public long Switches { get { return endSwitchCount - begSwitchCount; } }
public long KernelGCs { get { return endKernelGcCount - begKernelGcCount; } }
public long ProcessGCs { get { return endProcessGcCount - begProcessGcCount; } }
public ulong AllocatedCount { get { return endAllocatedCount-begAllocatedCount; } }
public ulong AllocatedBytes { get { return endAllocatedBytes-begAllocatedBytes; } }
public ulong FreedCount { get { return endFreedCount - begFreedCount; } }
public ulong FreedBytes { get { return endFreedBytes - begFreedBytes; } }
public ulong StackGets { get { return endStackGets - begStackGets; } }
public ulong StackRets { get { return endStackRets - begStackRets; } }
public long ElapsedTicks { get { return endTicks - begTicks; } }
public void Start()
{
if (!atRing3) {
// disabled = Processor.DisableInterrupts();
}
int collectorCount;
long collectorMillis;
long collectorBytes;
GC.PerformanceCounters(out collectorCount,
out collectorMillis,
out collectorBytes);
ulong stackGets;
ulong stackRets;
StackService.GetUsageStatistics(out stackGets,
out stackRets);
begStackGets = stackGets;
begStackRets = stackRets;
ulong allocatedCount;
ulong allocatedBytes;
ulong freedCount;
ulong freedBytes;
PageTableService.GetUsageStatistics(out allocatedCount,
out allocatedBytes,
out freedCount,
out freedBytes);
begAllocatedCount = allocatedCount;
begAllocatedBytes = allocatedBytes;
begFreedCount = freedCount;
begFreedBytes = freedBytes;
begInterruptCount = ProcessService.GetKernelInterruptCount();
begSwitchCount = ProcessService.GetContextSwitchCount();
begKernelGcCount = ProcessService.GetKernelGcCount();
begProcessGcCount = collectorCount;
begTicks = DateTime.Now.Ticks;
#if x64_PERF
// Set up for perf counting
if (!atRing3) {
// Reset the performance counters to what we're interested in.
Reset(0, PerfEvtSel.COUNT | PerfEvtSel.CyclesNotHalted);
Reset(1, PerfEvtSel.COUNT | PerfEvtSel.RetiredInstructions);
Reset(2, PerfEvtSel.COUNT | PerfEvtSel.RetiredBranchInstructions);
Reset(3, PerfEvtSel.COUNT | PerfEvtSel.RequestsToL2Cache | 0x400);
}
else {
// We're not allowed to reset the perf counters, so take note
// of their current values; we will subtract from this later.
x64_i0 = Processor.ReadPmc(0);
x64_i1 = Processor.ReadPmc(1);
x64_i2 = Processor.ReadPmc(2);
x64_i3 = Processor.ReadPmc(3);
}
#endif
begCycleCount = unchecked((long)Processor.CycleCount);
}
public void Finish(long iterations)
{
endCycleCount = unchecked((long)Processor.CycleCount);
#if X64_PERF
x64_p0 = Processor.ReadPmc(0);
x64_p1 = Processor.ReadPmc(1);
x64_p2 = Processor.ReadPmc(2);
x64_p3 = Processor.ReadPmc(3);
#endif
endInterruptCount = ProcessService.GetKernelInterruptCount();
endSwitchCount = ProcessService.GetContextSwitchCount();
endKernelGcCount = ProcessService.GetKernelGcCount();
int collectorCount;
long collectorMillis;
long collectorBytes;
GC.PerformanceCounters(out collectorCount,
out collectorMillis,
out collectorBytes);
endProcessGcCount = collectorCount;
ulong allocatedCount;
ulong allocatedBytes;
ulong freedCount;
ulong freedBytes;
PageTableService.GetUsageStatistics(out allocatedCount,
out allocatedBytes,
out freedCount,
out freedBytes);
endAllocatedCount = allocatedCount;
endAllocatedBytes = allocatedBytes;
endFreedCount = freedCount;
endFreedBytes = freedBytes;
ulong stackGets;
ulong stackRets;
StackService.GetUsageStatistics(out stackGets,
out stackRets);
endStackGets = stackGets;
endStackRets = stackRets;
endTicks = DateTime.Now.Ticks;
if (!atRing3) {
// /ravi/07/14/07/ Processor.RestoreInterrupts(disabled);
}
this.iterations = iterations;
}
public void Display(string name)
{
if (xmlOutput) {
DisplayXml(name);
}
else {
DisplayText(name);
}
}
private static void WriteXmlValue(string name, long value)
{
DualWriteLine(
String.Format(" <Measurement> <name> {0} </name> <value> {1:d} </value> </Measurement>", name, value)
);
}
private static void WriteXmlValue(string name, ulong value)
{
DualWriteLine(
String.Format(" <Measurement> <name> {0} </name> <value> {1:d} </value> </Measurement>", name, value)
);
}
private void DisplayXml(string name)
{
DualWriteLine(
String.Format("<Microbenchmark Name=\"{0}\">", name)
);
WriteXmlValue("CyclesPerIteration", Cycles / iterations);
WriteXmlValue("Cycles", Cycles);
WriteXmlValue("Iterations", iterations);
WriteXmlValue("Switches", Switches);
WriteXmlValue("Interrupts", Interrupts);
WriteXmlValue("KernelGCs", KernelGCs);
WriteXmlValue("ProcessGCs", ProcessGCs);
WriteXmlValue("AllocationCount", AllocatedCount);
WriteXmlValue("AllocationBytes", AllocatedBytes);
WriteXmlValue("FreedCount", FreedCount);
WriteXmlValue("FreedBytes", FreedBytes);
WriteXmlValue("StackGetCount", StackGets);
WriteXmlValue("StackReturnCount", StackRets);
WriteXmlValue("ElapsedTicks", ElapsedTicks);
DualWriteLine("</Microbenchmark>");
}
private void DisplayText(string name)
{
DualWriteLine(
String.Format("{0,-16} {1,6:d} x{2,8:d} {3,6:d} " +
"[swi={4,6:d} int={5,3:d} gc={6:d}/{7:d}]",
name,
iterations,
Cycles / iterations,
ElapsedTicks / iterations,
Switches,
Interrupts,
KernelGCs,
ProcessGCs)
);
if (AllocatedCount > 1 || FreedCount > 1 || StackGets > 1) {
DualWriteLine(
string.Format(
" " +
"[alloc={0,4:d}/{1,8:x} free={2,4:d}/{3,8:x} " +
"stack={4,4:d}/{5,4:d}]",
AllocatedCount,
AllocatedBytes,
FreedCount,
FreedBytes,
StackGets,
StackRets)
);
}
#if x64_PERF
if (!atRing3) {
// Read off the current MSR values and turn them
// into nice labels
ulong e0 = Processor.ReadMsr(0xc0010000);
ulong e1 = Processor.ReadMsr(0xc0010001);
ulong e2 = Processor.ReadMsr(0xc0010002);
ulong e3 = Processor.ReadMsr(0xc0010003);
DualWriteLine(
String.Format("evt: {0,16} {1,16} {2,16} {3,16}",
EvtSelToString(e0),
EvtSelToString(e1),
EvtSelToString(e2),
EvtSelToString(e3)));
}
else {
// Subtract from the initial perf-counter values to
// get the delta we want
x64_p0 -= x64_i0;
x64_p1 -= x64_i1;
x64_p2 -= x64_i2;
x64_p3 -= x64_i3;
}
DualWriteLine(
String.Format("pmc: {0:d16} {1:d16} {2:d16} {3:d16} {4:d16}\n\n",
Cycles, x64_p0, x64_p1, x64_p2, x64_p3));
#endif
}
private static void DualWriteLine(string message)
{
Console.WriteLine(message);
DebugStub.WriteLine(message);
}
public static void SetOptions(bool ring3, bool doXmlOutput)
{
PerfSnap.atRing3 = ring3;
PerfSnap.xmlOutput = doXmlOutput;
}
}
}

View File

@ -0,0 +1,27 @@
<!--
###############################################################################
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
###############################################################################
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\..\Paths.targets" />
<PropertyGroup>
<OutputType>Exe</OutputType>
<AssemblyName>schedbench</AssemblyName>
<AssumeFieldsNonNull>true</AssumeFieldsNonNull>
</PropertyGroup>
<ItemGroup>
<Compile Include="PerfSnap.sg" />
<Compile Include="SchedBench.sg" />
<ProjectReference Include="$(SINGULARITY_ROOT)\Contracts\Diagnostics.Contracts\Diagnostics.Contracts.csproj" />
<ProjectReference Include="$(SINGULARITY_ROOT)\Libraries\DirectoryService.Utils\DirectoryService.Utils.csproj" />
</ItemGroup>
<Import Project="$(SINGULARITY_ROOT)\Targets\ConsoleCategory.targets" />
</Project>

File diff suppressed because it is too large Load Diff

View File

@ -4,8 +4,6 @@
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// //
// File: SharedHeapBench.cs
//
// Note: Singularity micro-benchmark program. // Note: Singularity micro-benchmark program.
// //
using Microsoft.Singularity; using Microsoft.Singularity;
@ -24,7 +22,8 @@ using Microsoft.Singularity.Io;
using Microsoft.Singularity.Configuration; using Microsoft.Singularity.Configuration;
[assembly: Transform(typeof(ApplicationResourceTransform))] [assembly: Transform(typeof(ApplicationResourceTransform))]
namespace Microsoft.Singularity.Applications { namespace Microsoft.Singularity.Applications
{
[ConsoleCategory(HelpMessage="Show attributes associated with a file", DefaultAction=true)] [ConsoleCategory(HelpMessage="Show attributes associated with a file", DefaultAction=true)]
internal class Parameters { internal class Parameters {
[InputEndpoint("data")] [InputEndpoint("data")]

View File

@ -1,8 +1,6 @@
<!-- <!--
############################################################################### ###############################################################################
# #
# Microsoft Research Singularity
#
# Copyright (c) Microsoft Corporation. All rights reserved. # Copyright (c) Microsoft Corporation. All rights reserved.
# #
############################################################################### ###############################################################################

View File

@ -4,8 +4,6 @@
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// //
// File: BenchChild.sg
//
// Note: Simple ping-pong second child process // Note: Simple ping-pong second child process
// //
@ -52,12 +50,13 @@ namespace Microsoft.Singularity.Applications.Singbench
if (config.doWhere) { if (config.doWhere) {
if (Processor.AtKernelPrivilege()) { if (Processor.AtKernelPrivilege()) {
DualWriteLine("Benchchild running at KERNEL privilege"); DualWriteLine("Benchchild running at KERNEL privilege");
} else { }
else {
DualWriteLine("Benchchild running at USER privilege"); DualWriteLine("Benchchild running at USER privilege");
} }
} }
ExtensionContract.Exp ep = (config.sendRef).Acquire(); ExtensionContract.Exp ep = ((!)config.sendRef).Acquire();
SendTestContract.Exp simpleConn = ep as SendTestContract.Exp; SendTestContract.Exp simpleConn = ep as SendTestContract.Exp;
@ -82,7 +81,7 @@ namespace Microsoft.Singularity.Applications.Singbench
conn.SendTestReady(); conn.SendTestReady();
int arg; int arg;
while(true) { while (true) {
conn.RecvReq(out arg); conn.RecvReq(out arg);
if (arg == -1) { if (arg == -1) {

View File

@ -1,8 +1,6 @@
<!-- <!--
############################################################################### ###############################################################################
# #
# Microsoft Research Singularity
#
# Copyright (c) Microsoft Corporation. All rights reserved. # Copyright (c) Microsoft Corporation. All rights reserved.
# #
############################################################################### ###############################################################################
@ -14,7 +12,6 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<AssemblyName>benchchild</AssemblyName> <AssemblyName>benchchild</AssemblyName>
<AssumeFieldsNonNull>true</AssumeFieldsNonNull>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -4,7 +4,6 @@
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// //
// File: MemoryContract.sg
// Note: Contract definition for the memory diagnostic module // Note: Contract definition for the memory diagnostic module
// //

View File

@ -0,0 +1,27 @@
<!--
###############################################################################
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
###############################################################################
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\..\..\Paths.targets" />
<PropertyGroup>
<OutputType>Library</OutputType>
<AssemblyName>Singbench.Contracts</AssemblyName>
</PropertyGroup>
<ItemGroup>
<Compile Include="ChannelTestContract.sg" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(SINGULARITY_ROOT)\Contracts\Directory.Contracts\Directory.Contracts.Kernel.csproj" />
</ItemGroup>
<Import Project="$(SINGULARITY_ROOT)\Targets\KernelLibrary.targets" />
</Project>

View File

@ -1,8 +1,6 @@
<!-- <!--
############################################################################### ###############################################################################
# #
# Microsoft Research Singularity
#
# Copyright (c) Microsoft Corporation. All rights reserved. # Copyright (c) Microsoft Corporation. All rights reserved.
# #
############################################################################### ###############################################################################
@ -13,7 +11,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AssemblyName>SingBench.Contracts</AssemblyName> <AssemblyName>Singbench.Contracts</AssemblyName>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,3 +1,11 @@
<!--
###############################################################################
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
###############################################################################
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\..\Paths.targets"/> <Import Project="..\..\..\Paths.targets"/>

View File

@ -0,0 +1,127 @@
///////////////////////////////////////////////////////////////////////////////
//
// Microsoft Research Singularity
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
using Microsoft.Singularity.Channels;
using Microsoft.Singularity.Diagnostics.Contracts;
using Microsoft.Singularity.Endpoint;
using Microsoft.Singularity.Directory;
using Microsoft.Singularity.V1.Services;
using Microsoft.Singularity.Io;
using Microsoft.Singularity.Configuration;
using System;
using System.Runtime.CompilerServices;
using System.Threading;
using Microsoft.Contracts;
using Microsoft.SingSharp.Reflection;
using Microsoft.Singularity.Applications;
using Allocation = Microsoft.Singularity.V1.Services.SharedHeapService.Allocation;
namespace Microsoft.Singularity.Applications.Singbench
{
public sealed class Child
{
public static void ReceivePerf(int iterations)
{
int doit = iterations / 2;
// Make a new channel.
SendTestContract.Imp! childImp;
SendTestContract.Exp! childExp;
SendTestContract.NewChannel(out childImp, out childExp);
// Start up our child
string[] args = new string[3];
args[0] = "BenchChild";
args[1] = "-where";
args[2] = "!";
Process child = new Process(args, (Endpoint * in ExHeap)childExp);
// set the where parameter to true
ParameterCode code;
code = child.SetStartupBoolArg(0, true);
if (code != ParameterCode.Success) {
Console.WriteLine("unable to set bool index 0. error={0}", code);
delete childImp;
return;
}
child.Start();
childImp.RecvTestReady();
PerfSnap snap = new PerfSnap();
snap.Start();
try {
int arg;
for (int i = 0; i < doit; i++) {
arg = i;
childImp.SendReq(arg);
childImp.RecvResp(out arg);
}
}
finally {
snap.Finish(iterations);
}
childImp.SendReq(-1);
delete childImp;
child.Join();
snap.Display("CHILD S/R");
}
////////////////////////////// Child send-receive performance test
//
public static void ReceivePerf2(int iterations, int messageBytes)
{
// Make a new channel.
BufferTestContract.Imp! childImp;
BufferTestContract.Exp! childExp;
BufferTestContract.NewChannel(out childImp, out childExp);
// Start up our child
string[] args = new string[2];
args[0] = "BenchChild";
args[1] = "!";
Process child = new Process(args, (Endpoint * in ExHeap)childExp);
child.Start();
childImp.RecvBufferReady();
byte[]! in ExHeap buffer = new [ExHeap] byte[messageBytes];
PerfSnap snap = new PerfSnap();
snap.Start();
try {
for (int i = 0; i < iterations; i++) {
childImp.SendReq(iterations - i - 1, buffer);
childImp.RecvResp(out buffer);
}
}
finally {
// Factor of two for one-sided send-receive only
snap.Finish(2 * iterations);
delete buffer;
}
delete childImp;
child.Join();
if (messageBytes < 1024) {
snap.Display(String.Format("Child S/RB-{0}", messageBytes));
}
else {
snap.Display(String.Format("Child S/RB-{0}K",
messageBytes / 1024));
}
}
}
}

View File

@ -0,0 +1,62 @@
///////////////////////////////////////////////////////////////////////////////
//
// Microsoft Research Singularity
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
using Microsoft.Singularity.Channels;
using Microsoft.Singularity.Diagnostics.Contracts;
using Microsoft.Singularity.Endpoint;
using Microsoft.Singularity.Directory;
using Microsoft.Singularity.V1.Services;
using Microsoft.Singularity.Io;
using Microsoft.Singularity.Configuration;
using System;
using System.Runtime.CompilerServices;
using System.Threading;
using Microsoft.Contracts;
using Microsoft.SingSharp.Reflection;
using Microsoft.Singularity.Applications;
using Allocation = Microsoft.Singularity.V1.Services.SharedHeapService.Allocation;
[assembly: Transform(typeof(ApplicationResourceTransform))]
namespace Microsoft.Singularity.Applications.Singbench
{
[ConsoleCategory(HelpMessage="Singularity Benchmark Application", DefaultAction=true)]
internal sealed class Parameters
{
[InputEndpoint("data")]
public readonly TRef<UnicodePipeContract.Exp:READY> Stdin;
[OutputEndpoint("data")]
public readonly TRef<UnicodePipeContract.Imp:READY> Stdout;
[Endpoint]
public readonly TRef<MemoryContract.Imp:Start> memoryRef;
[BoolParameter( "b", Default=false , HelpMessage="Break at start of tests.")]
internal bool breakIn;
[LongParameter( "i", Default=10000 , HelpMessage="Iterate tests <n> times.")]
internal long iterations;
[BoolParameter( "n", Default=true , HelpMessage="No GC between tests.")]
internal bool allowGC;
[BoolParameter( "w", Default=false , HelpMessage="Wait for key press between tests.")]
internal bool pauseForKeys;
[BoolParameter( "x", Default=false , HelpMessage="XML output.")]
internal bool xmlOutput;
reflective internal Parameters();
internal int AppMain() {
return SingBench.AppMain(this);
}
}
}

View File

@ -4,8 +4,6 @@
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// //
// File: PerfSnap.sg
//
// Note: Performance measurer for Singularity Benchmark // Note: Performance measurer for Singularity Benchmark
// //
@ -62,7 +60,7 @@ namespace Microsoft.Singularity.Applications.Singbench
public void Start() public void Start()
{ {
if (!atRing3) { if (!atRing3) {
disabled = Processor.DisableInterrupts(); // disabled = Processor.DisableInterrupts();
// flush out pending IO interrupts // flush out pending IO interrupts
Thread.Yield(); Thread.Yield();
Thread.Yield(); Thread.Yield();
@ -111,7 +109,8 @@ namespace Microsoft.Singularity.Applications.Singbench
Reset(1, PerfEvtSel.COUNT | PerfEvtSel.RetiredInstructions); Reset(1, PerfEvtSel.COUNT | PerfEvtSel.RetiredInstructions);
Reset(2, PerfEvtSel.COUNT | PerfEvtSel.RetiredBranchInstructions); Reset(2, PerfEvtSel.COUNT | PerfEvtSel.RetiredBranchInstructions);
Reset(3, PerfEvtSel.COUNT | PerfEvtSel.RequestsToL2Cache | 0x400); Reset(3, PerfEvtSel.COUNT | PerfEvtSel.RequestsToL2Cache | 0x400);
} else { }
else {
// We're not allowed to reset the perf counters, so take note // We're not allowed to reset the perf counters, so take note
// of their current values; we will subtract from this later. // of their current values; we will subtract from this later.
x64_i0 = Processor.ReadPmc(0); x64_i0 = Processor.ReadPmc(0);
@ -168,7 +167,7 @@ namespace Microsoft.Singularity.Applications.Singbench
endStackRets = stackRets; endStackRets = stackRets;
if (!atRing3) { if (!atRing3) {
Processor.RestoreInterrupts(disabled); // Processor.RestoreInterrupts(disabled);
} }
this.iterations = iterations; this.iterations = iterations;
@ -178,7 +177,8 @@ namespace Microsoft.Singularity.Applications.Singbench
{ {
if (xmlOutput) { if (xmlOutput) {
DisplayXml(name); DisplayXml(name);
} else { }
else {
DisplayText(name); DisplayText(name);
} }
} }
@ -263,7 +263,8 @@ namespace Microsoft.Singularity.Applications.Singbench
EvtSelToString(e1), EvtSelToString(e1),
EvtSelToString(e2), EvtSelToString(e2),
EvtSelToString(e3))); EvtSelToString(e3)));
} else { }
else {
// Subtract from the initial perf-counter values to // Subtract from the initial perf-counter values to
// get the delta we want // get the delta we want
x64_p0 -= x64_i0; x64_p0 -= x64_i0;

View File

@ -4,10 +4,7 @@
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// //
// File: SingBench.sg
//
// Note: Benchmark suite for Singularity primitives
//
using Microsoft.Singularity.Channels; using Microsoft.Singularity.Channels;
using Microsoft.Singularity.Diagnostics.Contracts; using Microsoft.Singularity.Diagnostics.Contracts;
using Microsoft.Singularity.Endpoint; using Microsoft.Singularity.Endpoint;
@ -23,44 +20,11 @@ using System.Threading;
using Microsoft.Contracts; using Microsoft.Contracts;
using Microsoft.SingSharp.Reflection; using Microsoft.SingSharp.Reflection;
using Microsoft.Singularity.Applications; using Microsoft.Singularity.Applications;
[assembly: Transform(typeof(ApplicationResourceTransform))]
using Allocation = Microsoft.Singularity.V1.Services.SharedHeapService.Allocation;
namespace Microsoft.Singularity.Applications.Singbench namespace Microsoft.Singularity.Applications.Singbench
{ {
[ConsoleCategory(HelpMessage="Singularity Benchmark Application", DefaultAction=true)]
internal sealed class Parameters
{
[InputEndpoint("data")]
public readonly TRef<UnicodePipeContract.Exp:READY> Stdin;
[OutputEndpoint("data")]
public readonly TRef<UnicodePipeContract.Imp:READY> Stdout;
[Endpoint]
public readonly TRef<MemoryContract.Imp:Start> memoryRef;
[BoolParameter( "b", Default=false , HelpMessage="Break at start of tests.")]
internal bool breakIn;
[BoolParameter( "n", Default=true , HelpMessage="No GC between tests.")]
internal bool allowGC;
[BoolParameter( "w", Default=false , HelpMessage="Wait for key press between tests.")]
internal bool pauseForKeys;
[BoolParameter( "x", Default=false , HelpMessage="XML output.")]
internal bool xmlOutput;
[LongParameter( "i", Default=10000 , HelpMessage="Iterate tests <n> times.")]
internal long iterations;
reflective internal Parameters();
internal int AppMain() {
return SingBench.AppMain(this);
}
}
public class SingBench public class SingBench
{ {
private static bool atRing3; private static bool atRing3;
@ -244,19 +208,22 @@ namespace Microsoft.Singularity.Applications.Singbench
PerfSnap snap = new PerfSnap(); PerfSnap snap = new PerfSnap();
bool saved = Processor.DisableInterrupts(); bool saved = Processor.DisableLocalPreemption();
System.Diagnostics.Debug.Assert(saved == true); // We no longer disable interrupts for this test.
// When the scheduler implements the SIP scheduling,
// we can enable this back after switching to the local preemption
//System.Diagnostics.Debug.Assert(saved == true);
try { try {
snap.Start(); snap.Start();
for (int i = 0; i < iterations; i++) { for (int i = 0; i < iterations; i++) {
Processor.RestoreInterrupts(saved); Processor.RestoreLocalPreemption(saved);
saved = Processor.DisableInterrupts(); saved = Processor.DisableLocalPreemption();
} }
} }
finally { finally {
snap.Finish(iterations); snap.Finish(iterations);
Processor.RestoreInterrupts(saved); Processor.RestoreLocalPreemption(saved);
} }
snap.Display("Irq SVE/RSTR"); snap.Display("Irq SVE/RSTR");
@ -431,6 +398,8 @@ namespace Microsoft.Singularity.Applications.Singbench
snap.Display("Wait/Set"); snap.Display("Wait/Set");
} }
//==============START SEND/RECV TESTS==================================
/////////////////////////////////////////// Receive Performance Tests. /////////////////////////////////////////// Receive Performance Tests.
// //
public contract ReceivePerfTest public contract ReceivePerfTest
@ -585,106 +554,6 @@ namespace Microsoft.Singularity.Applications.Singbench
} }
} }
/////////////////////////////////////////// Child-Receive performance tests
//
public static void DoChildReceivePerf(int iterations)
{
int doit = iterations / 2;
// Make a new channel.
SendTestContract.Imp! childImp;
SendTestContract.Exp! childExp;
SendTestContract.NewChannel(out childImp, out childExp);
// Start up our child
string[] args = new string[3];
args[0] = "BenchChild.x86";
args[1] = "-where";
args[2] = "!";
Process child = new Process(args, (Endpoint * in ExHeap)childExp);
// set the where parameter to true
ParameterCode code;
code = child.SetStartupBoolArg(0, true);
if (code != ParameterCode.Success){
Console.WriteLine("unable to set bool index 0. error={0}", code);
delete childImp;
return;
}
child.Start();
childImp.RecvTestReady();
PerfSnap snap = new PerfSnap();
snap.Start();
try {
int arg;
for (int i = 0; i < doit; i++) {
arg = i;
childImp.SendReq(arg);
childImp.RecvResp(out arg);
}
}
finally {
snap.Finish(iterations);
}
childImp.SendReq(-1);
delete childImp;
child.Join();
snap.Display("CHILD S/R");
}
////////////////////////////// Child send-receive performance test
//
public static void DoChildReceivePerf2(int iterations, int messageBytes)
{
// Make a new channel.
BufferTestContract.Imp! childImp;
BufferTestContract.Exp! childExp;
BufferTestContract.NewChannel(out childImp, out childExp);
// Start up our child
string[] args = new string[2];
args[0] = "BenchChild.x86";
args[1] = "!";
Process child = new Process(args, (Endpoint * in ExHeap)childExp);
child.Start();
childImp.RecvBufferReady();
byte[]! in ExHeap buffer = new [ExHeap] byte[messageBytes];
PerfSnap snap = new PerfSnap();
snap.Start();
try {
for (int i = 0; i < iterations; i++) {
childImp.SendReq(iterations - i - 1, buffer);
childImp.RecvResp(out buffer);
}
}
finally {
// Factor of two for one-sided send-receive only
snap.Finish(2 * iterations);
delete buffer;
}
delete childImp;
child.Join();
if (messageBytes < 1024) {
snap.Display(String.Format("Child S/RB-{0}", messageBytes));
}
else {
snap.Display(String.Format("Child S/RB-{0}K",
messageBytes / 1024));
}
}
//////////////////////////////////////////// Switch Performance Tests. //////////////////////////////////////////// Switch Performance Tests.
// //
public contract SwitchPerfTest public contract SwitchPerfTest
@ -706,8 +575,7 @@ namespace Microsoft.Singularity.Applications.Singbench
peerReady.Set(); peerReady.Set();
for (int i = 0; i != -1;) { for (int i = 0; i != -1;) {
switch receive switch receive {
{
case ep.Req(arg) in s: case ep.Req(arg) in s:
i = arg; i = arg;
if (i != -1) { if (i != -1) {
@ -754,11 +622,10 @@ namespace Microsoft.Singularity.Applications.Singbench
e.SendReq(0); e.SendReq(0);
s.Add(e); s.Add(e);
for (int i = 0; i < doit; i++) { for (int i = 0; i < doit; i++) {
switch receive switch receive {
{
case ep.Resp(arg) in s: case ep.Resp(arg) in s:
i = arg; i = arg;
if (i == doit -1) { if (i == doit - 1) {
ep.SendReq(-1); ep.SendReq(-1);
} }
else { else {
@ -782,6 +649,8 @@ namespace Microsoft.Singularity.Applications.Singbench
snap.Display("Send/Switch"); snap.Display("Send/Switch");
} }
//==============END SEND/RECV TESTS==================================
//////////////////////////////////////////// Create Directory Channel. //////////////////////////////////////////// Create Directory Channel.
// //
public static void DoPageAllocPerf(int iterations) public static void DoPageAllocPerf(int iterations)
@ -927,7 +796,7 @@ namespace Microsoft.Singularity.Applications.Singbench
public static void SelectThread() public static void SelectThread()
{ {
for (int i = 0; i < SELECT_ITERATIONS; i++) { for (int i = 0; i < SELECT_ITERATIONS; i++) {
for (int j = 0; j < NSELECT; j+=3) { for (int j = 0; j < NSELECT; j += 3) {
SelectTest.Imp imp = ((!)impEndpoints[j]).Acquire(); SelectTest.Imp imp = ((!)impEndpoints[j]).Acquire();
imp.SendA(); imp.SendA();
@ -935,7 +804,7 @@ namespace Microsoft.Singularity.Applications.Singbench
((!)impEndpoints[j]).Release(imp); ((!)impEndpoints[j]).Release(imp);
} }
for (int j = 1; j < NSELECT; j+=3) { for (int j = 1; j < NSELECT; j += 3) {
SelectTest.Imp imp = ((!)impEndpoints[j]).Acquire(); SelectTest.Imp imp = ((!)impEndpoints[j]).Acquire();
imp.SendB(); imp.SendB();
@ -943,7 +812,7 @@ namespace Microsoft.Singularity.Applications.Singbench
((!)impEndpoints[j]).Release(imp); ((!)impEndpoints[j]).Release(imp);
} }
for (int j = 2; j < NSELECT; j+=3) { for (int j = 2; j < NSELECT; j += 3) {
SelectTest.Imp imp = ((!)impEndpoints[j]).Acquire(); SelectTest.Imp imp = ((!)impEndpoints[j]).Acquire();
imp.SendC(); imp.SendC();
@ -1020,7 +889,7 @@ namespace Microsoft.Singularity.Applications.Singbench
bool failed = false; bool failed = false;
for (int i = 0; i < SELECT_ITERATIONS; i++) { for (int i = 0; i < SELECT_ITERATIONS; i++) {
for(int j = 0; j < NSELECT-2; j++) { for (int j = 0; j < NSELECT - 2; j++) {
SelectTest.Exp a = ((!)expEndpoints[j+0]).Acquire(); SelectTest.Exp a = ((!)expEndpoints[j+0]).Acquire();
SelectTest.Exp b = ((!)expEndpoints[j+1]).Acquire(); SelectTest.Exp b = ((!)expEndpoints[j+1]).Acquire();
SelectTest.Exp c = ((!)expEndpoints[j+2]).Acquire(); SelectTest.Exp c = ((!)expEndpoints[j+2]).Acquire();
@ -1110,7 +979,7 @@ namespace Microsoft.Singularity.Applications.Singbench
bool failed = false; bool failed = false;
Console.WriteLine(" Starting server loop - {0} iterations", SELECT_ITERATIONS); Console.WriteLine(" Starting server loop - {0} iterations", SELECT_ITERATIONS);
for (i = 0 ; i < SELECT_ITERATIONS; i++) { for (i = 0; i < SELECT_ITERATIONS; i++) {
ActuallySelect(eset, 0, ref failed); ActuallySelect(eset, 0, ref failed);
ActuallySelect(eset, 0, ref failed); ActuallySelect(eset, 0, ref failed);
ActuallySelect(eset, 0, ref failed); ActuallySelect(eset, 0, ref failed);
@ -1177,7 +1046,7 @@ namespace Microsoft.Singularity.Applications.Singbench
Process[] process = new Process[iterations]; Process[] process = new Process[iterations];
string[] args = new string[2]; string[] args = new string[2];
args[0] = "testpe.x86"; args[0] = "testpe";
args[1] = "!"; // Special flag to not notify debugger. args[1] = "!"; // Special flag to not notify debugger.
PerfSnap snap = new PerfSnap(); PerfSnap snap = new PerfSnap();
@ -1232,6 +1101,8 @@ namespace Microsoft.Singularity.Applications.Singbench
// //
public static int GetTrace() public static int GetTrace()
{ {
#if false
Tracing.LogEntry * lstart; Tracing.LogEntry * lstart;
Tracing.LogEntry * llimit; Tracing.LogEntry * llimit;
Tracing.LogEntry ** lhead; Tracing.LogEntry ** lhead;
@ -1245,6 +1116,7 @@ namespace Microsoft.Singularity.Applications.Singbench
(UIntPtr)lstart, (UIntPtr)llimit, (UIntPtr)lhead, (UIntPtr)(*lhead)); (UIntPtr)lstart, (UIntPtr)llimit, (UIntPtr)lhead, (UIntPtr)(*lhead));
Console.WriteLine("Text: {0:X} {1:X}, {2:X}, {3:X}", Console.WriteLine("Text: {0:X} {1:X}, {2:X}, {3:X}",
(UIntPtr)tstart, (UIntPtr)tlimit, (UIntPtr)thead, (UIntPtr)(*thead)); (UIntPtr)tstart, (UIntPtr)tlimit, (UIntPtr)thead, (UIntPtr)(*thead));
#endif
return 0; return 0;
} }
@ -1284,7 +1156,8 @@ namespace Microsoft.Singularity.Applications.Singbench
if (Processor.AtKernelPrivilege()) { if (Processor.AtKernelPrivilege()) {
atRing3 = false; atRing3 = false;
DualWriteLine("Singbench running at KERNEL privilege"); DualWriteLine("Singbench running at KERNEL privilege");
} else { }
else {
atRing3 = true; atRing3 = true;
DualWriteLine("Singbench running at USER privilege"); DualWriteLine("Singbench running at USER privilege");
} }
@ -1345,25 +1218,24 @@ namespace Microsoft.Singularity.Applications.Singbench
Pause(); Pause();
ClearEnvironment(impMem); ClearEnvironment(impMem);
DoReceivePerf(1000); DoReceivePerf(1024);
Pause(); Pause();
for (int i = 1; i <= 65536; i *= 2) { for (int i = 1; i <= 65536; i *= 2) {
ClearEnvironment(impMem); ClearEnvironment(impMem);
DoReceivePerf2(iterations, i); DoReceivePerf2(iterations, i);
Pause(); Pause();
} }
// Child-channel tests // Child-channel tests
ClearEnvironment(impMem); ClearEnvironment(impMem);
DoChildReceivePerf(1000); Child.ReceivePerf(1000);
Pause(); Pause();
for (int i = 1; i <= 65536; i *= 2) { for (int i = 1; i <= 65536; i *= 2) {
ClearEnvironment(impMem); ClearEnvironment(impMem);
DoChildReceivePerf2(iterations, i); Child.ReceivePerf2(iterations, i);
Pause(); Pause();
} }
ClearEnvironment(impMem); ClearEnvironment(impMem);
@ -1419,8 +1291,8 @@ namespace Microsoft.Singularity.Applications.Singbench
ClearEnvironment(impMem); ClearEnvironment(impMem);
DoSelectSet(); DoSelectSet();
#endif #endif
}
} catch (Exception e) { catch (Exception e) {
Console.WriteLine("Caught {0}", e.Message); Console.WriteLine("Caught {0}", e.Message);
// How do I work out where an exception was thrown from these days? // How do I work out where an exception was thrown from these days?
//Console.WriteLine(e.StackTrace); //Console.WriteLine(e.StackTrace);

View File

@ -1,8 +1,6 @@
<!-- <!--
############################################################################### ###############################################################################
# #
# Microsoft Research Singularity
#
# Copyright (c) Microsoft Corporation. All rights reserved. # Copyright (c) Microsoft Corporation. All rights reserved.
# #
############################################################################### ###############################################################################
@ -15,9 +13,12 @@
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<AssemblyName>singbench</AssemblyName> <AssemblyName>singbench</AssemblyName>
<AssumeFieldsNonNull>true</AssumeFieldsNonNull> <AssumeFieldsNonNull>true</AssumeFieldsNonNull>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Child.sg" />
<Compile Include="Parameters.sg" />
<Compile Include="PerfSnap.sg" /> <Compile Include="PerfSnap.sg" />
<Compile Include="SingBench.sg" /> <Compile Include="SingBench.sg" />
<ProjectReference Include="$(SINGULARITY_ROOT)\Contracts\Diagnostics.Contracts\Diagnostics.Contracts.csproj" /> <ProjectReference Include="$(SINGULARITY_ROOT)\Contracts\Diagnostics.Contracts\Diagnostics.Contracts.csproj" />

View File

@ -1,8 +1,3 @@
From: Mark Aiken
Sent: Sunday, October 16, 2005 4:19 PM
To: Chris Hawblitzel
Subject: Running SPECweb
Here is how to run webfiles: Here is how to run webfiles:
On Windows: On Windows:
@ -12,14 +7,14 @@ in Applications\Benchmarks\SpecWeb99\webfiles type
On Singularity: On Singularity:
First run: First run:
- "mkfs /dev/vol2" - "fatcontrol @format /dev/vol2"
- "fsmount /dev/vol2 /fs -n" [no caching] - "fatcontrol @mount /dev/vol2 /fs"
- "wafgen99 -v 10 /fs" [Generates lots of files] - "wafgen99 -v 10 /fs" [Generates lots of files]
- "fsunmount" - "fatcontrol @unmount"
- reboot to clear the log. - reboot to clear the log.
Second boot: Second boot:
- "fsmount /dev/vol2 /fs" - "fatcontrol @mount /dev/vol2 /fs"
- "webfiles -r:60" - "webfiles -r:60"
Alternatively, to run an fixed benchmark size, use the -f:X, forced Alternatively, to run an fixed benchmark size, use the -f:X, forced

View File

@ -1,65 +1,65 @@
#define NO_ZIPF_SPIKE #define NO_ZIPF_SPIKE
/* //
* (C)1997 Standard Performance Evaluation Corporation (SPEC) // (C)1997 Standard Performance Evaluation Corporation (SPEC)
* //
* This suite contains code acquired from several sources who // This suite contains code acquired from several sources who
* understand and agree with SPEC's goal of creating fair and // understand and agree with SPEC's goal of creating fair and
* objective benchmarks to measure computer performance. // objective benchmarks to measure computer performance.
* //
* This copyright notice is placed here only to protect SPEC in the // This copyright notice is placed here only to protect SPEC in the
* event the source is misused in any manner that is contrary to // event the source is misused in any manner that is contrary to
* the spirit, the goals and the intent of SPEC. // the spirit, the goals and the intent of SPEC.
* //
* The source code is provided to the user or company under the // The source code is provided to the user or company under the
* license agreement for the SPEC Benchmark Suite for this suite. // license agreement for the SPEC Benchmark Suite for this suite.
*/ //
/***************************************************************** //////////////////////////////////////////////////////////////////
* * // *
* Copyright 1991,1992 Legato Systems, Inc. * // Copyright 1991,1992 Legato Systems, Inc. *
* Copyright 1991,1992 Auspex Systems, Inc. * // Copyright 1991,1992 Auspex Systems, Inc. *
* Copyright 1991,1992 Data General Corporation * // Copyright 1991,1992 Data General Corporation *
* Copyright 1991,1992 Digital Equipment Corporation * // Copyright 1991,1992 Digital Equipment Corporation *
* Copyright 1991,1992 Interphase Corporation * // Copyright 1991,1992 Interphase Corporation *
* Copyright 1991,1992 Sun Microsystems, Inc. * // Copyright 1991,1992 Sun Microsystems, Inc. *
* * // *
*****************************************************************/ /////////////////////////////////////////////////////////////////
/* //
* ---------------------- laddis_c_rnd.c --------------------- // ---------------------- laddis_c_rnd.c ---------------------
* //
* Random number generator. // Random number generator.
* //
*.Exported_routines //.Exported_routines
* double Spec_random (RandomState *theState); // double Spec_random (RandomState *theState);
* long Spec_nrandom (RandomState *theState); // long Spec_nrandom (RandomState *theState);
* void Spec_srandom (RandomState *theState, int seed); // void Spec_srandom (RandomState *theState, int seed);
* //
*.Local_routines //.Local_routines
* None // None
* //
*.Revision_History //.Revision_History
* 06-Nov-05 Convert to Sing# // 06-Nov-05 Convert to Sing#
* 24-May-97 Chan-Nui Re-write to make thread-safe // 24-May-97 Re-write to make thread-safe
* 28-Nov-91 Teelucksingh ANSI C // 28-Nov-91 ANSI C
* 01-Aug-91 Wiryaman laddis_srandom() and laddis_random()whee // 01-Aug-91 laddis_srandom() and laddis_random()
* now use spec_srand() and spec_rand() // now use spec_srand() and spec_rand()
* instead of srandom() and random(). // instead of srandom() and random().
* 17-Apr-91 Wittle Created. // 17-Apr-91 Created.
*/ //
/* //
* Here's the source for the random number generator that SPEC uses. // Here's the source for the random number generator that SPEC uses.
* The function to be called is "spec_rand" which returns an integer // The function to be called is "spec_rand" which returns an integer
* between 1 and MAX_INT-1. // between 1 and MAX_INT-1.
* //
*/ //
/***************************************************************************** //////////////////////////////////////////////////////////////////////////////
* UNIFORM Distribution * // UNIFORM Distribution *
*****************************************************************************/ /////////////////////////////////////////////////////////////////////////////
using System; using System;
using Singularity.Application.SPECWeb99; using Singularity.Application.SPECWeb99;
@ -77,12 +77,12 @@ namespace Singularity.Application.SPECWeb99.WebFiles
public class Random public class Random
{ {
public const int A_MULTIPLIER = 16807; public const int A_MULTIPLIER = 16807;
public const int M_MODULUS = 2147483647; /* (2**31)-1 */ public const int M_MODULUS = 2147483647; // (2**31)-1
public const int Q_QUOTIENT = 127773; /* 2147483647 / 16807 */ public const int Q_QUOTIENT = 127773; // 2147483647 / 16807
public const int R_REMAINDER = 2836; /* 2147483647 % 16807 */ public const int R_REMAINDER = 2836; // 2147483647 % 16807
/* //
* Compute the next random number. //Compute the next random number.
*/ //
public class RandomState public class RandomState
{ {
public int val; public int val;
@ -130,11 +130,11 @@ namespace Singularity.Application.SPECWeb99.WebFiles
#endif #endif
public double Spec_random(RandomState /*!*/ theState) public double Spec_random(RandomState /*!*/ theState)
/* See "Random Number Generators: Good Ones Are Hard To Find", */ // See "Random Number Generators: Good Ones Are Hard To Find",
/* Park & Miller, CACM 31#10 October 1988 pages 1192-1201. */ // Park & Miller, CACM 31#10 October 1988 pages 1192-1201.
/***********************************************************/ ///////////////////////////////////////////////////////////
/* THIS IMPLEMENTATION REQUIRES AT LEAST 32 BIT INTEGERS ! */ // THIS IMPLEMENTATION REQUIRES AT LEAST 32 BIT INTEGERS !
/***********************************************************/ ///////////////////////////////////////////////////////////
{ {
int lo; int lo;
int hi; int hi;
@ -145,30 +145,31 @@ namespace Singularity.Application.SPECWeb99.WebFiles
test = A_MULTIPLIER * lo - R_REMAINDER * hi; test = A_MULTIPLIER * lo - R_REMAINDER * hi;
if (test > 0) { if (test > 0) {
theState.val = test; theState.val = test;
} else { }
else {
theState.val = test + M_MODULUS; theState.val = test + M_MODULUS;
} }
return((float) theState.val / M_MODULUS); return((float) theState.val / M_MODULUS);
} }
/* //
* Seed the random number generator. //Seed the random number generator.
*/ //
public void Spec_srandom( RandomState /*!*/ theState, int seed ) { public void Spec_srandom( RandomState /*!*/ theState, int seed ) {
theState.val = seed; theState.val = seed;
} }
/* //
* Returns a random number. //Returns a random number.
*/ //
public int Spec_nrandom( RandomState/*!*/ theState ) { public int Spec_nrandom( RandomState/*!*/ theState ) {
Spec_random(theState); Spec_random(theState);
return(theState.val); return(theState.val);
} }
/***************************************************************************** //////////////////////////////////////////////////////////////////////////////
* ZIPF Distribution * //ZIPF Distribution *
*****************************************************************************/ ////////////////////////////////////////////////////////////////////////////
public ZipfState spec_zipf_setup(RandomState rstate, int size, double Z) public ZipfState spec_zipf_setup(RandomState rstate, int size, double Z)
{ {
@ -178,14 +179,14 @@ namespace Singularity.Application.SPECWeb99.WebFiles
ZipfState theState = new ZipfState(rstate, size); ZipfState theState = new ZipfState(rstate, size);
if (theState == null) return null; if (theState == null) return null;
/* compute zipf values for samples 1-n */ // compute zipf values for samples 1-n
for (i = 1; i <= size; i++) { for (i = 1; i <= size; i++) {
theState.table[i] = Math.Pow(((double)1.0/((double)i)), Z); theState.table[i] = Math.Pow(((double)1.0/((double)i)), Z);
//theState.table[i] = 1; // SPL TOTAL HACK until POW works!! //theState.table[i] = 1; // SPL TOTAL HACK until POW works!!
} }
/* sum the values so we can compute probabilities. */ // sum the values so we can compute probabilities.
/* at the same time, make the values cumulative */ // at the same time, make the values cumulative
zipf_sum = 0.0; zipf_sum = 0.0;
for (i = 1; i <= size; i++) { for (i = 1; i <= size; i++) {
zipf_sum += theState.table[i] ; zipf_sum += theState.table[i] ;
@ -194,9 +195,9 @@ namespace Singularity.Application.SPECWeb99.WebFiles
theState.table[size] = 0.0; theState.table[size] = 0.0;
theState.table[0] = 0.0; theState.table[0] = 0.0;
/* compute probability values by dividing by the sum. */ // compute probability values by dividing by the sum.
/* also reverse the table so we have values starting at 1.0 */ // also reverse the table so we have values starting at 1.0
/* and descending to 0.0 (this is what spec_zipf needs) */ // and descending to 0.0 (this is what spec_zipf needs)
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
theState.table[i] = 1.0 - (theState.table[i]/zipf_sum); theState.table[i] = 1.0 - (theState.table[i]/zipf_sum);
} }
@ -224,7 +225,7 @@ namespace Singularity.Application.SPECWeb99.WebFiles
i++; i++;
} }
#if NO_ZIPF_SPIKE #if NO_ZIPF_SPIKE
} while (i>theState.size); } while (i > theState.size);
#endif #endif
return i-1; return i-1;
} }
@ -233,9 +234,9 @@ namespace Singularity.Application.SPECWeb99.WebFiles
#if STATIC_NORMAL_DIST #if STATIC_NORMAL_DIST
/* Right now, mean and stddev are ignored. If someone has a good function to // Right now, mean and stddev are ignored. If someone has a good function to
generate the cdf for normal distributions, let me know... */ // generate the cdf for normal distributions, let me know...
/* size=20, mean = 10, stddev = 3.5, will generate numbers from 0 to 20 */ // size=20, mean = 10, stddev = 3.5, will generate numbers from 0 to 20
NormalState spec_normal_setup(, RandomState rstate, double mean, double stddev) { NormalState spec_normal_setup(, RandomState rstate, double mean, double stddev) {
double normal_dist[] = { double normal_dist[] = {
@ -297,16 +298,16 @@ int spec_nnormal(NormalState theState) {
#else #else
/* Guts of this routine are based on: */ // Guts of this routine are based on:
/* boxmuller.c Implements the Polar form of the Box-Muller // boxmuller.c Implements the Polar form of the Box-Muller
Transformation // Transformation
//
(c) Copyright 1994, Everett F. Carter Jr. // (c) Copyright 1994, Everett F. Carter Jr.
Permission is granted by the author to use // Permission is granted by the author to use
this software for any application provided this // this software for any application provided this
copyright notice is preserved. // copyright notice is preserved.
//
*/ //
private NormalState spec_normal_setup(NormalState/*!*/ theState, private NormalState spec_normal_setup(NormalState/*!*/ theState,
RandomState/*!*/ rstate, RandomState/*!*/ rstate,
@ -328,7 +329,7 @@ int spec_nnormal(NormalState theState) {
{ {
double x1, x2, w, y1; double x1, x2, w, y1;
if (theState.use_last ) { /* use value from previous call */ if (theState.use_last) { // use value from previous call
y1 = theState.y2; y1 = theState.y2;
} }
else { else {
@ -336,7 +337,7 @@ int spec_nnormal(NormalState theState) {
x1 = 2.0 * Spec_random(theState.rstate) - 1.0; x1 = 2.0 * Spec_random(theState.rstate) - 1.0;
x2 = 2.0 * Spec_random(theState.rstate) - 1.0; x2 = 2.0 * Spec_random(theState.rstate) - 1.0;
w = x1 * x1 + x2 * x2; w = x1 * x1 + x2 * x2;
} while ( w >= 1.0 ); } while (w >= 1.0);
w = Math.Sqrt( (-2.0 * Math.Log( w ) ) / w ); w = Math.Sqrt( (-2.0 * Math.Log( w ) ) / w );
y1 = x1 * w; y1 = x1 * w;

View File

@ -1,10 +1,8 @@
/////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------
//
// Microsoft Research Singularity
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// //
/////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------
using System; using System;
using System.Collections; using System.Collections;
@ -12,7 +10,8 @@ using System.Text;
namespace Singularity.Application.SPECWeb99.WebFiles namespace Singularity.Application.SPECWeb99.WebFiles
{ {
class Cache { class Cache
{
private const bool verbose = false; private const bool verbose = false;
private UrlSet cache; private UrlSet cache;
private UrlSet free; private UrlSet free;
@ -52,7 +51,7 @@ namespace Singularity.Application.SPECWeb99.WebFiles
// now see if there are any urls available // now see if there are any urls available
// if not either wait on or generate the global deck // if not either wait on or generate the global deck
while (client.urlDeck.pos == 0){ while (client.urlDeck.pos == 0) {
if (client.generatingUrls == false) { if (client.generatingUrls == false) {
//Console.WriteLine("Generating cache"); //Console.WriteLine("Generating cache");
UrlSet temp = client.urlDeck; UrlSet temp = client.urlDeck;
@ -77,8 +76,8 @@ namespace Singularity.Application.SPECWeb99.WebFiles
// the global deck is ok -- prime our cache // the global deck is ok -- prime our cache
if (client.urlDeck.pos > 0 ) { if (client.urlDeck.pos > 0) {
for (int i =0; i < cache.urls.Length && (client.urlDeck.pos > 0); i++) { for (int i = 0; i < cache.urls.Length && (client.urlDeck.pos > 0); i++) {
cache.urls[cache.pos++] = cache.urls[cache.pos++] =
client.urlDeck.urls[--client.urlDeck.pos]; client.urlDeck.urls[--client.urlDeck.pos];
} }
@ -88,7 +87,7 @@ namespace Singularity.Application.SPECWeb99.WebFiles
} }
public void FreeUrl(FileSpec url) { public void FreeUrl(FileSpec url) {
if (free.pos+1 >= free.urls.Length) { if (free.pos + 1 >= free.urls.Length) {
//Console.WriteLine("free cache full! de-allocating"); //Console.WriteLine("free cache full! de-allocating");
url = null; url = null;
return; return;

View File

@ -1,10 +1,8 @@
/////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------
//
// Microsoft Research Singularity
// //
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// //
/////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// Simulate the file reading portion of the specweb99 test suite // Simulate the file reading portion of the specweb99 test suite
@ -98,7 +96,8 @@ namespace Singularity.Application.SPECWeb99.WebFiles
} }
#endif #endif
#if !SINGULARITY #if !SINGULARITY
class FileReader { class FileReader
{
//const uint FILE_FLAG_NO_BUFFERING = 0x20000000; //const uint FILE_FLAG_NO_BUFFERING = 0x20000000;
const uint FILE_FLAG_NO_BUFFERING = 0; const uint FILE_FLAG_NO_BUFFERING = 0;
const uint GENERIC_READ = 0x80000000; const uint GENERIC_READ = 0x80000000;
@ -147,7 +146,7 @@ namespace Singularity.Application.SPECWeb99.WebFiles
FILE_FLAG_NO_BUFFERING, FILE_FLAG_NO_BUFFERING,
0); 0);
if (handle != IntPtr.Zero && handle != ((IntPtr) (-1)) ) { if (handle != IntPtr.Zero && handle != ((IntPtr) (-1))) {
return true; return true;
} }
else { else {
@ -185,7 +184,7 @@ namespace Singularity.Application.SPECWeb99.WebFiles
public class UrlSet public class UrlSet
{ {
public int pos; public int pos;
public FileSpec[] urls; public FileSpec[]/*!*/ urls;
public UrlSet(int size) public UrlSet(int size)
{ {
@ -202,7 +201,7 @@ namespace Singularity.Application.SPECWeb99.WebFiles
private const int MAX_PATH = 256; private const int MAX_PATH = 256;
private const int LINESIZE = 64; private const int LINESIZE = 64;
private const int MARKER_FREQ = 4096; private const int MARKER_FREQ = 4096;
private const int BUF_SIZE = 1024*1024; /* 1MB */ private const int BUF_SIZE = 1024*1024; // 1MB
private const int MAX_DECK = 1000; private const int MAX_DECK = 1000;
////////////////////////////////// //////////////////////////////////
// Pseudo-constants // Pseudo-constants
@ -220,16 +219,13 @@ namespace Singularity.Application.SPECWeb99.WebFiles
// Instance variables // Instance variables
public Random.RandomState randomState; public Random.RandomState randomState;
public bool generatingUrls; public bool generatingUrls;
public Mutex globalLock; public Mutex/*!*/ globalLock;
public Mutex syncLock; public Mutex/*!*/ syncLock;
public UrlSet urlDeck; public UrlSet/*!*/ urlDeck;
public UrlSet freeDeck; public UrlSet/*!*/ freeDeck;
public UrlSet spareDeck; public UrlSet/*!*/ spareDeck;
#if SINGULARITY #if SINGULARITY
public static TRef<DirectoryServiceContract.Imp:Ready> namespaceRootT; public static TRef<DirectoryServiceContract.Imp:Ready> namespaceRootT;
private long fileCount = 0;
private long repeatCount = 0;
private bool dumpTable = false;
#else #else
/// <summary> /// <summary>
/// will not work for multiple threads!!! /// will not work for multiple threads!!!
@ -237,12 +233,15 @@ namespace Singularity.Application.SPECWeb99.WebFiles
private static FileReader reader = new FileReader(); private static FileReader reader = new FileReader();
#endif #endif
private long dirCount = 0; private long dirCount = 0;
private long fileCount = 0;
private long repeatCount = 0;
private static long blockSize = 0; private static long blockSize = 0;
private long totalSize = 0; private long totalSize = 0;
private long fileSizeNum = 0; private long fileSizeNum = 0;
private long classSizeNum = 0; private long classSizeNum = 0;
private long threadNum = 1; private long threadNum = 1;
private long verbose = 0; private long verbose = 0;
private bool dumpTable = false;
private bool testMode = false; private bool testMode = false;
private int runTime; private int runTime;
private int rampTime; private int rampTime;
@ -268,9 +267,7 @@ namespace Singularity.Application.SPECWeb99.WebFiles
private class LocalState private class LocalState
{ {
public WorkerState State; public WorkerState State;
#if SINGULARITY
public DateTime StartTime; public DateTime StartTime;
#endif
public long bindCount; public long bindCount;
public TimeSpan bindTime; public TimeSpan bindTime;
public long readCount; public long readCount;
@ -292,9 +289,7 @@ namespace Singularity.Application.SPECWeb99.WebFiles
} }
} }
#if SINGULARITY
[NotDelayed] [NotDelayed]
#endif
public Client(string/*!*/ prefix, long dir, public Client(string/*!*/ prefix, long dir,
long bSize, long fSize, long bSize, long fSize,
long threads, long verbose, long threads, long verbose,
@ -322,7 +317,6 @@ namespace Singularity.Application.SPECWeb99.WebFiles
fileBucket = new int [FILES_PER_CLASS]; fileBucket = new int [FILES_PER_CLASS];
sb = new StringBuilder(512); sb = new StringBuilder(512);
if (sb == null) throw new Exception (" could not allocate memory for string builder");
#if SINGULARITY #if SINGULARITY
namespaceRootT = new TRef<DirectoryServiceContract.Imp:Ready>( namespaceRootT = new TRef<DirectoryServiceContract.Imp:Ready>(
DirectoryService.NewClientEndpoint()); DirectoryService.NewClientEndpoint());
@ -330,9 +324,9 @@ namespace Singularity.Application.SPECWeb99.WebFiles
#endif #endif
workerLocalStates = new LocalState[threads]; workerLocalStates = new LocalState[threads];
if (workerLocalStates == null) { #if SINGULARITY
throw new Exception ("unable to alloc workerstats"); base();
} #endif // SINGULARITY
} }
//------------------------------------------------------------------ //------------------------------------------------------------------
@ -341,7 +335,7 @@ namespace Singularity.Application.SPECWeb99.WebFiles
// throw the content away (no copying, no converting etc...) // throw the content away (no copying, no converting etc...)
//------------------------------------------------------------------ //------------------------------------------------------------------
// FIXFIX way this is called is rather bizarre. // TODO: The way this is called is rather bizarre. Fix it.
// a Client spawns LocalWorker objects that call back to this // a Client spawns LocalWorker objects that call back to this
// function. Should be moved into the LoadWorker class // function. Should be moved into the LoadWorker class
@ -365,16 +359,17 @@ namespace Singularity.Application.SPECWeb99.WebFiles
// only perform timing while in the run state // only perform timing while in the run state
DirectoryServiceContract.Imp:Ready! ds = Client.namespaceRootT.Acquire(); DirectoryServiceContract.Imp:Ready! ds = ((!)Client.namespaceRootT).Acquire();
ErrorCode errorCode = ErrorCode.Unknown; ErrorCode errorCode = ErrorCode.Unknown;
try { try {
if (currentState == WorkerState.Run) { if (currentState == WorkerState.Run) {
start = DateTime.Now; start = DateTime.Now;
conn = FileUtils.OpenFile(fileName, ds, out errorCode); conn = FileUtils.OpenFile(fileName, ds, out errorCode);
btime = DateTime.Now - start; btime = DateTime.Now - start;
local.bindTime += btime; local.bindTime += btime;
local.bindCount++; local.bindCount++;
} else { }
else {
conn = FileUtils.OpenFile(fileName, ds, out errorCode); conn = FileUtils.OpenFile(fileName, ds, out errorCode);
} }
} }
@ -418,7 +413,8 @@ namespace Singularity.Application.SPECWeb99.WebFiles
} }
if (currentState == WorkerState.Run) { if (currentState == WorkerState.Run) {
local.totalTime += DateTime.Now - beginTotal; DateTime end = DateTime.Now;
local.totalTime += end - beginTotal;
} }
return inBuf; return inBuf;
} }
@ -430,12 +426,13 @@ namespace Singularity.Application.SPECWeb99.WebFiles
public void GenerateFileSpecs() public void GenerateFileSpecs()
{ {
FileSpec fs; FileSpec fs;
long size, linkCount;
uint flags;
double totalProb = 0.0; double totalProb = 0.0;
UrlSet fr = freeDeck; UrlSet/*!*/ fr = freeDeck;
UrlSet sp = spareDeck; UrlSet/*!*/ sp = spareDeck;
// //
// Ensure the spare deck is fully allocated // Ensure the spare deck is fully allocated
@ -454,8 +451,8 @@ namespace Singularity.Application.SPECWeb99.WebFiles
// NOTE allocation should mostly happen during the initialization phase // NOTE allocation should mostly happen during the initialization phase
for (int i=0; i < fr.urls.Length; i++){ for (int i = 0; i < fr.urls.Length; i++) {
if (fr.pos == 0 ) { if (fr.pos == 0) {
//if ( sp.urls[i] != null) DebugStub.Break(); //if ( sp.urls[i] != null) DebugStub.Break();
sp.urls[i] = new FileSpec(); sp.urls[i] = new FileSpec();
if (sp.urls[i] == null) { if (sp.urls[i] == null) {
@ -476,7 +473,7 @@ namespace Singularity.Application.SPECWeb99.WebFiles
// The loop immediately below will generate s set of files conforming to the // The loop immediately below will generate s set of files conforming to the
// requested probabilities but will not be random. // requested probabilities but will not be random.
for (int classNo = 0; classNo < MAX_CLASS_COUNT; classNo++) { for (int classNo = 0; classNo < MAX_CLASS_COUNT; classNo++) {
totalProb += CLASS_PROB[classNo]; totalProb += CLASS_PROB[classNo];
while (sp.pos < totalProb * sp.urls.Length) { while (sp.pos < totalProb * sp.urls.Length) {
fs = sp.urls[sp.pos++]; fs = sp.urls[sp.pos++];
@ -507,8 +504,10 @@ namespace Singularity.Application.SPECWeb99.WebFiles
} }
} }
/* Randomize deck */ // Randomize deck
for (int i = 0; i < sp.pos ; i++) { for (int i = 0; i < sp.pos; i++) {
/*^ assert this.randomState != null; ^*/
/*^ assert this.rand != null; ^*/
int pos = rand.Spec_nrandom(randomState) % (sp.pos - i); int pos = rand.Spec_nrandom(randomState) % (sp.pos - i);
FileSpec obj = sp.urls[sp.pos- i - 1]; FileSpec obj = sp.urls[sp.pos- i - 1];
sp.urls[sp.pos - i - 1] = sp.urls[pos]; sp.urls[sp.pos - i - 1] = sp.urls[pos];
@ -526,9 +525,7 @@ namespace Singularity.Application.SPECWeb99.WebFiles
{ {
private Client hostClient; private Client hostClient;
private LocalState localState; private LocalState localState;
#if SINGULARITY
private readonly ArrayList fs; private readonly ArrayList fs;
#endif
private StringBuilder sb; private StringBuilder sb;
private int readSize; private int readSize;
private Cache cache; private Cache cache;
@ -621,6 +618,8 @@ namespace Singularity.Application.SPECWeb99.WebFiles
// Allocate one one buffer for all operations // Allocate one one buffer for all operations
byte[] buf = new byte [blockSize]; byte[] buf = new byte [blockSize];
#endif #endif
long size;
// if loop we've been told to quit, but run at least the forcedIterations. // if loop we've been told to quit, but run at least the forcedIterations.
for (int iterations = 0;; iterations++) { for (int iterations = 0;; iterations++) {
if (iterations >= localState.forcedIterations && if (iterations >= localState.forcedIterations &&
@ -684,6 +683,7 @@ namespace Singularity.Application.SPECWeb99.WebFiles
/// manages Global state machine via timers etc. /// manages Global state machine via timers etc.
public void GenerateLoad() public void GenerateLoad()
{ {
ArrayList/*!*/ urlList;
totalSize = 0; totalSize = 0;
double megaBytes; double megaBytes;
InitializeGlobalState(); InitializeGlobalState();
@ -696,19 +696,16 @@ namespace Singularity.Application.SPECWeb99.WebFiles
long startIrqCount; long startIrqCount;
long startSwitchCount; long startSwitchCount;
long startKernelGcCount; long startKernelGcCount;
#endif
int startGcCount; int startGcCount;
long startGcMillis; long startGcMillis;
long startGcBytes; long startGcBytes;
DateTime startTime;
long endGcMillis; long endGcMillis;
long endGcBytes; long endGcBytes;
TimeSpan startTime;
TimeSpan endTime;
#else
DateTime startTime;
DateTime endTime; DateTime endTime;
#endif //DateTime globalStartTime = DateTime.Now;
//DateTime globalStartTime = ProcessService.GetUpTime();
// Create all the workers // Create all the workers
LoadWorker[] workers = new LoadWorker[threadNum]; LoadWorker[] workers = new LoadWorker[threadNum];
@ -734,7 +731,7 @@ namespace Singularity.Application.SPECWeb99.WebFiles
currentState = WorkerState.Rampup; currentState = WorkerState.Rampup;
for (int i = 0; i < threadNum; i++) { for (int i = 0; i < threadNum; i++) {
Thread t = threads[i]; Thread t = threads[i];
/*^ assume t!= null; ^*/ /*^ assume t!= null; ^*/
t.Start(); t.Start();
} }
@ -749,7 +746,7 @@ namespace Singularity.Application.SPECWeb99.WebFiles
out startGcMillis, out startGcMillis,
out startGcBytes); out startGcBytes);
startTime = ProcessService.GetUpTime(); startTime = DateTime.Now;
startIrqCount = ProcessService.GetKernelInterruptCount(); startIrqCount = ProcessService.GetKernelInterruptCount();
startSwitchCount = ProcessService.GetContextSwitchCount(); startSwitchCount = ProcessService.GetContextSwitchCount();
startKernelGcCount = ProcessService.GetKernelGcCount(); startKernelGcCount = ProcessService.GetKernelGcCount();
@ -764,7 +761,7 @@ namespace Singularity.Application.SPECWeb99.WebFiles
out startGcMillis, out startGcMillis,
out startGcBytes); out startGcBytes);
startTime = ProcessService.GetUpTime(); startTime = DateTime.Now;
startIrqCount = ProcessService.GetKernelInterruptCount(); startIrqCount = ProcessService.GetKernelInterruptCount();
startSwitchCount = ProcessService.GetContextSwitchCount(); startSwitchCount = ProcessService.GetContextSwitchCount();
startKernelGcCount = ProcessService.GetKernelGcCount(); startKernelGcCount = ProcessService.GetKernelGcCount();
@ -777,7 +774,7 @@ namespace Singularity.Application.SPECWeb99.WebFiles
currentState = WorkerState.Rampup; currentState = WorkerState.Rampup;
for (int i = 0; i < threadNum; i++) { for (int i = 0; i < threadNum; i++) {
Thread t = threads[i]; Thread t = threads[i];
/*^ assume t!= null; ^*/ /*^ assume t!= null; ^*/
t.Start(); t.Start();
} }
@ -812,22 +809,23 @@ namespace Singularity.Application.SPECWeb99.WebFiles
if (wasActive) Console.WriteLine("May want to reset Monitoring state -- was active"); if (wasActive) Console.WriteLine("May want to reset Monitoring state -- was active");
Monitoring.setActive(false); Monitoring.setActive(false);
// Wait for all the threads to complete // Wait for all the threads to complete
for (int i = 0 ; i < threadNum; i++) { for (int i = 0; i < threadNum; i++) {
Thread t = threads[i]; Thread t = threads[i];
/*^ assume t!= null; ^*/ /*^ assume t!= null; ^*/
t.Join(); t.Join();
} }
#endif #endif
// should stats happen before or after thread join? // REVIEW: Should stats happen before or after thread join?
long totalFiles; long totalFiles;
long totalBytes = GatherStats(out totalFiles); long totalBytes = GatherStats(out totalFiles);
megaBytes = ( (double) (totalBytes) / (double) (1024*1024) ); megaBytes = ( (double) (totalBytes) / (double) (1024*1024) );
#if SINGULARITY
int endGcCount; int endGcCount;
endTime = ProcessService.GetUpTime(); #if SINGULARITY
endTime = DateTime.Now;
GC.PerformanceCounters(out endGcCount, GC.PerformanceCounters(out endGcCount,
out endGcMillis, out endGcMillis,
out endGcBytes); out endGcBytes);
@ -859,21 +857,21 @@ namespace Singularity.Application.SPECWeb99.WebFiles
#else #else
string info = "not implemented"; string info = "not implemented";
#endif #endif
if (verbose > 0 ) { if (verbose > 0) {
Console.WriteLine(); Console.WriteLine();
Console.WriteLine(summ); Console.WriteLine(summ);
Console.WriteLine(info); Console.WriteLine(info);
} }
if (verbose > 1 ) { if (verbose > 1) {
long ftotal = 0; long ftotal = 0;
for (int i=0; i < 9; i++) { for (int i = 0; i < 9; i++) {
ftotal += fileBucket[i]; ftotal += fileBucket[i];
} }
Console.WriteLine("Actual Zipf file distribution:"); Console.WriteLine("Actual Zipf file distribution:");
for (int i=0; i < 9; i++) { for (int i = 0; i < 9; i++) {
double foo = (double) (fileBucket[i] * 100) / (double) ftotal; double foo = (double) (fileBucket[i] * 100) / (double) ftotal;
Console.WriteLine(" FileBucket[{0}] = {1:d6}. %={2:f2}", Console.WriteLine(" FileBucket[{0}] = {1:d6}. %={2:f2}",
i, fileBucket[i], foo); i, fileBucket[i], foo);
@ -900,17 +898,17 @@ namespace Singularity.Application.SPECWeb99.WebFiles
out long value) out long value)
{ {
// arg should look like "[-][A-z]:[0-9]*" // arg should look like "[-][A-z]:[0-9]*"
if (arg.Length >= 4) if (arg.Length >= 4) {
{ try {
try
{
value = Int64.Parse(arg.Substring(3)); value = Int64.Parse(arg.Substring(3));
return true; return true;
} }
catch (FormatException) catch (FormatException) {
{Console.WriteLine("format ex"); } Console.WriteLine("format ex");
catch (OverflowException) }
{Console.WriteLine("overflow ex");} catch (OverflowException) {
Console.WriteLine("overflow ex");
}
} }
Console.WriteLine("Could not parse {0}, {1}", name,arg.Substring(3)); Console.WriteLine("Could not parse {0}, {1}", name,arg.Substring(3));
value = 0; value = 0;
@ -958,6 +956,7 @@ namespace Singularity.Application.SPECWeb99.WebFiles
rampTime = 0; rampTime = 0;
runTime = 0; runTime = 0;
} }
Console.WriteLine(" args: content=" + contentPrefix +" dir=" + dirCount + " block size="+blockSize); Console.WriteLine(" args: content=" + contentPrefix +" dir=" + dirCount + " block size="+blockSize);
Console.WriteLine(" verbose="+verbose+" FileSizeNum="+fileSizeNum+" ClassSizeNum="+classSizeNum); Console.WriteLine(" verbose="+verbose+" FileSizeNum="+fileSizeNum+" ClassSizeNum="+classSizeNum);
Console.WriteLine(" threads="+numThreads+" forcedIterations="+forcedIterations); Console.WriteLine(" threads="+numThreads+" forcedIterations="+forcedIterations);
@ -968,7 +967,7 @@ namespace Singularity.Application.SPECWeb99.WebFiles
testMode, (int) rampTime, (int)runTime, testMode, (int) rampTime, (int)runTime,
(int)forcedIterations); (int)forcedIterations);
if (c != null ) { if (c != null) {
c.GenerateLoad(); c.GenerateLoad();
} }
@ -999,19 +998,17 @@ namespace Singularity.Application.SPECWeb99.WebFiles
bool needHelp = args.Length == 0; bool needHelp = args.Length == 0;
int i; int i;
for (i = 1; i < args.Length; i++) for (i = 1; i < args.Length; i++) {
{
string/*!*/ arg = (string /*!*/) args[i]; string/*!*/ arg = (string /*!*/) args[i];
if (arg.Length < 2 || (arg[0] != '-' && arg[0] != '/') ) if (arg.Length < 2 || (arg[0] != '-' && arg[0] != '/')) {
{
Console.WriteLine("Invalid argument: {0}", arg); Console.WriteLine("Invalid argument: {0}", arg);
Usage(); Usage();
return -1; return -1;
} }
switch (Char.ToLower(arg[1])) long temp;
{ switch (Char.ToLower(arg[1])) {
case '?': case '?':
case 'h': case 'h':
needHelp = true; needHelp = true;
@ -1075,7 +1072,7 @@ namespace Singularity.Application.SPECWeb99.WebFiles
testMode, (int) rampTime, (int)runTime, testMode, (int) rampTime, (int)runTime,
(int)forcedIterations); (int)forcedIterations);
if (c != null ) { if (c != null) {
c.GenerateLoad(); c.GenerateLoad();
} }

View File

@ -1,8 +1,6 @@
<!-- <!--
############################################################################### ###############################################################################
# #
# Microsoft Research Singularity
#
# Copyright (c) Microsoft Corporation. All rights reserved. # Copyright (c) Microsoft Corporation. All rights reserved.
# #
############################################################################### ###############################################################################

View File

@ -1,11 +1,12 @@
clear clear
mkfs '/dev/vol0.2' fatcontrol '@format' '/dev/vol0.2'
fsmount '/dev/vol0.2' '/fs' '-n' fatcontrol '@mount' '/dev/vol0.2' '/fs'
wafgen99 '-v' '60' '/fs' wafgen99 '-v' '60' '/fs'
clear clear
echo '==============================================================================' echo '=============================================================================='
echo 'When fsunmount says that the volume has been unmounted, initialization is echo 'When unmount has completed the initialization is complete.
echo 'complete. You must manually reset the machine to start the xwebfile benchmark.' echo 'You must manually reset the machine to start the xwebfile benchmark.'
echo '==============================================================================' echo '=============================================================================='
echo 'fsunmount:' echo 'Unmounting...'
fsunmount fatcontrol @unmount '/fs'
echo '...Unmount completed.'

File diff suppressed because it is too large Load Diff

View File

@ -5,8 +5,6 @@ Microsoft Research Singularity
Copyright (c) Microsoft Corporation. All rights reserved. Copyright (c) Microsoft Corporation. All rights reserved.
File: Applications\YourApp\YourApp.csproj
Note: This is the template for a basic console app. Note: This is the template for a basic console app.
############################################################################## ##############################################################################
@ -56,7 +54,12 @@ Note: This is the template for a basic console app.
<ProjectReference Include="$(SINGULARITY_ROOT)\Libraries\FileSystem.Utils\FileSystem.Utils.csproj"/> <ProjectReference Include="$(SINGULARITY_ROOT)\Libraries\FileSystem.Utils\FileSystem.Utils.csproj"/>
<ProjectReference Include="$(SINGULARITY_ROOT)\Libraries\DirectoryService.Utils\DirectoryService.Utils.csproj"/> <ProjectReference Include="$(SINGULARITY_ROOT)\Libraries\DirectoryService.Utils\DirectoryService.Utils.csproj"/>
<ProjectReference Include="$(SINGULARITY_ROOT)\Libraries\Security\Security.csproj"/> <ProjectReference Include="$(SINGULARITY_ROOT)\Libraries\Security\Security.csproj"/>
</ItemGroup>
<!-- Include all of the MSIL assemblies needed to build the kernel -->
<Content Include="Kernel\Kernel.exe"/>
<Content Include="Kernel\*.dll"/>
<Content Include="Kernel\*.pdb"/>
</ItemGroup>
<Import Project="$(SINGULARITY_ROOT)\Targets\ConsoleCategory.targets"/> <Import Project="$(SINGULARITY_ROOT)\Targets\ConsoleCategory.targets"/>
</Project> </Project>

View File

@ -0,0 +1,29 @@
@echo.
@echo *** Checking out Bartok MSIL files.
@echo.
sd edit msil\bartok.*
@if errorlevel 1 goto exit
@echo.
@echo *** Copying files from Bartok enlistment.
@echo.
@if exist c:\othercode\act\bartok\obj\sing-debug-x86-x86\nul (
copy c:\othercode\act\bartok\obj\sing-debug-x86-x86\bartok.* msil
@if errorlevel 1 goto exit
)
@if exist c:\act\bartok\obj\sing-debug-x86-x86\nul (
copy c:\act\bartok\obj\sing-debug-x86-x86\bartok.* msil
@if errorlevel 1 goto exit
)
@if exist c:\home\act-dev7\bartok\obj\sing-debug-x86-x86\nul (
copy c:\home\act-dev7\bartok\obj\sing-debug-x86-x86\bartok.* msil
@if errorlevel 1 goto exit
)
@echo.
@echo *** Deleting unused files.
@echo.
del msil\bartok.tryallextension.* 2>nul

View File

@ -0,0 +1 @@

Some files were not shown because too many files have changed in this diff Show More