static void _init_thread_memory(void *buffer) { blas_queue_t queue[MAX_CPU_NUMBER]; int num_cpu; for (num_cpu = 0; num_cpu < blas_num_threads; num_cpu++) { blas_queue_init(&queue[num_cpu]); queue[num_cpu].mode = BLAS_DOUBLE | BLAS_REAL; queue[num_cpu].routine = &_touch_memory; queue[num_cpu].args = NULL; queue[num_cpu].next = &queue[num_cpu + 1]; } queue[num_cpu - 1].next = NULL; queue[0].sa = buffer; exec_blas(num_cpu, queue); }
int blas_level1_thread(int mode, BLASLONG m, BLASLONG n, BLASLONG k, void *alpha, void *a, BLASLONG lda, void *b, BLASLONG ldb, void *c, BLASLONG ldc, int (*function)(), int nthreads){ blas_queue_t queue[MAX_CPU_NUMBER]; blas_arg_t args [MAX_CPU_NUMBER]; BLASLONG i, width, astride, bstride; int num_cpu, calc_type; calc_type = (mode & BLAS_PREC) + ((mode & BLAS_COMPLEX) != 0) + 2; mode |= BLAS_LEGACY; for (i = 0; i < nthreads; i++) blas_queue_init(&queue[i]); num_cpu = 0; i = m; while (i > 0){ /* Adjust Parameters */ width = blas_quickdivide(i + nthreads - num_cpu - 1, nthreads - num_cpu); i -= width; if (i < 0) width = width + i; astride = width * lda; if (!(mode & BLAS_TRANSB_T)) { bstride = width * ldb; } else { bstride = width; } astride <<= calc_type; bstride <<= calc_type; args[num_cpu].m = width; args[num_cpu].n = n; args[num_cpu].k = k; args[num_cpu].a = (void *)a; args[num_cpu].b = (void *)b; args[num_cpu].c = (void *)c; args[num_cpu].lda = lda; args[num_cpu].ldb = ldb; args[num_cpu].ldc = ldc; args[num_cpu].alpha = alpha; queue[num_cpu].mode = mode; queue[num_cpu].routine = function; queue[num_cpu].args = &args[num_cpu]; queue[num_cpu].next = &queue[num_cpu + 1]; a = (void *)((BLASULONG)a + astride); b = (void *)((BLASULONG)b + bstride); num_cpu ++; } if (num_cpu) { queue[num_cpu - 1].next = NULL; exec_blas(num_cpu, queue); } return 0; }