eZak
BAN USER#include <map>
class AlignedMemoryManager
{
public:
void* MallocAligned( uint size, uint alignment);
bool FreeAligned( uintptr_t address);
private:
std::map<void*,void*> allocationMap_;
}
void* AlignedMemoryManager::MallocAligned( uint size, uint alignment){
{
size_t actualSize = (alignment-1)+size;
void * result = malloc(actualSize);
void* alignedResult = NULL;
if( result != NULL )
{
alignedResult = result + result%alignments
allocationMap_.insert(make_pair(alignedResult, result ) );
}
return alignedResult;
}
bool AlignedMemoryManager::FreeAligned( uintptr_t address)
{
std::map<void*,void*>::iterator it = allocationMap_.find( address );
if( it != allocationMap_.end() )
{
free( it->second);
allocationMap_.erase( it)
return true;
}
return false;
}
RepMelissaJoy, Associate at Bocada
Hi, I am Melissa, a purchasing agent from Texas. Kind of a good Samaritan, terrible athlete, but extremely blessed in ...
Repcarmelalewis9, Area Sales Manager at AMD
I am fond of reading stories then reading articles which are all about a story of a beautiful nature and ...
I would replace 2-4 steps with the following:
- eZak October 05, 20152) In the 320ns, we can clear reading 320/5=64 words
3) We need 80-64=16 words in buffer
Sanity check:
20 idle write cycle are 80 ns which are 16 read cycles --> we manage to clear the FIFO for next burst