Skip to content

Commit 81bb6af

Browse files
committed
Make mandelbrot test compilable without SSE or threads.
1 parent 8795cbd commit 81bb6af

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/pthread/test_pthread_mandelbrot.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
#endif
1515
#endif
1616

17+
#ifdef __SSE__
1718
#include <xmmintrin.h>
19+
#endif
1820

1921
// h: 0,360
2022
// s: 0,1
@@ -146,6 +148,7 @@ unsigned long long ComputeMandelbrot(float *srcReal, float *srcImag, uint32_t *d
146148
return (unsigned long long)((h-y)/yIncr)*w*numIters;
147149
}
148150

151+
#ifdef __SSE__
149152
// Not strictly correct anyzero_ps, but faster, and depends on that color alpha channel is always either 0xFF or 0.
150153
int anyzero_ps(__m128 m)
151154
{
@@ -249,6 +252,7 @@ unsigned long long ComputeMandelbrot_SSE(float *srcReal, float *srcImag, uint32_
249252
}
250253
return (unsigned long long)((h-y)/yIncr)*w*numIters;
251254
}
255+
#endif
252256

253257
const int W = 512;
254258
const int H = 512;
@@ -304,9 +308,11 @@ void *mandelbrot_thread(void *arg)
304308
fputs("hello", handle);
305309
fclose(handle);
306310
#endif
311+
#ifdef __SSE__
307312
if (use_sse)
308313
ni = ComputeMandelbrot_SSE(mandelReal, mandelImag, outputImage, sizeof(float)*W, sizeof(uint32_t)*W, 0, idx, numTasks, W, H, left, top, incrX, incrY, numItersDoneOnCanvas, numItersPerFrame);
309314
else
315+
#endif
310316
ni = ComputeMandelbrot(mandelReal, mandelImag, outputImage, sizeof(float)*W, sizeof(uint32_t)*W, 0, idx, numTasks, W, H, left, top, incrX, incrY, numItersDoneOnCanvas, numItersPerFrame);
311317
//emscripten_atomic_add_u32(&numIters, ni);
312318
double t1 = emscripten_get_now();
@@ -335,9 +341,11 @@ void register_tasks()
335341
for(int i = 0; i < numTasks; ++i)
336342
{
337343
double t0 = emscripten_get_now();
344+
#ifdef __SSE__
338345
if (use_sse)
339346
numIters[0] += ComputeMandelbrot_SSE(mandelReal, mandelImag, outputImage, sizeof(float)*W, sizeof(uint32_t)*W, W*i/numTasks, 0, 1, W/numTasks, H, left, top, incrX, incrY, numItersDoneOnCanvas, numItersPerFrame);
340347
else
348+
#endif
341349
numIters[0] += ComputeMandelbrot(mandelReal, mandelImag, outputImage, sizeof(float)*W, sizeof(uint32_t)*W, W*i/numTasks, 0, 1, W/numTasks, H, left, top, incrX, incrY, numItersDoneOnCanvas, numItersPerFrame);
342350
double t1 = emscripten_get_now();
343351
timeSpentInMandelbrot[0] += t1-t0;
@@ -551,7 +559,9 @@ int main(int argc, char** argv)
551559
}
552560
#endif
553561

562+
#ifndef SINGLETHREADED
554563
emscripten_set_thread_name(pthread_self(), "Mandelbrot main");
564+
#endif
555565

556566
EM_ASM("SDL.defaults.copyOnLock = false; SDL.defaults.discardOnLock = true; SDL.defaults.opaqueFrontBuffer = false;");
557567

0 commit comments

Comments
 (0)