Skip to content

Commit 7656aba

Browse files
authored
Merge pull request #3493 from martin-frbg/casts+cleanup
WIP casts and cleanups
2 parents aec32e5 + 7b146e5 commit 7656aba

File tree

19 files changed

+55
-38
lines changed

19 files changed

+55
-38
lines changed

cpuid_x86.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,11 @@ int get_vendor(void){
323323

324324
int get_cputype(int gettype){
325325
int eax, ebx, ecx, edx;
326+
/*
326327
int extend_family, family;
327328
int extend_model, model;
328329
int type, stepping;
330+
*/
329331
int feature = 0;
330332

331333
cpuid(1, &eax, &ebx, &ecx, &edx);
@@ -428,7 +430,8 @@ int get_cacheinfo(int type, cache_info_t *cacheinfo){
428430
cpuid(0, &cpuid_level, &ebx, &ecx, &edx);
429431

430432
if (cpuid_level > 1) {
431-
int numcalls =0 ;
433+
int numcalls;
434+
432435
cpuid(2, &eax, &ebx, &ecx, &edx);
433436
numcalls = BITMASK(eax, 0, 0xff); //FIXME some systems may require repeated calls to read all entries
434437
info[ 0] = BITMASK(eax, 8, 0xff);
@@ -1637,7 +1640,6 @@ int get_cpuname(void){
16371640
else
16381641
return CPUTYPE_BARCELONA;
16391642
}
1640-
break;
16411643
case 10: // Zen3
16421644
if(support_avx())
16431645
#ifndef NO_AVX2
@@ -2193,7 +2195,6 @@ int get_coretype(void){
21932195
else
21942196
return CORE_NEHALEM;
21952197
#endif
2196-
break;
21972198

21982199
case 7:
21992200
if (model == 10)
@@ -2582,4 +2583,4 @@ void get_sse(void){
25822583
if (features & HAVE_FMA3 ) printf("HAVE_FMA3=1\n");
25832584

25842585
}
2585-
//}
2586+
//}

driver/others/blas_server.c

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ static void legacy_exec(void *func, int mode, blas_arg_t *args, void *sb){
209209
/* REAL / Double */
210210
void (*afunc)(BLASLONG, BLASLONG, BLASLONG, double,
211211
double *, BLASLONG, double *, BLASLONG,
212-
double *, BLASLONG, void *) = func;
212+
double *, BLASLONG, void *) = (void (*)(BLASLONG, BLASLONG, BLASLONG, double, double *, BLASLONG,
213+
double *, BLASLONG, double *, BLASLONG, void *)) func;
213214

214215
afunc(args -> m, args -> n, args -> k,
215216
((double *)args -> alpha)[0],
@@ -220,7 +221,10 @@ static void legacy_exec(void *func, int mode, blas_arg_t *args, void *sb){
220221
/* REAL / Single */
221222
void (*afunc)(BLASLONG, BLASLONG, BLASLONG, float,
222223
float *, BLASLONG, float *, BLASLONG,
223-
float *, BLASLONG, void *) = func;
224+
float *, BLASLONG, void *) = (void (*)
225+
(BLASLONG, BLASLONG, BLASLONG, float,
226+
float *, BLASLONG, float *, BLASLONG,
227+
float *, BLASLONG, void *)) func;
224228

225229
afunc(args -> m, args -> n, args -> k,
226230
((float *)args -> alpha)[0],
@@ -232,7 +236,9 @@ static void legacy_exec(void *func, int mode, blas_arg_t *args, void *sb){
232236
/* REAL / BFLOAT16 */
233237
void (*afunc)(BLASLONG, BLASLONG, BLASLONG, bfloat16,
234238
bfloat16 *, BLASLONG, bfloat16 *, BLASLONG,
235-
bfloat16 *, BLASLONG, void *) = func;
239+
bfloat16 *, BLASLONG, void *) = (void (*)(BLASLONG, BLASLONG, BLASLONG, bfloat16,
240+
bfloat16 *, BLASLONG, bfloat16 *, BLASLONG,
241+
bfloat16 *, BLASLONG, void *)) func;
236242

237243
afunc(args -> m, args -> n, args -> k,
238244
((bfloat16 *)args -> alpha)[0],
@@ -243,7 +249,9 @@ static void legacy_exec(void *func, int mode, blas_arg_t *args, void *sb){
243249
/* REAL / BLAS_STOBF16 */
244250
void (*afunc)(BLASLONG, BLASLONG, BLASLONG, float,
245251
float *, BLASLONG, bfloat16 *, BLASLONG,
246-
float *, BLASLONG, void *) = func;
252+
float *, BLASLONG, void *) = (void (*)(BLASLONG, BLASLONG, BLASLONG, float,
253+
float *, BLASLONG, bfloat16 *, BLASLONG,
254+
float *, BLASLONG, void *)) func;
247255

248256
afunc(args -> m, args -> n, args -> k,
249257
((float *)args -> alpha)[0],
@@ -254,7 +262,9 @@ static void legacy_exec(void *func, int mode, blas_arg_t *args, void *sb){
254262
/* REAL / BLAS_DTOBF16 */
255263
void (*afunc)(BLASLONG, BLASLONG, BLASLONG, double,
256264
double *, BLASLONG, bfloat16 *, BLASLONG,
257-
double *, BLASLONG, void *) = func;
265+
double *, BLASLONG, void *) = (void (*)(BLASLONG, BLASLONG, BLASLONG, double,
266+
double *, BLASLONG, bfloat16 *, BLASLONG,
267+
double *, BLASLONG, void *)) func;
258268

259269
afunc(args -> m, args -> n, args -> k,
260270
((double *)args -> alpha)[0],
@@ -271,7 +281,9 @@ static void legacy_exec(void *func, int mode, blas_arg_t *args, void *sb){
271281
/* COMPLEX / Extended Double */
272282
void (*afunc)(BLASLONG, BLASLONG, BLASLONG, xdouble, xdouble,
273283
xdouble *, BLASLONG, xdouble *, BLASLONG,
274-
xdouble *, BLASLONG, void *) = func;
284+
xdouble *, BLASLONG, void *) = (void (*)(BLASLONG, BLASLONG, BLASLONG, xdouble, xdouble,
285+
xdouble *, BLASLONG, xdouble *, BLASLONG,
286+
xdouble *, BLASLONG, void *)) func;
275287

276288
afunc(args -> m, args -> n, args -> k,
277289
((xdouble *)args -> alpha)[0],
@@ -285,7 +297,9 @@ static void legacy_exec(void *func, int mode, blas_arg_t *args, void *sb){
285297
/* COMPLEX / Double */
286298
void (*afunc)(BLASLONG, BLASLONG, BLASLONG, double, double,
287299
double *, BLASLONG, double *, BLASLONG,
288-
double *, BLASLONG, void *) = func;
300+
double *, BLASLONG, void *) = (void (*)(BLASLONG, BLASLONG, BLASLONG, double, double,
301+
double *, BLASLONG, double *, BLASLONG,
302+
double *, BLASLONG, void *)) func;
289303

290304
afunc(args -> m, args -> n, args -> k,
291305
((double *)args -> alpha)[0],
@@ -297,7 +311,9 @@ static void legacy_exec(void *func, int mode, blas_arg_t *args, void *sb){
297311
/* COMPLEX / Single */
298312
void (*afunc)(BLASLONG, BLASLONG, BLASLONG, float, float,
299313
float *, BLASLONG, float *, BLASLONG,
300-
float *, BLASLONG, void *) = func;
314+
float *, BLASLONG, void *) = (void (*)(BLASLONG, BLASLONG, BLASLONG, float, float,
315+
float *, BLASLONG, float *, BLASLONG,
316+
float *, BLASLONG, void *)) func;
301317

302318
afunc(args -> m, args -> n, args -> k,
303319
((float *)args -> alpha)[0],
@@ -425,7 +441,7 @@ blas_queue_t *tscq;
425441
#endif
426442

427443
if (queue) {
428-
int (*routine)(blas_arg_t *, void *, void *, void *, void *, BLASLONG) = queue -> routine;
444+
int (*routine)(blas_arg_t *, void *, void *, void *, void *, BLASLONG) = (int (*)(blas_arg_t *, void *, void *, void *, void *, BLASLONG))queue -> routine;
429445

430446
atomic_store_queue(&thread_status[cpu].queue, (blas_queue_t *)1);
431447

@@ -503,7 +519,7 @@ blas_queue_t *tscq;
503519
legacy_exec(routine, queue -> mode, queue -> args, sb);
504520
} else
505521
if (queue -> mode & BLAS_PTHREAD) {
506-
void (*pthreadcompat)(void *) = queue -> routine;
522+
void (*pthreadcompat)(void *) = (void(*)(void*))queue -> routine;
507523
(pthreadcompat)(queue -> args);
508524
} else
509525
(routine)(queue -> args, queue -> range_m, queue -> range_n, sa, sb, queue -> position);
@@ -871,13 +887,13 @@ int exec_blas(BLASLONG num, blas_queue_t *queue){
871887
fprintf(STDERR, "\n");
872888
#endif
873889

874-
routine = queue -> routine;
890+
routine = (int (*)(blas_arg_t *, void *, void *, double *, double *, BLASLONG))queue -> routine;
875891

876892
if (queue -> mode & BLAS_LEGACY) {
877893
legacy_exec(routine, queue -> mode, queue -> args, queue -> sb);
878894
} else
879895
if (queue -> mode & BLAS_PTHREAD) {
880-
void (*pthreadcompat)(void *) = queue -> routine;
896+
void (*pthreadcompat)(void *) = (void (*)(void*))queue -> routine;
881897
(pthreadcompat)(queue -> args);
882898
} else
883899
(routine)(queue -> args, queue -> range_m, queue -> range_n,

interface/axpy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ void CNAME(blasint n, FLOAT alpha, FLOAT *x, blasint incx, FLOAT *y, blasint inc
115115
#endif
116116

117117
blas_level1_thread(mode, n, 0, 0, &alpha,
118-
x, incx, y, incy, NULL, 0, (void *)AXPYU_K, nthreads);
118+
x, incx, y, incy, NULL, 0, (int (*)(void))AXPYU_K, nthreads);
119119

120120
}
121121
#endif

interface/scal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void CNAME(blasint n, FLOAT alpha, FLOAT *x, blasint incx){
102102
#else
103103
&alpha,
104104
#endif
105-
x, incx, NULL, 0, NULL, 0, (void *)SCAL_K, nthreads);
105+
x, incx, NULL, 0, NULL, 0, (int (*)(void))SCAL_K, nthreads);
106106

107107
}
108108
#endif

interface/zaxpy.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ void CNAME(blasint n, FLOAT *ALPHA, FLOAT *x, blasint incx, FLOAT *y, blasint in
128128

129129
blas_level1_thread(mode, n, 0, 0, ALPHA, x, incx, y, incy, NULL, 0,
130130
#ifndef CONJ
131-
(void *)AXPYU_K,
131+
(int (*)(void))AXPYU_K,
132132
#else
133-
(void *)AXPYC_K,
133+
(int (*)(void))AXPYC_K,
134134
#endif
135135
nthreads);
136136
}

interface/zscal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void CNAME(blasint n, FLOAT alpha_r, void *vx, blasint incx){
108108
mode = BLAS_SINGLE | BLAS_COMPLEX;
109109
#endif
110110

111-
blas_level1_thread(mode, n, 0, 0, alpha, x, incx, NULL, 0, NULL, 0, (void *)SCAL_K, nthreads);
111+
blas_level1_thread(mode, n, 0, 0, alpha, x, incx, NULL, 0, NULL, 0, (int (*)(void))SCAL_K, nthreads);
112112

113113
}
114114
#endif

kernel/x86_64/casum.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ FLOAT CNAME(BLASLONG n, FLOAT *x, BLASLONG inc_x)
130130
mode = BLAS_DOUBLE | BLAS_COMPLEX;
131131
#endif
132132
blas_level1_thread_with_return_value(mode, n, 0, 0, dummy_alpha, x, inc_x,
133-
NULL, 0, result, 0, (void *)asum_thread_function, nthreads);
133+
NULL, 0, result, 0, (int (*)(void))asum_thread_function, nthreads);
134134
ptr = (FLOAT *)result;
135135
for (i = 0; i < nthreads; i++) {
136136
sumf += (*ptr);

kernel/x86_64/dasum.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ FLOAT CNAME(BLASLONG n, FLOAT *x, BLASLONG inc_x)
114114
#else
115115
mode = BLAS_DOUBLE | BLAS_REAL;
116116
#endif
117-
blas_level1_thread_with_return_value(mode, n, 0, 0, &dummy_alpha, x, inc_x, NULL, 0, result, 0, (void *)asum_thread_function, nthreads);
117+
blas_level1_thread_with_return_value(mode, n, 0, 0, &dummy_alpha, x, inc_x, NULL, 0, result, 0, (int (*)(void))asum_thread_function, nthreads);
118118
ptr = (FLOAT *)result;
119119
for (i = 0; i < nthreads; i++) {
120120
sumf += (*ptr);

kernel/x86_64/ddot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ FLOAT CNAME(BLASLONG n, FLOAT *x, BLASLONG inc_x, FLOAT *y, BLASLONG inc_y)
190190
#endif
191191
blas_level1_thread_with_return_value(mode, n, 0, 0, &dummy_alpha,
192192
x, inc_x, y, inc_y, result, 0,
193-
( void *)dot_thread_function, nthreads);
193+
(int (*)(void)) dot_thread_function, nthreads);
194194

195195
ptr = (RETURN_TYPE *)result;
196196
for (i = 0; i < nthreads; i++) {

kernel/x86_64/drot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ int CNAME(BLASLONG n, FLOAT *x, BLASLONG inc_x, FLOAT *y, BLASLONG inc_y, FLOAT
196196
#else
197197
int mode = BLAS_SINGLE | BLAS_REAL | BLAS_PTHREAD;
198198
#endif
199-
blas_level1_thread(mode, n, 0, 0, alpha, x, inc_x, y, inc_y, &dummy_c, 0, (void *)rot_thread_function, nthreads);
199+
blas_level1_thread(mode, n, 0, 0, alpha, x, inc_x, y, inc_y, &dummy_c, 0, (int (*)(void))rot_thread_function, nthreads);
200200
}
201201
#else
202202
rot_compute(n, x, inc_x, y, inc_y, c, s);

0 commit comments

Comments
 (0)