Skip to content

Commit

Permalink
loongarch64: Move the get_cpu_model outside the loop to avoid multipl…
Browse files Browse the repository at this point in the history
…e reads
  • Loading branch information
XiWeiGu committed Apr 24, 2024
1 parent d421dec commit 54da8c9
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions driver/others/blas_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,16 @@ blas_queue_t *tscq;
fprintf(STDERR, "Server[%2ld] Thread has just been spawned!\n", cpu);
#endif

//For Loongson servers, like the 3C5000 (featuring 16 cores), applying an
//offset to the buffer is essential for minimizing cache conflicts and optimizing performance.
#if defined(LOONGSON3R5) && !defined(NO_AFFINITY)
char model_name[128];
int offset_flag = 0;
get_cpu_model(model_name);
if ((strstr(model_name, "3C5000") != NULL) || (strstr(model_name, "3D5000") != NULL))
offset_flag = 1;
#endif

while (1){

#ifdef MONITOR
Expand Down Expand Up @@ -1077,10 +1087,9 @@ fprintf(STDERR, "Server[%2ld] Calculation started. Mode = 0x%03x M = %3ld N=%3l
//For Loongson servers, like the 3C5000 (featuring 16 cores), applying an
//offset to the buffer is essential for minimizing cache conflicts and optimizing performance.
#if defined(LOONGSON3R5) && !defined(NO_AFFINITY)
char model_name[128];
get_cpu_model(model_name);
if ((strstr(model_name, "3C5000") != NULL) || (strstr(model_name, "3D5000") != NULL))
if (sa == NULL) sa = (void *)((BLASLONG)buffer + (WhereAmI() & 0xf) * GEMM_OFFSET_A);
if ((sa == NULL) && offset_flag) {
sa = (void *)((BLASLONG)buffer + (WhereAmI() & 0xf) * GEMM_OFFSET_A);
}
#endif
if (sa == NULL) sa = (void *)((BLASLONG)buffer + GEMM_OFFSET_A);

Expand Down

0 comments on commit 54da8c9

Please sign in to comment.