Allow AMD's implementation of FFT's to allocate internal resources
| 26 | |
| 27 | // Allow AMD's implementation of FFT's to allocate internal resources |
| 28 | clfftStatus clfftSetup( const clfftSetupData* sData ) |
| 29 | { |
| 30 | // Static data is not thread safe (to create), so we implement a lock to protect instantiation for the first call |
| 31 | // Implemented outside of FFTRepo::getInstance to minimize lock overhead; this is only necessary on first creation |
| 32 | scopedLock sLock( FFTRepo::lockRepo, _T( "FFTRepo::getInstance" ) ); |
| 33 | |
| 34 | // First invocation of this function will allocate the FFTRepo singleton; thereafter the object always exists |
| 35 | FFTRepo& fftRepo = FFTRepo::getInstance( ); |
| 36 | |
| 37 | clfftInitRequestLibNoMemAlloc(); |
| 38 | clfftInitBinaryCache(); |
| 39 | |
| 40 | // Discover and load the timer module if present |
| 41 | fftRepo.timerHandle = LoadSharedLibrary( "lib", "StatTimer", true ); |
| 42 | if( fftRepo.timerHandle ) |
| 43 | { |
| 44 | // Timer module discovered and loaded successfully |
| 45 | // Initialize function pointers to call into the shared module |
| 46 | PFGETSTATTIMER pfGetStatTimer = reinterpret_cast< PFGETSTATTIMER > ( LoadFunctionAddr( fftRepo.timerHandle, "getStatTimer" ) ); |
| 47 | |
| 48 | // Create and initialize our timer class, if the external timer shared library loaded |
| 49 | if( pfGetStatTimer ) |
| 50 | { |
| 51 | fftRepo.pStatTimer = reinterpret_cast< GpuStatTimer* > ( pfGetStatTimer( CLFFT_GPU ) ); |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | // If the client has no setupData, we are done |
| 56 | if( sData == NULL ) |
| 57 | return CLFFT_SUCCESS; |
| 58 | |
| 59 | // Versioning checks commented out until necessary |
| 60 | //// If the major version number between the client and library do not match, return mismatch |
| 61 | //if( sData->major > clfftVersionMajor ) |
| 62 | // return CLFFT_VERSION_MISMATCH; |
| 63 | |
| 64 | //// If the minor version number between the client and library do not match, return mismatch |
| 65 | //if( sData->minor > clfftVersionMinor ) |
| 66 | // return CLFFT_VERSION_MISMATCH; |
| 67 | |
| 68 | //// We ignore patch version number for version validation |
| 69 | |
| 70 | fftRepo.setupData = *sData; |
| 71 | |
| 72 | return CLFFT_SUCCESS; |
| 73 | } |
| 74 | |
| 75 | // Allow AMD's implementation of FFT's to destroy internal resources |
| 76 | clfftStatus clfftTeardown( ) |