| 297 | _Atomic uint32_t tasksPending[MAX_NUM_THREADS] = {}; |
| 298 | #ifndef SINGLETHREADED |
| 299 | void *mandelbrot_thread(void *arg) |
| 300 | { |
| 301 | long idx = (long)arg; |
| 302 | numThreadsRunning++; |
| 303 | |
| 304 | char threadName[32]; |
| 305 | sprintf(threadName, "Worker %ld", idx); |
| 306 | emscripten_set_thread_name(pthread_self(), threadName); |
| 307 | |
| 308 | for(;;) |
| 309 | { |
| 310 | while (tasksPending[idx] == 0) { |
| 311 | emscripten_futex_wait(&tasksPending[idx], 0, INFINITY); |
| 312 | } |
| 313 | tasksPending[idx] = 0; |
| 314 | double t0 = emscripten_get_now(); |
| 315 | int ni; |
| 316 | #ifdef TEST_THREAD_PROFILING |
| 317 | // If building as part of the harness, do silly things that show up in --threadprofiler, |
| 318 | // such as sleeping and proxied file i/o ops |
| 319 | usleep(2000); |
| 320 | FILE *handle = fopen("a.txt", "w"); |
| 321 | fputs("hello", handle); |
| 322 | fclose(handle); |
| 323 | #endif |
| 324 | #ifdef __SSE__ |
| 325 | if (use_sse) |
| 326 | ni = ComputeMandelbrot_SSE(mandelReal, mandelImag, outputImage, sizeof(float)*W, sizeof(uint32_t)*W, 0, (int)idx, numTasks, W, H, left, top, incrX, incrY, numItersDoneOnCanvas, numItersPerFrame); |
| 327 | else |
| 328 | #endif |
| 329 | ni = ComputeMandelbrot(mandelReal, mandelImag, outputImage, sizeof(float)*W, sizeof(uint32_t)*W, 0, (int)idx, numTasks, W, H, left, top, incrX, incrY, numItersDoneOnCanvas, numItersPerFrame); |
| 330 | double t1 = emscripten_get_now(); |
| 331 | numIters[idx] += ni; |
| 332 | timeSpentInMandelbrot[idx] += t1-t0; |
| 333 | tasksDone++; |
| 334 | emscripten_futex_wake(&tasksDone, 9999); |
| 335 | } |
| 336 | } |
| 337 | #endif |
| 338 | |
| 339 | float hScroll = 0; |
nothing calls this directly
no test coverage detected