Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ CorJitResult compileMethod(ICorJitInfo* comp, /* IN */
struct CORINFO_METHOD_INFO* info, /* IN */
unsigned /* code:CorJitFlag */ flags, /* IN */
uint8_t** nativeEntry, /* OUT */
uint32_t* nativeSizeOfCode /* OUT */
uint32_t* nativeSizeOfCode, /* OUT */
double* perfScore /* OUT */
);

// Do any appropriate work at process shutdown. Default impl is to do nothing.
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/ToolBox/superpmi/superpmi-shared/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class Logger
enum IssueType
{
ISSUE_ASSERT,
ISSUE_ASM_DIFF
ISSUE_ASM_DIFF,
};

//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ CorJitResult interceptor_ICJC::compileMethod(ICorJitInfo* comp,
struct CORINFO_METHOD_INFO* info, /* IN */
unsigned /* code:CorJitFlag */ flags, /* IN */
uint8_t** nativeEntry, /* OUT */
uint32_t* nativeSizeOfCode /* OUT */
uint32_t* nativeSizeOfCode, /* OUT */
double* perfScore /* OUT */
)
{
interceptor_ICJI our_ICorJitInfo;
Expand Down Expand Up @@ -60,7 +61,7 @@ CorJitResult interceptor_ICJC::compileMethod(ICorJitInfo* comp,
}

CorJitResult temp =
original_ICorJitCompiler->compileMethod(&our_ICorJitInfo, info, flags, nativeEntry, nativeSizeOfCode);
original_ICorJitCompiler->compileMethod(&our_ICorJitInfo, info, flags, nativeEntry, nativeSizeOfCode, perfScore);

if (temp == CORJIT_OK)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ CorJitResult interceptor_ICJC::compileMethod(ICorJitInfo* comp,
struct CORINFO_METHOD_INFO* info, /* IN */
unsigned /* code:CorJitFlag */ flags, /* IN */
uint8_t** nativeEntry, /* OUT */
uint32_t* nativeSizeOfCode /* OUT */
uint32_t* nativeSizeOfCode,/* OUT */
double* perfScore /* OUT */
)
{
interceptor_ICJI our_ICorJitInfo;
Expand All @@ -19,7 +20,7 @@ CorJitResult interceptor_ICJC::compileMethod(ICorJitInfo* comp,

mcs->AddCall("compileMethod");
CorJitResult temp =
original_ICorJitCompiler->compileMethod(&our_ICorJitInfo, info, flags, nativeEntry, nativeSizeOfCode);
original_ICorJitCompiler->compileMethod(&our_ICorJitInfo, info, flags, nativeEntry, nativeSizeOfCode, perfScore);

return temp;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ CorJitResult interceptor_ICJC::compileMethod(ICorJitInfo* comp,
struct CORINFO_METHOD_INFO* info, /* IN */
unsigned /* code:CorJitFlag */ flags, /* IN */
uint8_t** nativeEntry, /* OUT */
uint32_t* nativeSizeOfCode /* OUT */
uint32_t* nativeSizeOfCode, /* OUT */
double* perfScore /* OUT */

)
{
interceptor_ICJI our_ICorJitInfo;
our_ICorJitInfo.original_ICorJitInfo = comp;

CorJitResult temp =
original_ICorJitCompiler->compileMethod(&our_ICorJitInfo, info, flags, nativeEntry, nativeSizeOfCode);
original_ICorJitCompiler->compileMethod(&our_ICorJitInfo, info, flags, nativeEntry, nativeSizeOfCode, perfScore);

return temp;
}
Expand Down
15 changes: 12 additions & 3 deletions src/coreclr/ToolBox/superpmi/superpmi/jitinstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,10 @@ bool JitInstance::reLoad(MethodContext* firstContext)
return true;
}

JitInstance::Result JitInstance::CompileMethod(MethodContext* MethodToCompile, int mcIndex, bool collectThroughput)
JitInstance::Result JitInstance::CompileMethod(MethodContext* MethodToCompile,
int mcIndex,
bool collectThroughput,
double* perfScore)
{
struct Param : FilterSuperPMIExceptionsParam_CaptureException
{
Expand All @@ -286,12 +289,14 @@ JitInstance::Result JitInstance::CompileMethod(MethodContext* MethodToCompile, i
unsigned flags;
int mcIndex;
bool collectThroughput;
double perfScore;
} param;
param.pThis = this;
param.result = RESULT_SUCCESS; // assume success
param.flags = 0;
param.mcIndex = mcIndex;
param.collectThroughput = collectThroughput;
param.perfScore = 0.0;

// store to instance field our raw values, so we can figure things out a bit later...
mc = MethodToCompile;
Expand All @@ -307,12 +312,13 @@ JitInstance::Result JitInstance::CompileMethod(MethodContext* MethodToCompile, i
uint32_t NCodeSizeBlock = 0;

pParam->pThis->mc->repCompileMethod(&pParam->info, &pParam->flags);
double perfScore = 0.0;
if (pParam->collectThroughput)
{
pParam->pThis->lt.Start();
}
CorJitResult jitResult = pParam->pThis->pJitInstance->compileMethod(pParam->pThis->icji, &pParam->info,
pParam->flags, &NEntryBlock, &NCodeSizeBlock);
pParam->flags, &NEntryBlock, &NCodeSizeBlock, &perfScore);
if (pParam->collectThroughput)
{
pParam->pThis->lt.Stop();
Expand Down Expand Up @@ -363,6 +369,7 @@ JitInstance::Result JitInstance::CompileMethod(MethodContext* MethodToCompile, i
pParam->pThis->mc->cr->recAllocGCInfoCapture();

pParam->pThis->mc->cr->recMessageLog("Successful Compile");
pParam->perfScore = perfScore;
}
else
{
Expand Down Expand Up @@ -397,6 +404,7 @@ JitInstance::Result JitInstance::CompileMethod(MethodContext* MethodToCompile, i
}

mc->cr->secondsToCompile = stj.GetSeconds();
*perfScore = param.perfScore;

return param.result;
}
Expand All @@ -414,8 +422,9 @@ void JitInstance::timeResult(CORINFO_METHOD_INFO info, unsigned flags)
{
delete mc->cr;
mc->cr = new CompileResult();
double perfScore;
lt.Start();
pJitInstance->compileMethod(icji, &info, flags, &NEntryBlock, &NCodeSizeBlock);
pJitInstance->compileMethod(icji, &info, flags, &NEntryBlock, &NCodeSizeBlock, &perfScore);
lt.Stop();
time = lt.GetCycles();
if (times[1] == 0)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/ToolBox/superpmi/superpmi/jitinstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class JitInstance

bool resetConfig(MethodContext* firstContext);

Result CompileMethod(MethodContext* MethodToCompile, int mcIndex, bool collectThroughput);
Result CompileMethod(MethodContext* MethodToCompile, int mcIndex, bool collectThroughput, double* perfScore);

const WCHAR* getForceOption(const WCHAR* key);
const WCHAR* getOption(const WCHAR* key);
Expand Down
23 changes: 15 additions & 8 deletions src/coreclr/ToolBox/superpmi/superpmi/parallelsuperpmi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ void ProcessChildStdOut(const CommandLine::Options& o,
int* excluded,
int* missing,
int* diffs,
double* totalPerfScore,
double* totalPerfScore2,
bool* usageError)
{
char buff[MAX_LOG_LINE_SIZE];
Expand Down Expand Up @@ -255,12 +257,14 @@ void ProcessChildStdOut(const CommandLine::Options& o,
else if (strncmp(buff, g_AllFormatStringFixedPrefix, strlen(g_AllFormatStringFixedPrefix)) == 0)
{
int childLoaded = 0, childJitted = 0, childFailed = 0, childExcluded = 0, childMissing = 0;
double perfScore = 0.0, perfScore2 = 0.0;

if (o.applyDiff)
{
int childDiffs = 0;
int converted = sscanf_s(buff, g_AsmDiffsSummaryFormatString, &childLoaded, &childJitted, &childFailed,
&childExcluded, &childMissing, &childDiffs);
if (converted != 6)
&childExcluded, &childMissing, &childDiffs, &perfScore, &perfScore2);
if (converted != 8)
{
LogError("Couldn't parse status message: \"%s\"", buff);
continue;
Expand All @@ -269,9 +273,9 @@ void ProcessChildStdOut(const CommandLine::Options& o,
}
else
{
int converted =
sscanf_s(buff, g_SummaryFormatString, &childLoaded, &childJitted, &childFailed, &childExcluded, &childMissing);
if (converted != 5)
int converted = sscanf_s(buff, g_SummaryFormatString, &childLoaded, &childJitted, &childFailed,
&childExcluded, &childMissing, &perfScore);
if (converted != 6)
{
LogError("Couldn't parse status message: \"%s\"", buff);
continue;
Expand All @@ -283,6 +287,8 @@ void ProcessChildStdOut(const CommandLine::Options& o,
*failed += childFailed;
*excluded += childExcluded;
*missing += childMissing;
*totalPerfScore += perfScore;
*totalPerfScore2 += perfScore2;
}
}

Expand Down Expand Up @@ -625,13 +631,14 @@ int doParallelSuperPMI(CommandLine::Options& o)
bool usageError = false; // variable to flag if we hit a usage error in SuperPMI

int loaded = 0, jitted = 0, failed = 0, excluded = 0, missing = 0, diffs = 0;
double perfScore = 0.0, perfScore2 = 0.0;

// Read the stderr files and log them as errors
// Read the stdout files and parse them for counts and log any MISSING or ISSUE errors
for (int i = 0; i < o.workerCount; i++)
{
ProcessChildStdErr(arrStdErrorPath[i]);
ProcessChildStdOut(o, arrStdOutputPath[i], &loaded, &jitted, &failed, &excluded, &missing, &diffs, &usageError);
ProcessChildStdOut(o, arrStdOutputPath[i], &loaded, &jitted, &failed, &excluded, &missing, &diffs, &perfScore, &perfScore2, &usageError);
if (usageError)
break;
}
Expand All @@ -652,11 +659,11 @@ int doParallelSuperPMI(CommandLine::Options& o)
{
if (o.applyDiff)
{
LogInfo(g_AsmDiffsSummaryFormatString, loaded, jitted, failed, excluded, missing, diffs);
LogInfo(g_AsmDiffsSummaryFormatString, loaded, jitted, failed, excluded, missing, diffs, perfScore, perfScore2);
}
else
{
LogInfo(g_SummaryFormatString, loaded, jitted, failed, excluded, missing);
LogInfo(g_SummaryFormatString, loaded, jitted, failed, excluded, missing, perfScore);
}
}

Expand Down
24 changes: 17 additions & 7 deletions src/coreclr/ToolBox/superpmi/superpmi/superpmi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ extern int doParallelSuperPMI(CommandLine::Options& o);
// There must be a single, fixed prefix common to all strings, to ease the determination of when
// to parse the string fully.
const char* const g_AllFormatStringFixedPrefix = "Loaded ";
const char* const g_SummaryFormatString = "Loaded %d Jitted %d FailedCompile %d Excluded %d Missing %d";
const char* const g_AsmDiffsSummaryFormatString = "Loaded %d Jitted %d FailedCompile %d Excluded %d Missing %d Diffs %d";
const char* const g_SummaryFormatString = "Loaded %d Jitted %d FailedCompile %d Excluded %d Missing %d PerfScore %f";
const char* const g_AsmDiffsSummaryFormatString = "Loaded %d Jitted %d FailedCompile %d Excluded %d Missing %d Diffs %d, PerfScore %f, PerfScore2 %f";

//#define SuperPMI_ChewMemory 0x7FFFFFFF //Amount of address space to consume on startup

Expand Down Expand Up @@ -248,6 +248,8 @@ int __cdecl main(int argc, char* argv[])
int missingCount = 0;
int index = 0;
int excludedCount = 0;
double totalPerfScore = 0;
double totalPerfScore2 = 0;

st1.Start();
NearDiffer nearDiffer(o.targetArchitecture, o.useCoreDisTools);
Expand Down Expand Up @@ -354,9 +356,11 @@ int __cdecl main(int argc, char* argv[])
}

jittedCount++;
double perfScore = 0.0;
st3.Start();
res = jit->CompileMethod(mc, reader->GetMethodContextIndex(), collectThroughput);
res = jit->CompileMethod(mc, reader->GetMethodContextIndex(), collectThroughput, &perfScore);
st3.Stop();
totalPerfScore += perfScore;
LogDebug("Method %d compiled in %fms, result %d", reader->GetMethodContextIndex(), st3.GetMilliseconds(), res);

if ((res == JitInstance::RESULT_SUCCESS) && Logger::IsLogLevelEnabled(LOGLEVEL_DEBUG))
Expand All @@ -372,9 +376,11 @@ int __cdecl main(int argc, char* argv[])
crl = mc->cr;
mc->cr = new CompileResult();

perfScore = 0.0;
st4.Start();
res2 = jit2->CompileMethod(mc, reader->GetMethodContextIndex(), collectThroughput);
res2 = jit2->CompileMethod(mc, reader->GetMethodContextIndex(), collectThroughput, &perfScore);
st4.Stop();
totalPerfScore2 += perfScore;
LogDebug("Method %d compiled by JIT2 in %fms, result %d", reader->GetMethodContextIndex(),
st4.GetMilliseconds(), res2);

Expand Down Expand Up @@ -587,12 +593,16 @@ int __cdecl main(int argc, char* argv[])
// NOTE: these output status strings are parsed by parallelsuperpmi.cpp::ProcessChildStdOut().
if (o.applyDiff)
{
LogInfo(g_AsmDiffsSummaryFormatString, loadedCount, jittedCount, failToReplayCount, excludedCount,
missingCount, jittedCount - failToReplayCount - matchCount);
LogInfo(g_AsmDiffsSummaryFormatString, loadedCount, jittedCount, failToReplayCount, excludedCount, missingCount,
jittedCount - failToReplayCount - matchCount, totalPerfScore, totalPerfScore2);

LogIssue(ISSUE_ASM_DIFF, g_AsmDiffsSummaryFormatString, loadedCount, jittedCount, failToReplayCount,
excludedCount, missingCount,
jittedCount - failToReplayCount - matchCount, totalPerfScore, totalPerfScore2);
}
else
{
LogInfo(g_SummaryFormatString, loadedCount, jittedCount, failToReplayCount, excludedCount, missingCount);
LogInfo(g_SummaryFormatString, loadedCount, jittedCount, failToReplayCount, excludedCount, missingCount, totalPerfScore);
}

st2.Stop();
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/inc/corjit.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ class ICorJitCompiler
struct CORINFO_METHOD_INFO *info, /* IN */
unsigned /* code:CorJitFlag */ flags, /* IN */
uint8_t **nativeEntry, /* OUT */
uint32_t *nativeSizeOfCode /* OUT */
uint32_t *nativeSizeOfCode, /* OUT */
double *perfScore /* OUT */
) = 0;

// Do any appropriate work at process shutdown. Default impl is to do nothing.
Expand Down
9 changes: 9 additions & 0 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6966,6 +6966,7 @@ int jitNativeCode(CORINFO_METHOD_HANDLE methodHnd,
CORINFO_METHOD_INFO* methodInfo,
void** methodCodePtr,
uint32_t* methodCodeSize,
double* perfScore,
JitFlags* compileFlags,
void* inlineInfoPtr)
{
Expand Down Expand Up @@ -7012,6 +7013,7 @@ int jitNativeCode(CORINFO_METHOD_HANDLE methodHnd,
uint32_t* methodCodeSize;
JitFlags* compileFlags;
InlineInfo* inlineInfo;
double perfScore;
#if MEASURE_CLRAPI_CALLS
WrapICorJitInfo* wrapCLR;
#endif
Expand All @@ -7029,6 +7031,7 @@ int jitNativeCode(CORINFO_METHOD_HANDLE methodHnd,
param.methodCodeSize = methodCodeSize;
param.compileFlags = compileFlags;
param.inlineInfo = inlineInfo;
param.perfScore = 0.0;
#if MEASURE_CLRAPI_CALLS
param.wrapCLR = nullptr;
#endif
Expand Down Expand Up @@ -7084,6 +7087,7 @@ int jitNativeCode(CORINFO_METHOD_HANDLE methodHnd,
// Now generate the code
pParam->result = pParam->pComp->compCompile(pParam->classPtr, pParam->methodCodePtr, pParam->methodCodeSize,
pParam->compileFlags);
pParam->perfScore = pParam->pComp->info.compPerfScore;
}
finallyErrorTrap()
{
Expand Down Expand Up @@ -7124,6 +7128,11 @@ int jitNativeCode(CORINFO_METHOD_HANDLE methodHnd,

result = param.result;

if (perfScore != nullptr)
{
*perfScore = param.perfScore;
}

if (!inlineInfo &&
(result == CORJIT_INTERNALERROR || result == CORJIT_RECOVERABLEERROR || result == CORJIT_IMPLLIMITATION) &&
!jitFallbackCompile)
Expand Down
5 changes: 3 additions & 2 deletions src/coreclr/jit/ee_il_dll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ CorJitResult CILJit::compileMethod(ICorJitInfo* compHnd,
CORINFO_METHOD_INFO* methodInfo,
unsigned flags,
uint8_t** entryAddress,
uint32_t* nativeSizeOfCode)
uint32_t* nativeSizeOfCode,
double* perfScore)
{
JitFlags jitFlags;

Expand All @@ -274,7 +275,7 @@ CorJitResult CILJit::compileMethod(ICorJitInfo* compHnd,
assert(methodInfo->ILCode);

result = jitNativeCode(methodHandle, methodInfo->scope, compHnd, methodInfo, &methodCodePtr, nativeSizeOfCode,
&jitFlags, nullptr);
perfScore, &jitFlags, nullptr);

if (result == CORJIT_OK)
{
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/jit/ee_il_dll.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class CILJit : public ICorJitCompiler
CORINFO_METHOD_INFO* methodInfo, /* IN */
unsigned flags, /* IN */
uint8_t** nativeEntry, /* OUT */
uint32_t* nativeSizeOfCode /* OUT */
uint32_t* nativeSizeOfCode, /* OUT */
double* perfScore = nullptr /* OUT */
);

void ProcessShutdownWork(ICorStaticInfo* statInfo);
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/fginline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ void Compiler::fgInvokeInlineeCompiler(GenTreeCall* call, InlineResult* inlineRe
int result =
jitNativeCode(pParam->fncHandle, pParam->inlineCandidateInfo->methInfo.scope,
pParam->pThis->info.compCompHnd, &pParam->inlineCandidateInfo->methInfo,
(void**)pParam->inlineInfo, nullptr, &compileFlagsForInlinee, pParam->inlineInfo);
(void**)pParam->inlineInfo, nullptr, nullptr, &compileFlagsForInlinee, pParam->inlineInfo);

if (result != CORJIT_OK)
{
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/jit.h
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,7 @@ extern int jitNativeCode(CORINFO_METHOD_HANDLE methodHnd,
CORINFO_METHOD_INFO* methodInfo,
void** methodCodePtr,
uint32_t* methodCodeSize,
double* perfScore,
JitFlags* compileFlags,
void* inlineInfoPtr);

Expand Down
Loading