11/*********************************************************************/
22/* Copyright 2009, 2010 The University of Texas at Austin. */
3+ /* Copyright 2023 The OpenBLAS Project. */
34/* All rights reserved. */
45/* */
56/* Redistribution and use in source and binary forms, with or */
4445#define DIVIDE_RATE 2
4546#endif
4647
47- #ifndef SWITCH_RATIO
48- #define SWITCH_RATIO 2
49- #endif
50-
5148#ifndef GEMM_PREFERED_SIZE
5249#define GEMM_PREFERED_SIZE 1
5350#endif
@@ -577,6 +574,11 @@ InitializeCriticalSection((PCRITICAL_SECTION)&level3_lock);
577574 BLASLONG width , i , j , k , js ;
578575 BLASLONG m , n , n_from , n_to ;
579576 int mode ;
577+ #if defined(DYNAMIC_ARCH )
578+ int switch_ratio = gotoblas -> switch_ratio ;
579+ #else
580+ int switch_ratio = SWITCH_RATIO ;
581+ #endif
580582
581583 /* Get execution mode */
582584#ifndef COMPLEX
@@ -698,8 +700,8 @@ EnterCriticalSection((PCRITICAL_SECTION)&level3_lock);
698700 num_parts = 0 ;
699701 while (n > 0 ){
700702 width = blas_quickdivide (n + nthreads - num_parts - 1 , nthreads - num_parts );
701- if (width < SWITCH_RATIO ) {
702- width = SWITCH_RATIO ;
703+ if (width < switch_ratio ) {
704+ width = switch_ratio ;
703705 }
704706 width = round_up (n , width , GEMM_PREFERED_SIZE );
705707
@@ -746,6 +748,11 @@ int CNAME(blas_arg_t *args, BLASLONG *range_m, BLASLONG *range_n, IFLOAT *sa, IF
746748 BLASLONG m = args -> m ;
747749 BLASLONG n = args -> n ;
748750 BLASLONG nthreads_m , nthreads_n ;
751+ #if defined(DYNAMIC_ARCH )
752+ int switch_ratio = gotoblas -> switch_ratio ;
753+ #else
754+ int switch_ratio = SWITCH_RATIO ;
755+ #endif
749756
750757 /* Get dimensions from index ranges if available */
751758 if (range_m ) {
@@ -755,21 +762,21 @@ int CNAME(blas_arg_t *args, BLASLONG *range_m, BLASLONG *range_n, IFLOAT *sa, IF
755762 n = range_n [1 ] - range_n [0 ];
756763 }
757764
758- /* Partitions in m should have at least SWITCH_RATIO rows */
759- if (m < 2 * SWITCH_RATIO ) {
765+ /* Partitions in m should have at least switch_ratio rows */
766+ if (m < 2 * switch_ratio ) {
760767 nthreads_m = 1 ;
761768 } else {
762769 nthreads_m = args -> nthreads ;
763- while (m < nthreads_m * SWITCH_RATIO ) {
770+ while (m < nthreads_m * switch_ratio ) {
764771 nthreads_m = nthreads_m / 2 ;
765772 }
766773 }
767774
768- /* Partitions in n should have at most SWITCH_RATIO * nthreads_m columns */
769- if (n < SWITCH_RATIO * nthreads_m ) {
775+ /* Partitions in n should have at most switch_ratio * nthreads_m columns */
776+ if (n < switch_ratio * nthreads_m ) {
770777 nthreads_n = 1 ;
771778 } else {
772- nthreads_n = (n + SWITCH_RATIO * nthreads_m - 1 ) / (SWITCH_RATIO * nthreads_m );
779+ nthreads_n = (n + switch_ratio * nthreads_m - 1 ) / (switch_ratio * nthreads_m );
773780 if (nthreads_m * nthreads_n > args -> nthreads ) {
774781 nthreads_n = blas_quickdivide (args -> nthreads , nthreads_m );
775782 }
0 commit comments