Add command line option to choose atomics path for compression.

This commit is contained in:
Pavel Krajcevski 2013-03-06 20:58:01 -05:00
parent 3d1d1e359f
commit dbabd5e399
2 changed files with 21 additions and 3 deletions

View file

@ -59,6 +59,7 @@ void PrintUsage() {
fprintf(stderr, "\t-n <num>\tCompress the image num times and give the average time and PSNR. Default: 1\n");
fprintf(stderr, "\t-simd\t\tUse SIMD compression path\n");
fprintf(stderr, "\t-t <num>\tCompress the image using <num> threads. Default: 1\n");
fprintf(stderr, "\t-a \tCompress the image using synchronization via atomic operations. Default: Off\n");
fprintf(stderr, "\t-j <num>\tUse <num> blocks for each work item in a worker queue threading model. Default: (Blocks / Threads)\n");
}
@ -91,6 +92,7 @@ int _tmain(int argc, _TCHAR* argv[])
int numCompressions = 1;
bool bUseSIMD = false;
bool bSaveLog = false;
bool bUseAtomics = false;
bool knowArg = false;
do {
@ -162,6 +164,12 @@ int _tmain(int argc, _TCHAR* argv[])
continue;
}
if(strcmp(argv[fileArg], "-a") == 0) {
fileArg++;
bUseAtomics = true;
knowArg = true;
continue;
}
} while(knowArg && fileArg < argc);
if(numThreads > 1 && bSaveLog) {
@ -194,6 +202,7 @@ int _tmain(int argc, _TCHAR* argv[])
SCompressionSettings settings;
settings.bUseSIMD = bUseSIMD;
settings.bUseAtomics = bUseAtomics;
settings.iNumThreads = numThreads;
settings.iQuality = quality;
settings.iNumCompressions = numCompressions;

View file

@ -184,13 +184,15 @@ class AtomicThreadUnit : public TCCallable {
m_OutBuf(outBuf),
m_Height(height),
m_Width(width),
m_Barrier(barrier)
m_Barrier(barrier),
m_NumCompressions(nCompressions),
m_CmpFnc(f)
{ }
virtual ~AtomicThreadUnit() { }
virtual void operator()() {
m_Barrier->Wait();
for(int i = 0; i < m_NumCompressions; i++)
for(uint32 i = 0; i < m_NumCompressions; i++)
(*m_CmpFnc)(m_InBuf, m_OutBuf, m_Width, m_Height);
}
};
@ -374,7 +376,14 @@ bool CompressImageData(
double cmpMSTime = 0.0;
if(settings.iNumThreads > 1) {
if(settings.iJobSize > 0)
if(settings.bUseAtomics) {
//!KLUDGE!
unsigned int height = 4;
unsigned int width = dataSz / 16;
cmpMSTime = CompressImageWithAtomics(data, width, height, settings, cmpData);
}
else if(settings.iJobSize > 0)
cmpMSTime = CompressImageWithWorkerQueue(data, dataSz, settings, cmpData);
else
cmpMSTime = CompressImageWithThreads(data, dataSz, settings, cmpData);