3 Pages

ThreadedFFT-handout

Course: ECE 3090, Spring 2012
School: Georgia Tech
Rating:
 
 
 
 
 

Word Count: 535

Document Preview

2 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 // 2D FFT Using threads // George F. Riley, Georgia Tech, Fall 2009 #include <iostream> #include "pthread.h" #include "math.h" #include <sys/time.h> #include "complex.h" #include...

Register Now

Unformatted Document Excerpt

Coursehero >> Georgia >> Georgia Tech >> ECE 3090

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
2 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 // 2D FFT Using threads // George F. Riley, Georgia Tech, Fall 2009 #include <iostream> #include "pthread.h" #include "math.h" #include <sys/time.h> #include "complex.h" #include "InputImage.h" using namespace std; // We use global variables in lieu of member variables for this example Complex** h; // Points to the 2D array of complex (the input) Complex* W; // Weights (computed once in main unsigned N; // Number of elements (both width and height) unsigned nThreads; // Desired number of threads unsigned activeCount = 0; // Number of active threads // pthread variables pthread_mutex_t activeMutex; pthread_mutex_t exitMutex; pthread_cond_t exitCondition; pthread_mutex_t coutMutex; // Add a verbose flag to turn on/off extra outputs bool verbose = false; // Helper routines void DumpTransformedValues() { // Code omitted for brevity } void TransposeInPlace(Complex** m, int wh) { // code omitted for brevity } void LoadWeights() { // Compute the needed W values. } Omitted for brevity void Transform1D(Complex* h) { // The simple 1D transform we did earlier. } Code omitted for brevity Program threaded-fft.cc 1 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 void* FFT_Thread(void* v) { unsigned long myId = (unsigned long)v; // My thread number unsigned rowsPerCPU = N / nThreads; unsigned myFirstRow = myId * rowsPerCPU; // We have to do a mutex around the "activeCount++". Why? pthread_mutex_lock(&activeMutex); activeCount++; pthread_mutex_unlock(&activeMutex); if (verbose) { pthread_mutex_lock(&coutMutex); cout << "MyId is " << myId << " myFirstRow " << myFirstRow << endl; pthread_mutex_unlock(&coutMutex); } // Call the 1D FFT on each row for (unsigned i = 0; i < rowsPerCPU; ++i) { Transform1D(h[myFirstRow + i]); } // Now notify the main thread we have completed the rows pthread_mutex_lock(&exitMutex); // Insure only one thread signals the exit pthread_mutex_lock(&activeMutex); // Insure only one thread changes active activeCount--; pthread_mutex_unlock(&activeMutex); (activeCount if == 0) { // We are the last thread to exit. Signal the main thread // that all threads are done pthread_cond_signal(&exitCondition); } pthread_mutex_unlock(&exitMutex); return 0; } Program threaded-fft.cc (continued) 2 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 int main( int argc, char** argv) { verbose = argc > 3; InputImage image(argv[1]); nThreads = atol(argv[2]); // Number of threads N = image.GetHeight(); // Assume square, width = height h = image.GetRows(0, N); // In this case, we get all rows // Start the timer here, after loading the image struct timeval tp; gettimeofday(&tp, 0); double startSec = tp.tv_sec + tp.tv_usec/1000000.0; LoadWeights(); // Only need to do this once // Initialize the pthread mutex and condition variables pthread_mutex_init(&activeMutex, 0); pthread_mutex_init(&exitMutex, 0); pthread_cond_init(&exitCondition, 0); pthread_mutex_init(&coutMutex, 0); // We lock the exitMutex to be sure no threads exit until // all threads created, and we are waiting on the condition signal pthread_mutex_lock(&exitMutex); // Create the threads for (unsigned i = 0; i < nThreads; ++i) { pthread_t t; pthread_create(&t, 0, FFT_Thread, (void*)i); } // Now wait for them to finish pass 1 pthread_cond_wait(&exitCondition, &exitMutex); if (verbose) cout << "All threads finished pass 1" << endl; // Transpose the matrix and schedule threads to do rows again TransposeInPlace(h, N); // Start the threads again for (unsigned i = 0; i < nThreads; ++i) { pthread_t t; pthread_create(&t, 0, FFT_Thread, (void*)i); } // Now wait for them to finish pass 2 pthread_cond_wait(&exitCondition, &exitMutex); if (verbose) cout << "All threads finished pass 2" << endl; // Transpose back and write results TransposeInPlace(h, N); gettimeofday(&tp, 0); cout << "Calculated FFT " << (tp.tv_sec+tp.tv_usec/1000000.0) - startSec << " seconds" << endl; DumpTransformedValues(); } Program threaded-fft.cc (continued) 3
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Georgia Tech - ECE - 3090
/ Demonstrate the use of the Standard Template Library &quot;vector&quot; class. / and associated iterators, and templated subroutines / George F. Riley, ECE3090 Georgia Tech, Fall 2009 #include #include #include #include &lt;iostream&gt; &lt;vector&gt; &lt;algorithm&gt; &lt;iterator&gt;
Georgia Tech - ECE - 3090
/ Demonstrate the use of the Standard Template Library &quot;vector&quot; class. / George F. Riley, ECE3090 Georgia Tech, Fall 2009 / A vector is a variable length array. It starts out as &quot;zero&quot; length / and grows or shrinks as needed. Further, the vector is a arra
Georgia Tech - ECE - 3090
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56/ Demonstrate the use of the Standard Template Library &quot;vector&quot; class. / and associated iterator
Georgia Tech - ECE - 3090
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56/ Demonstrate the use of the Standard Template Library &quot;vector&quot; class. / George F. Riley, ECE309
Georgia Tech - ECE - 3090
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56/ Example illustrating Subclassing with virtual functions / ECE3090 / George F. Riley, Georgia T
Georgia Tech - ECE - 3090
C+SearchSearch:InformationGeneral information about the C+programming language, including nontechnical documents and descriptions:cplusplus.com Description of the C+ language History of the C+ language F.A.Q., Frequently Asked QuestionsInformati
Palm Beach Community College - HEALTH - HSC 2100
Brooke Sparks16th April 2012HSC2130T&amp;Th 3:30-4:45Genital human papillomavirus, also known as HPV for short, is the most commonsexually transmitted infection (STI) in the United States. This infection is viral. There are morethan 40 types of HPV that
NYU - ECON - ECON-UA 10
NYU - ECON - ECON-UA 10
NYU - ECON - ECON-UA 10
NYU - ECON - ECON-UA 10
Hartford - MGT - 320
Chapter 11 LocationChapter11LocationTRUE/FALSE1.If the customer must be physically present at the process, location is an important issue.Answer: TrueReference: IntroductionDifficulty: EasyKeywords: location, physical presence, customer2.Two c
Hartford - MGT - 320
11LocationPowerPoint SlidesPowerPointby Jeff HeylbyCopyright 2010 Pearson Education, Inc. Publishing as Prentice Hall.For Operations Management, 9e byFor OperationsKrajewski/Ritzman/Malhotra 2010 Pearson Education201011 1Location DecisionsLo
Hartford - MGT - 320
12Inventory ManagementPowerPoint SlidesPowerPointby Jeff HeylbyCopyright 2010 Pearson Education, Inc. Publishing as Prentice Hall.For Operations Management, 9e byFor OperationsKrajewski/Ritzman/Malhotra 2010 Pearson Education201012 1Inventory
Hartford - MGT - 320
13ForecastingPowerPoint SlidesPowerPointby Jeff HeylbyCopyright 2010 Pearson Education, Inc. Publishing as Prentice Hall.For Operations Management, 9e byFor OperationsKrajewski/Ritzman/Malhotra 2010 Pearson Education201013 1Forecasting Forec
Hartford - MGT - 320
Chapter 7 Constraint ManagementChapter7Constraint ManagementTRUE/FALSE1.A bottleneck is an operation that has the lowest effective capacity of any operation in theprocess.Answer: TrueReference: IntroductionDifficulty: ModerateKeywords: bottlene
Hartford - MGT - 320
Chapter 8 Lean SystemsChapter8Lean SystemsTRUE/FALSE1.Lean systems are operating systems that maximize the value added of each of itsactivities by paring unnecessary resources and delays from them.Answer: TrueReference: IntroductionDifficulty: E
Hartford - MGT - 320
Chapter 9 Supply Chain DesignChapter9Supply Chain DesignTRUE/FALSE1.The purpose of supply chain management is to synchronize a firms processes with thoseof its suppliers and customers.Answer: TrueReference: Supply Chains for Services and Manufact
Hartford - MGT - 320
Chapter 10 Supply Chain IntegrationChapter10Supply Chain IntegrationTRUE/FALSE1.Supply chain integration is the effective coordination of supply chain processes throughthe seamless flow of information to suppliers, but does not include customers, s
Hartford - AC - 321
Weaver General Store, Inc.Student # 1:Student # 2:Instructions1. Using the Chart of Accounts provided, record the transactions in the General Journal. Do not add new accounts.2. Post the General Journal entries to the General Ledger.3. Prepare the U
NYU - SOCIAL WOR - 101
AxisIisreservedforclinicaldisordersanddevelopmentalandlearning disorders.DisordersthatmaybepresentonAxisIinclude:PanicDisorderGeneralizedAnxietyDisorderSocialPhobiaObsessiveCompulsiveDisorderPosttraumaticStressDisorderSpecificPhobiaAxisIIisforpers
Lovely Professional University - BUISENESS - mgt 511
CAPITALMARKETCAPITAL MARKETPROLOGUEPROLOGUECapital markets are a sub-part of the financialsystem. Conceptually, the financial systemincludes a complex of institutions andmechanism which affects the generation ofsavings and their transfers to thos
Lovely Professional University - BUISENESS - mgt 511
COMPETITIONLAWSININDIACompetition Isasituationinamarketinwhichfirmsor sellers independently strive for thebuyerspatronageinordertoachieveaparticular business objective forexample,profits,salesormarketshareContd Is the foundation of an efficient w
Lovely Professional University - BUISENESS - mgt 511
Industrial FinanceDefine-Industrial Refersto a company or firms that engageslargely or exclusively in the manufacture ofproducts. An industrial company, forexample, makes a good, which it then sellseither to retailers or directly to consumersSourc
Lovely Professional University - BUISENESS - mgt 511
Industries Developmentand RegulationandIntroductionIntroductionObject of industrialisation to attainhigher levels of economic well-beingGLoalisation, liberalisation andderegulationAdaptability of each country dependslargely on ability of each co
Lovely Professional University - BUISENESS - mgt 511
MONETARY AND FISCALPOLICIESInflationInflation is a rise in the generallevel of prices of goods andservices in an economy over aperiod of time. When the pricelevel rises, each unit of currencybuys fewer goods and services. Achief measure of price
Lovely Professional University - BUISENESS - mgt 511
Intellectual property rightsIntellectualLegislativeFrameworkofIPAdministrationLegislativeFrameworkofIPAdministrationDepartment of IP &amp;P coversThe Patents Act, 1970 (as amended in 2005)The Patents Rules, 2003 (as amended in 2006)The Designs Act, 200
Lovely Professional University - BUISENESS - mgt 511
Case studyReliance Industries Ltd.By:Abhishek AgarwalRB18B2A07Ahana KaushalRB18B2A09Summary Of CaseReliance the biggest private owned group of IndiaFounded by Dhirubhai H Ambani in 1967 .Involved in production of oil and gases refining andmarket
Lovely Professional University - BUISENESS - mgt 511
PublicsectorIntro The part of the economy that is owned bythe state or that it is communally owned,including the national provincial and localauthorities and public entities. One of the three sectors of the economy,consisting of government and gove
Lovely Professional University - BUISENESS - mgt 511
Small Scale and Village IndustryAll the industrial policy resolutions have emphasized theimportance of developing the village and small industries. TheSmall scale industries have a place of pride in our economy.They have a high potential for generatin
Lovely Professional University - BUISENESS - mgt 511
Stock Exchange The stock exchange is a highly organised market for the purchase and saleof second hand quoted or listed securities. Stock exchange is a market inwhich securities are bought and sold and it is an essential component of adeveloped capita
Lovely Professional University - MANAGEMENT - mgt 511
EconomicPlanningInIndiaIntroductionTheperiodfrom1947tomid1950sPreparatoryPhaseinPlanningfordevelopmentFrom1950sto1960sRapidIndustrializationLate1960s&amp;1970sPlansfocusedonAgriculturePhaseofLiberalizationstartingtentativelyinthe1980s&amp;gearingupfrom1991
Lovely Professional University - MANAGEMENT - mgt 511
Employee participation inmanagement(Business environment)Introduction:Three groups of managerialdecisions affect the workers ofany industry:Economic decisions methodsof manufacturing, automation,The main implications of workersparticipation in m
Lovely Professional University - MANAGEMENT - mgt 511
Exitpolicyreferstothepolicyregardingtheretrenchmentofsurplusmanpowerresultingfromrestructuringofindustrialunitsortheworkersbecomingunemployedbytheclosureofsickunits.Theterm'exit'istheobverseoftheterm'entry'intoindustry.Itreferstotherightorabilityofa
Lovely Professional University - MANAGEMENT - mgt 511
Foreign Direct InvestmentForeignForeign Direct InvestmentForeign Foreigndirect investment (FDI): a firminvests directly in foreign facilitiesAfirm that engages in FDI becomes amultinational enterprise (MNE) Multinational = more than one country
Lovely Professional University - MANAGEMENT - mgt 511
INDUSTRIAL RELATIONS&amp;LABOR LAWSDEFINING IR Industrial relations encompasses a set ofphenomena, both inside and outside theworkplace, concerned with determiningand regulating employment relationship Relationship between management andemployees or
Lovely Professional University - MANAGEMENT - mgt 511
MultinationalCorporationsintheGlobalEconomy1WhatdoyouthinkaMNCis? Acorporationthathasitsfacilitiesandotherassetsinatleastonecountryotherthanitshomecountry. Suchcompanieshaveofficesand/orfactoriesindifferentcountriesandusuallyhavecentralisedheadoff
Lovely Professional University - MANAGEMENT - mgt 511
TradeLiberalisationTradeLiberalisationandtheWTOAbriefhistoryofmultilateraltradeAbriefhistoryofmultilateraltradenegotiations InternationalTradeOrganisationproposedattheBrettonWoodsConferencein1944. TheGeneralAgreementonTariffsandTrade(GATT)wasfir
Boğaziçi University - FINANCE - 257
CHAPTER 11Cash Flow Estimation andEvaluation for a ReplacementProject1Replacement Project ExampleRequired rate of return (Cost of Capital) = 11%Tax rate = 35%Original MachineBook value = 100,000Resale value today = 80,000Resale Value in 4 years
Boğaziçi University - FINANCE - 257
Chapter 9Making CapitalInvestmentDecisions0McGraw-Hill/IrwinCopyright 2008 by The McGraw-Hill Companies, Inc. All rights reserved.119 -NC-1Key Concepts and Skills Understand how to determine the relevantcash flows for a proposed investment Und
Boğaziçi University - FINANCE - 257
1-1 8-1Key Concepts and Skills Understand the payback rule and itsshortcomings Understand the internal rate of return andits strengths and weaknesses Understand the net present value rule andwhy it is the best decision criteriaChapter 8Net Presen
Boğaziçi University - FINANCE - 257
BA 2204 and BAS 324Human Resource ManagementWork flows and job analysisInstructor: ar Topal1Work: organizational perspectiveStrategy and organizationalstructure shaping structureStrategyStrategyand structure shaping HRstrategies and work flows
Boğaziçi University - FINANCE - 257
1-1 7-1Key Concepts and Skills Understand how stock prices depend onfuture dividends and dividend growth Be able to compute stock prices using thedividend growth model Understand how corporate directors areelected Understand how stock markets work
Boğaziçi University - FINANCE - 257
116 -NC-1Key Concepts and Skills Know the important bond features andbond types Understand bond values and why theyfluctuate Understand bond ratings and what theymean Understand the impact of inflation oninterest rates Understand the term struc
Boğaziçi University - FINANCE - 257
Chapter 7Equity Markets andStock Valuation0McGraw-Hill/IrwinCopyright 2008 by The McGraw-Hill Companies, Inc. All rights reserved.1-1 7-1Key Concepts and Skills Understand how stock prices depend onfuture dividends and dividend growth Be able to
Boğaziçi University - FINANCE - 257
Chapter 3Understanding Equal Opportunity and the Legal EnvironmentOBJECTIVE QUESTIONS1.The HR departments legal responsibilities include:a) monitoring the companys HR decisions.b) rendering legal opinions as to the appropriateness of HR-related deci
Boğaziçi University - FINANCE - 257
Chapter 4Managing DiversityOBJECTIVE QUESTIONS:1.You are the HRM manager in a company with a highly diverse workforce. Overlunch you are explaining to a Caucasian, middle-class, line manager that she needsto use different training techniques with he
Boğaziçi University - FINANCE - 257
Chapter 5Recruiting and Selecting EmployeesOBJECTIVE QUESTIONS1.Carmen is working through a process to ensure her company of the right number ofpeople with the right skills to meet their goals in delivering service and outputs totheir customers. Car
Boğaziçi University - FINANCE - 257
Chapter 6Managing Employee Separations, Downsizing, and OutplacementOBJECTIVE QUESTIONS1.During the late 1990s and the early 2000s, which of the following was true of thebusiness and employment environment?a) Involuntary separations increased by 30%
Boğaziçi University - FINANCE - 257
Chapter 7Appraising and Managing PerformanceOBJECTIVE QUESTIONS1.Which of the following is a comprehensive list of the functions in performanceassessment?a) Identifying, measuring, and managing human performance in organizations.b) Identifying, det
Boğaziçi University - FINANCE - 257
AchievingSuccessThroughEffectiveBusinessCommunicationBusiness Communication Today, 9e 1 - 1ChapterAchievingSuccessinTodaysCompetitiveEnvironmentWriting ClearlyWriting ClearlyCompeting for JobsCompeting for JobsSpeaking SkillfullySpeaking Skill
Boğaziçi University - FINANCE - 257
PlanningBusinessMessagesBusiness Communication Today, 9e 4 - 1ChapterThreeStepWritingProcessPlanningAnalyze SituationAnalyze SituationGather InformationGather InformationSelect MediumSelect MediumGet OrganizedGet OrganizedWritingAdapt toAd
Boğaziçi University - FINANCE - 257
WritingBusinessMessagesBusiness Communication Today, 9e 5 - 1ChapterThreeStepWritingProcessPlanningAnalyze SituationAnalyze SituationGather InformationGather InformationSelect MediumSelect MediumGet OrganizedGet OrganizedWritingAdapt toAda
Boğaziçi University - FINANCE - 257
CompletingBusinessMessagesBusiness Communication Today, 9e 6 - 1ChapterThreeStepWritingProcessPlanningAnalyze SituationAnalyze SituationGather InformationGather InformationSelect MediumSelect MediumGet OrganizedGet OrganizedWritingAdapt to
Boğaziçi University - FINANCE - 257
WritingRoutineandPositiveMessagesBusiness Communication Today, 9e 8 - 1ChapterThreeStepWritingProcessPlanningAnalyze SituationAnalyze SituationGather InformationGather InformationSelect MediumSelect MediumGet OrganizedGet OrganizedWritingAd
Boğaziçi University - FINANCE - 257
WritingNegativeMessagesBusiness Communication Today, 9e 9 - 1ChapterThreeStepWritingProcessPlanningAnalyze SituationAnalyze SituationGather InformationGather InformationSelect MediumSelect MediumGet OrganizedGet OrganizedWritingAdapt toAda
Boğaziçi University - FINANCE - 257
WritingWritingPersuasiveMessagesBusiness Communication Today, 9e 10 ChapterThreeStepWritingProcessPlanningAnalyze SituationAnalyze SituationGather InformationGather InformationSelect MediumSelect MediumGet OrganizedGet OrganizedWritingAdapt
Boğaziçi University - FINANCE - 257
CHAPTER 7EQUITY MARKETS AND STOCKVALUATIONAnswers to Concepts Review and Critical Thinking Questions1.The value of any investment depends on its cash flows; i.e., what investors will actually receive. Thecash flows from a share of stock are the divi
Boğaziçi University - FINANCE - 257
BA 2802 Principles of Finance Section IIFormulae Sheet for the Second Interim ExamSpring 2011ROE * b1 ROE * b1.Sustainable Growth Rate =2.Internal Growth Rate =3.(1 + Nominal) = (1 + Real)(1 + Inflation)4.PV6.11 (1 r ) n PVA PMTr8.Annu