Transcription of Monte-Carlo Simulation on AM57x Using OpenCL …
1 1 TIDUAR9 September2015 SubmitDocumentationFeedbackCopyright 2015,TexasInstrumentsIncorporatedMonte-C arloSimulationonAM57xUsingOpenCLtoLevera geDSPA ccelerationTI DesignsMonte-CarloSimulationon AM57xUsingOpenCLtoLeverageDSPA ccelerationARM,Cortexare registeredtrademarksof a trademarkof a registeredtrademarkof othertrademarksare the propertyof DesignsTI Designsprovidethe foundationthat you needincludingmethodology,testingand designfiles toquicklyevaluateand customizethe Designshelpyouaccelerateyourtime to E2E ExpertsWEBENCH CalculatorToolsDesignFeatures EnablesUse of the DSPA cceleratorsWithoutRequiringthe Userto HaveExpertKnowledgeofDSP Providesan Exampleof the Monte-CarloAlgorithmto GenerateGaussianRandomSequencesThatRun Fasteron the C66xDSPT hanon The ARM Cortex -A15 Core Offersa CompleteSystemReferenceDesignWithExample SoftwareImplementedand TestedUsingthe TI ProcessorSDKand the TI AM57xEVM
2 IncludesSoftwareSource,Schematics,Bill ofMaterials,and DesignFiles Applicableto Any ApplicationThatUsesthe BusinessStrategy RadioChannelSimulation PersonalFinance TrafficLoad(RoadCongestion,NetworkCapaci ty,and More)An IMPORTANTNOTICEat the end of this TI referencedesignaddressesauthorizeduse, intellectualpropertymattersand otherimportantdisclaimersand September2015 SubmitDocumentationFeedbackCopyright 2015,TexasInstrumentsIncorporatedMonte-C arloSimulationonAM57xUsingOpenCLtoLevera geDSPA cceleration1 DesignSummaryThis TI Designis an exampleof how to DSPeasyfor developersand is usedfor applicationssuchas medicalimaging,currencycountersand sorters,visioninspectionsystems.
3 And designshowsDSPacceleratorsfor theMonte-Carlosimulationusingthe Linux OpenCLprogramthat run on the a commonlyusedtool in manyfieldssuchas physics,communications,publicutilities,a nd Normal(Gaussian)distributedrandomnumbers equenceis an essentialpart of computationalload to generatelong normaldistributedrandomsequenceis manymodels,this load consumesmostof the designedto efficientlyexecutedigitalsignalalgorithm s,suchas the generationof designusesthe DSPto generatethe randomsequenceusinga standardOpenCLcoderunningonthe Cortex-A15processorunderthe showsthe GeneratingNormalDistributedRandomSequenc eTrueRandomNumberGenerationis generatedby s SecurityAcceleratorIP has atrue (PRNG)
4 Can be generatedbysoftwareand has generateuniformlydistributedrandomsequen ceare commonlyusemethodis the LinearCongruentialGenerator(LCG) LCGstartswith an initialseedandgeneratesrandomsequencebas edon Equation1:Xn+1 = (a Xn=c) Mod(M)(1)The followingare valuesand theirdescriptions:X0 a seedM the moduloa the multiplierc the incrementUndercertainconditions,the lengthof the sequence(the numberof randomnumbersbeforethesequencestartsrepe ating)is generatesnumbersthat are pseudo-uniformlydistributedbetween1 and M.
5 ScalingLCGsequenceto a uniformlydistributedsequencein the rangeof[ 1, 1] is (X)P [X] log P [X]c= -= c= c September2015 SubmitDocumentationFeedbackCopyright 2015,TexasInstrumentsIncorporatedMonte-C arloSimulationonAM57xUsingOpenCLtoLevera geDSPA ccelerationTo convertuniformlydistributedrandomsequenc einto a NormalGaussianrandomsequence,the designusesthe polarformof the Box-Mullertransformation(seeReference1 in Section4).The NormalGaussiandistributionhas two parameters,the average,and the a sequenceof N randomvariables:X (n), n = 1.
6 NThe average(or E (X)) = ( X (n)) NStandardDeviation = sqrt [E(X m)2]For a standardnormaldistributioncase, = 0 and = get Gaussianrandomvariablesfromuniformlydist ributedrandomvariableis asfollows:1. Get two uniformlydistributed( , ),x and y2. Calculatew = (x x + y y)3. If w < sqrt(( log (w) ) w)4. y1 = x y5. y2 = y wY1 and Y2 are two ,SequenceLength,and ParallelComputationMultipletestsare suggestedin the literaturefor the randomness of a NormalRandomsequence: Havethe correctdistribution(lim (1 n S(X (n)) ~ N (0,1) No predictability(Afterreachingthe lengthof the sequence,the sequencebeginsto preferableto shortersequences.)))
7 Auto-correlationgoesto infinite,crossingcorrelationgoesto zero (lim (S (X (n) X (n)) ) (lim (s (X (n) X (n k)) 0)Measurethe entropy lack of orderor predictability;For a finitesequenceX, the entropyis definedinthe formulain Equation1. (seethe discussionin Reference2 in Section4).Figure2. Equation2 Manypublicationsdiscusshow to choosethe constantsa, M, and c, and the initialseedx0 to achievepositiverandomnessfeatures(seeRef erence3 in Section4).TI chosea and M as constantsforEquation1 to ensurea long this TI designto use the full powerof the multipleDSPaccelerators,it mustmergemultipleindependentrandomsequen cesinto a singlerandomsequencewhilepreservingthe in Section4 suggestsa methodof choosingthe additiveconstantc for designusesa set of primenumbersfor parallelgeneratingof a portableheterogeneousstandardcomputingla nguagethat supportsthe easyuse of genericacceleratorsfor OpenCLapplications.))
8 Knowledgeaboutthe architectureof the acceleratoris codecan run on differentdeviceswith (kernel)is writtenin C or otherstandardlanguage,and the systemknowswhatcompilerto use to convertthe codeinto an a genericOpenCLcodethat requiresno knowledgeof the the developerisfamiliarwith the acceleratorarchitecture,and is willingto give up portability,architectureoptimizedexecuta blemay be usedby the deviceCompute deviceCompute unitMultiple processing elementsCompute unitMultiple processing elementsCompute unitMultiple processing elementsCompute unitMultiple processing elementsCompute unitMultiple processing elementsCompute unitMultiple processing September2015 SubmitDocumentationFeedbackCopyright 2015.
9 TexasInstrumentsIncorporatedMonte-CarloS imulationonAM57xUsingOpenCLtoLeverageDSP A ccelerationOpenCLstandardbodyis implementationof OpenCLon the AM57xis , see .In this TI design,the DSPacceleratorcodeis developedusingANSIC ,the projectmaybe easilyportedto otherdeviceswith showsthe OpenCLPlatformModelA host is connectedto one or OpenCLdeviceis a collectionof one or morecomputeunitsthat sharethe caseof the AM57x ,the host is the the set of C66xDSPs,and the computeunit is a September2015 SubmitDocumentationFeedbackCopyright 2015, acceleratorsusedin this TI designare kernelcodeis writtenin standardANSIC.
10 Sono intrinsicor assemblylanguageis codetakesadvantageof the C66xmemoryarchitecture,and the eightfunctionalunitsinsidethe core. The codeusesTI real-timestandardoptimizedMathlibraryfor standardMathfunctionssuchassquareroot,lo g, one overx, and so on. The runtimelibrarythat containsthesefunctionsis part of thestandardreleaseand is linkedby the devicethat supportsC musthavea similarlibrary(withthe sameor very similarsyntax)so portingthesefunctionsto anotherarchitectureis simple. The codetakesadvantageof the L1 DataSRAM part of the is a 32-KBareaof zerowait-stateaccesstime that is usedto storeand all acceleratorshaveL1 SRAM.
