/* Make sure if no one is using another buffer */
for (i = 0; i < args -> nthreads; i++)
- while (job[mypos].working[i][CACHE_LINE_SIZE * bufferside]) {YIELDING;};
+ while (job[mypos].working[i][CACHE_LINE_SIZE * bufferside]) {YIELDING;MB;};
STOP_RPCC(waiting1);
for (i = 0; i < args -> nthreads; i++)
job[mypos].working[i][CACHE_LINE_SIZE * bufferside] = (BLASLONG)buffer[bufferside];
- }
+ WMB;
+ }
current = mypos;
START_RPCC();
/* thread has to wait */
- while(job[current].working[mypos][CACHE_LINE_SIZE * bufferside] == 0) {YIELDING;};
+ while(job[current].working[mypos][CACHE_LINE_SIZE * bufferside] == 0) {YIELDING;MB;};
STOP_RPCC(waiting2);
if (m_to - m_from == min_i) {
job[current].working[mypos][CACHE_LINE_SIZE * bufferside] = 0;
+ WMB;
}
}
} while (current != mypos);
if (is + min_i >= m_to) {
/* Thread doesn't need this buffer any more */
job[current].working[mypos][CACHE_LINE_SIZE * bufferside] = 0;
+ WMB;
}
}
/* Make sure if no one is using another buffer */
for (i = 0; i < args -> nthreads; i++)
- while (job[mypos].working[i][CACHE_LINE_SIZE * bufferside]) {YIELDING;};
+ while (job[mypos].working[i][CACHE_LINE_SIZE * bufferside]) {YIELDING;MB;};
STOP_RPCC(waiting1);
START_RPCC();
/* thread has to wait */
- while(job[current].working[mypos][CACHE_LINE_SIZE * bufferside] == 0) {YIELDING;};
+ while(job[current].working[mypos][CACHE_LINE_SIZE * bufferside] == 0) {YIELDING;MB;};
STOP_RPCC(waiting2);
if (m_to - m_from == min_i) {
job[current].working[mypos][CACHE_LINE_SIZE * bufferside] = 0;
+ WMB;
}
}
} while (current != mypos);
/* Make sure if no one is using another buffer */
for (i = 0; i < args -> nthreads; i++)
- while (job[mypos].working[i][CACHE_LINE_SIZE * bufferside]) {YIELDING;};
+ while (job[mypos].working[i][CACHE_LINE_SIZE * bufferside]) {YIELDING;MB;};
STOP_RPCC(waiting1);
START_RPCC();
/* thread has to wait */
- while(job[current].working[mypos][CACHE_LINE_SIZE * bufferside] == 0) {YIELDING;};
+ while(job[current].working[mypos][CACHE_LINE_SIZE * bufferside] == 0) {YIELDING;MB;};
STOP_RPCC(waiting2);
}
if (m_to - m_from == min_i) {
- job[current].working[mypos][CACHE_LINE_SIZE * bufferside] = 0;
- }
+ job[current].working[mypos][CACHE_LINE_SIZE * bufferside] &= 0;
+ WMB;
+}
}
} while (current != mypos);
#endif
if (is + min_i >= m_to) {
/* Thread doesn't need this buffer any more */
- job[current].working[mypos][CACHE_LINE_SIZE * bufferside] = 0;
+ job[current].working[mypos][CACHE_LINE_SIZE * bufferside] &= 0;
+ WMB;
}
}
for (i = 0; i < args -> nthreads; i++) {
for (xxx = 0; xxx < DIVIDE_RATE; xxx++) {
- while (job[mypos].working[i][CACHE_LINE_SIZE * xxx] ) {YIELDING;};
+ while (job[mypos].working[i][CACHE_LINE_SIZE * xxx] ) {YIELDING;MB;};
}
}
static int gemm_driver(blas_arg_t *args, BLASLONG *range_m, BLASLONG
*range_n, FLOAT *sa, FLOAT *sb, BLASLONG mypos){
+#ifndef USE_OPENMP
+#ifndef OS_WINDOWS
+static pthread_mutex_t level3_lock = PTHREAD_MUTEX_INITIALIZER;
+#else
+CRITICAL_SECTION level3_lock;
+InitializeCriticalSection((PCRITICAL_SECTION)&level3_lock);
+#endif
+#endif
+
blas_arg_t newarg;
blas_queue_t queue[MAX_CPU_NUMBER];
mode = BLAS_SINGLE | BLAS_REAL | BLAS_NODE;
#endif
+#ifndef USE_OPENMP
+#ifndef OS_WINDOWS
+pthread_mutex_lock(&level3_lock);
+#else
+EnterCriticalSection((PCRITICAL_SECTION)&level3_lock);
+#endif
+#endif
+
newarg.m = args -> m;
newarg.n = args -> n;
newarg.k = args -> k;
free(job);
#endif
+#ifndef USE_OPENMP
+#ifndef OS_WINDOWS
+ pthread_mutex_unlock(&level3_lock);
+#else
+ LeaveCriticalSection((PCRITICAL_SECTION)&level3_lock);
+#endif
+#endif
+
return 0;
}