File: GB_jit_kernel_proto.h

package info (click to toggle)
suitesparse 1%3A7.10.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 254,920 kB
  • sloc: ansic: 1,134,743; cpp: 46,133; makefile: 4,875; fortran: 2,087; java: 1,826; sh: 996; ruby: 725; python: 495; asm: 371; sed: 166; awk: 44
file content (939 lines) | stat: -rw-r--r-- 59,005 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
//------------------------------------------------------------------------------
// GB_jit_kernel_proto.h: prototypes for all JIT kernels
//------------------------------------------------------------------------------

// SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2025, All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

//------------------------------------------------------------------------------

#ifndef GB_JIT_KERNEL_PROTO_H
#define GB_JIT_KERNEL_PROTO_H

//------------------------------------------------------------------------------
// JIT kernel prototypes
//------------------------------------------------------------------------------

#define GB_JIT_QUERY_PROTO(query_func)                                  \
bool query_func (uint64_t *hash, int v [3], const char *defn [5],       \
    void *id, void *term, size_t id_size, size_t term_size)

#define GB_JIT_KERNEL_USER_OP_PROTO(GB_jit_kernel_user_op)              \
GrB_Info GB_jit_kernel_user_op (void **user_function, char **defn)

#define GB_JIT_KERNEL_USER_TYPE_PROTO(GB_jit_kernel_user_type)          \
GrB_Info GB_jit_kernel_user_type (size_t *user_type_size, char **defn)

#define GB_JIT_KERNEL_ADD_PROTO(GB_jit_kernel_add)                      \
GrB_Info GB_jit_kernel_add                                              \
(                                                                       \
    GrB_Matrix C,                                                       \
    const GrB_Matrix M,                                                 \
    const GrB_Matrix A,                                                 \
    const GrB_Matrix B,                                                 \
    const bool Ch_is_Mh,                                                \
    const int64_t *restrict C_to_M,                                     \
    const int64_t *restrict C_to_A,                                     \
    const int64_t *restrict C_to_B,                                     \
    const GB_task_struct *restrict TaskList,                            \
    const int C_ntasks,                                                 \
    const int C_nthreads,                                               \
    const int64_t *M_ek_slicing,                                        \
    const int M_nthreads,                                               \
    const int M_ntasks,                                                 \
    const int64_t *A_ek_slicing,                                        \
    const int A_nthreads,                                               \
    const int A_ntasks,                                                 \
    const int64_t *B_ek_slicing,                                        \
    const int B_nthreads,                                               \
    const int B_ntasks,                                                 \
    const bool M_is_A,                                                  \
    const bool M_is_B,                                                  \
    const void *theta,                                                  \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_APPLY_BIND1ST_PROTO(GB_jit_kernel_apply_bind1st)  \
GrB_Info GB_jit_kernel_apply_bind1st                                    \
(                                                                       \
    GB_void *Cx_output,         /* Cx and Bx may be aliased */          \
    const GB_void *x_input,                                             \
    const GB_void *Bx_input,                                            \
    const int8_t *restrict Bb,                                          \
    const int64_t bnz,                                                  \
    const int nthreads,                                                 \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_APPLY_BIND2ND_PROTO(GB_jit_kernel_apply_bind2nd)  \
GrB_Info GB_jit_kernel_apply_bind2nd                                    \
(                                                                       \
    GB_void *Cx_output,         /* Cx and Ax may be aliased */          \
    const GB_void *Ax_input,                                            \
    const GB_void *y_input,                                             \
    const int8_t *restrict Ab,                                          \
    const int64_t anz,                                                  \
    const int nthreads,                                                 \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_APPLY_UNOP_PROTO(GB_jit_kernel_apply_unop)        \
GrB_Info GB_jit_kernel_apply_unop                                       \
(                                                                       \
    GB_void *Cx_out,            /* Cx and Ax may be aliased */          \
    const GrB_Matrix A,                                                 \
    const void *ythunk,         /* for idx unops (op->ytype scalar) */  \
    const int64_t *A_ek_slicing,                                        \
    const int A_ntasks,                                                 \
    const int A_nthreads,                                               \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_AXB_DOT2_PROTO(GB_jit_kernel_AxB_dot2)            \
GrB_Info GB_jit_kernel_AxB_dot2                                         \
(                                                                       \
    GrB_Matrix C,                                                       \
    const GrB_Matrix M,                                                 \
    const GrB_Matrix A,                                                 \
    const int64_t *restrict A_slice,                                    \
    const GrB_Matrix B,                                                 \
    const int64_t *restrict B_slice,                                    \
    const int nthreads,                                                 \
    const int naslice,                                                  \
    const int nbslice,                                                  \
    const void *theta,                                                  \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_AXB_DOT2N_PROTO(GB_jit_kernel_AxB_dot2n)          \
GrB_Info GB_jit_kernel_AxB_dot2n                                        \
(                                                                       \
    GrB_Matrix C,                                                       \
    const GrB_Matrix M,                                                 \
    const GrB_Matrix A,                                                 \
    const int64_t *restrict A_slice,                                    \
    const GrB_Matrix B,                                                 \
    const int64_t *restrict B_slice,                                    \
    const int nthreads,                                                 \
    const int naslice,                                                  \
    const int nbslice,                                                  \
    const void *theta,                                                  \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_AXB_DOT3_PROTO(GB_jit_kernel_AxB_dot3)            \
GrB_Info GB_jit_kernel_AxB_dot3                                         \
(                                                                       \
    GrB_Matrix C,                                                       \
    const GrB_Matrix M,                                                 \
    const GrB_Matrix A,                                                 \
    const GrB_Matrix B,                                                 \
    const GB_task_struct *restrict TaskList,                            \
    const int ntasks,                                                   \
    const int nthreads,                                                 \
    const void *theta,                                                  \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_AXB_DOT4_PROTO(GB_jit_kernel_AxB_dot4)            \
GrB_Info GB_jit_kernel_AxB_dot4                                         \
(                                                                       \
    GrB_Matrix C,                                                       \
    const GrB_Matrix A,                                                 \
    const GrB_Matrix B,                                                 \
    const int64_t *restrict A_slice,                                    \
    const int64_t *restrict B_slice,                                    \
    const int naslice,                                                  \
    const int nbslice,                                                  \
    const int nthreads,                                                 \
    GB_Werk Werk,                                                       \
    const void *theta,                                                  \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_AXB_SAXBIT_PROTO(GB_jit_kernel_AxB_saxbit)        \
GrB_Info GB_jit_kernel_AxB_saxbit                                       \
(                                                                       \
    GrB_Matrix C,                                                       \
    const GrB_Matrix M,                                                 \
    const GrB_Matrix A,                                                 \
    const GrB_Matrix B,                                                 \
    const int ntasks,                                                   \
    const int nthreads,                                                 \
    const int nfine_tasks_per_vector,                                   \
    const bool use_coarse_tasks,                                        \
    const bool use_atomics,                                             \
    const int64_t *M_ek_slicing,                                        \
    const int M_nthreads,                                               \
    const int M_ntasks,                                                 \
    const int64_t *restrict A_slice,                                    \
    const int64_t *restrict H_slice,                                    \
    GB_void *restrict Wcx,                                              \
    int8_t *restrict Wf,                                                \
    const int nthreads_max,                                             \
    double chunk,                                                       \
    const void *theta,                                                  \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_AXB_SAXPY3_PROTO(GB_jit_kernel_AxB_saxpy3)        \
GrB_Info GB_jit_kernel_AxB_saxpy3                                       \
(                                                                       \
    GrB_Matrix C,   /* C<any M>=A*B, C sparse or hypersparse */         \
    const GrB_Matrix M,                                                 \
    const bool M_in_place,                                              \
    const GrB_Matrix A,                                                 \
    const GrB_Matrix B,                                                 \
    GB_saxpy3task_struct *restrict SaxpyTasks,                          \
    const int ntasks,                                                   \
    const int nfine,                                                    \
    const int nthreads,                                                 \
    const int do_sort,                                                  \
    const int nthreads_max,                                             \
    double chunk,                                                       \
    GB_Werk Werk,                                                       \
    const void *theta,                                                  \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_AXB_SAXPY4_PROTO(GB_jit_kernel_AxB_saxpy4)        \
GrB_Info GB_jit_kernel_AxB_saxpy4                                       \
(                                                                       \
    GrB_Matrix C,                                                       \
    const GrB_Matrix A,                                                 \
    const GrB_Matrix B,                                                 \
    const int ntasks,                                                   \
    const int nthreads,                                                 \
    const int nfine_tasks_per_vector,                                   \
    const bool use_coarse_tasks,                                        \
    const bool use_atomics,                                             \
    const int64_t *restrict A_slice,                                    \
    const int64_t *restrict H_slice,                                    \
    GB_void *restrict Wcx,                                              \
    const void *theta,                                                  \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_AXB_SAXPY5_PROTO(GB_jit_kernel_AxB_saxpy5)        \
GrB_Info GB_jit_kernel_AxB_saxpy5                                       \
(                                                                       \
    GrB_Matrix C,                                                       \
    const GrB_Matrix A,                                                 \
    const GrB_Matrix B,                                                 \
    const int ntasks,                                                   \
    const int nthreads,                                                 \
    const int64_t *restrict B_slice,                                    \
    bool cpu_has_avx2,                                                  \
    bool cpu_has_avx512f,                                               \
    const void *theta,                                                  \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_BUILD_PROTO(GB_jit_kernel_build)                  \
GrB_Info GB_jit_kernel_build                                            \
(                                                                       \
    GB_void *restrict Tx_void,                                          \
    void *restrict Ti_void,                                             \
    const GB_void *restrict Sx_void,                                    \
    const int64_t nvals,                                                \
    const void *restrict I_work_void,                                   \
    const void *restrict K_work_void,                                   \
    const int64_t duplicate_entry_input,                                \
    const int64_t *restrict tstart_slice,                               \
    const int64_t *restrict tnz_slice,                                  \
    const int nthreads,                                                 \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_COLSCALE_PROTO(GB_jit_kernel_colscale)            \
GrB_Info GB_jit_kernel_colscale                                         \
(                                                                       \
    GrB_Matrix C,                                                       \
    const GrB_Matrix A,                                                 \
    const GrB_Matrix D,                                                 \
    const int64_t *A_ek_slicing,                                        \
    const int A_ntasks,                                                 \
    const int A_nthreads,                                               \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_CONCAT_BITMAP_PROTO(GB_jit_kernel_concat_bitmap)  \
GrB_Info GB_jit_kernel_concat_bitmap                                    \
(                                                                       \
    GrB_Matrix C,                                                       \
    const int64_t cistart,                                              \
    const int64_t cvstart,                                              \
    const GrB_Matrix A,                                                 \
    const int nthreads_max,                                             \
    double chunk,                                                       \
    GB_Werk Werk,                                                       \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_CONCAT_FULL_PROTO(GB_jit_kernel_concat_full)      \
GrB_Info GB_jit_kernel_concat_full                                      \
(                                                                       \
    GrB_Matrix C,                                                       \
    const int64_t cistart,                                              \
    const int64_t cvstart,                                              \
    const GrB_Matrix A,                                                 \
    const int A_nthreads,                                               \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_CONCAT_SPARSE_PROTO(GB_jit_kernel_concat_sparse)  \
GrB_Info GB_jit_kernel_concat_sparse                                    \
(                                                                       \
    GrB_Matrix C,                                                       \
    const int64_t cistart,                                              \
    const GrB_Matrix A,                                                 \
    const void *W_parameter,                                            \
    const int64_t *A_ek_slicing,                                        \
    const int A_ntasks,                                                 \
    const int A_nthreads,                                               \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_CONVERT_S2B_PROTO(GB_jit_kernel_convert_s2b)      \
GrB_Info GB_jit_kernel_convert_s2b                                      \
(                                                                       \
    GB_void *restrict Cx_new,                                           \
    int8_t *restrict Cb,                                                \
    const GrB_Matrix A,                                                 \
    const int64_t *A_ek_slicing,                                        \
    const int A_ntasks,                                                 \
    const int A_nthreads,                                               \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_EMULT_02_PROTO(GB_jit_kernel_emult_02)            \
GrB_Info GB_jit_kernel_emult_02                                         \
(                                                                       \
    GrB_Matrix C,                                                       \
    const GrB_Matrix M,                                                 \
    const bool Mask_struct,                                             \
    const bool Mask_comp,                                               \
    const GrB_Matrix A,                                                 \
    const GrB_Matrix B,                                                 \
    const uint64_t *restrict Cp_kfirst,                                 \
    const int64_t *A_ek_slicing,                                        \
    const int A_ntasks,                                                 \
    const int A_nthreads,                                               \
    const void *theta,                                                  \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_EMULT_03_PROTO(GB_jit_kernel_emult_03)            \
GrB_Info GB_jit_kernel_emult_03                                         \
(                                                                       \
    GrB_Matrix C,                                                       \
    const GrB_Matrix M,                                                 \
    const bool Mask_struct,                                             \
    const bool Mask_comp,                                               \
    const GrB_Matrix A,                                                 \
    const GrB_Matrix B,                                                 \
    const uint64_t *restrict Cp_kfirst,                                 \
    const int64_t *B_ek_slicing,                                        \
    const int B_ntasks,                                                 \
    const int B_nthreads,                                               \
    const void *theta,                                                  \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_EMULT_04_PROTO(GB_jit_kernel_emult_04)            \
GrB_Info GB_jit_kernel_emult_04                                         \
(                                                                       \
    GrB_Matrix C,                                                       \
    const GrB_Matrix M,                                                 \
    const bool Mask_struct,                                             \
    const GrB_Matrix A,                                                 \
    const GrB_Matrix B,                                                 \
    const uint64_t *restrict Cp_kfirst,                                 \
    const int64_t *M_ek_slicing,                                        \
    const int M_ntasks,                                                 \
    const int M_nthreads,                                               \
    const void *theta,                                                  \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_EMULT_08_PROTO(GB_jit_kernel_emult_08)            \
GrB_Info GB_jit_kernel_emult_08                                         \
(                                                                       \
    GrB_Matrix C,                                                       \
    const GrB_Matrix M,                                                 \
    const bool Mask_struct,                                             \
    const bool Mask_comp,                                               \
    const GrB_Matrix A,                                                 \
    const GrB_Matrix B,                                                 \
    const int64_t *restrict C_to_M,                                     \
    const int64_t *restrict C_to_A,                                     \
    const int64_t *restrict C_to_B,                                     \
    const GB_task_struct *restrict TaskList,                            \
    const int C_ntasks,                                                 \
    const int C_nthreads,                                               \
    const void *theta,                                                  \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_EMULT_BITMAP_PROTO(GB_jit_kernel_emult_bitmap)    \
GrB_Info GB_jit_kernel_emult_bitmap                                     \
(                                                                       \
    GrB_Matrix C,                                                       \
    const GrB_Matrix M,                                                 \
    const bool Mask_struct,                                             \
    const bool Mask_comp,                                               \
    const GrB_Matrix A,                                                 \
    const GrB_Matrix B,                                                 \
    const int64_t *M_ek_slicing,                                        \
    const int M_ntasks,                                                 \
    const int M_nthreads,                                               \
    const int C_nthreads,                                               \
    const void *theta,                                                  \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_EWISE_FULLA_PROTO(GB_jit_kernel_ewise_fulla)      \
GrB_Info GB_jit_kernel_ewise_fulla                                      \
(                                                                       \
    GrB_Matrix C,                                                       \
    const GrB_Matrix A,                                                 \
    const GrB_Matrix B,                                                 \
    const int nthreads,                                                 \
    const bool A_is_B,                                                  \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_EWISE_FULLN_PROTO(GB_jit_kernel_ewise_fulln)      \
GrB_Info GB_jit_kernel_ewise_fulln                                      \
(                                                                       \
    GrB_Matrix C,                                                       \
    const GrB_Matrix A,                                                 \
    const GrB_Matrix B,                                                 \
    const int nthreads,                                                 \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_REDUCE_PROTO(GB_jit_kernel_reduce)                \
GrB_Info GB_jit_kernel_reduce                                           \
(                                                                       \
    GB_void *result,                                                    \
    const GrB_Matrix A,                                                 \
    GB_void *restrict Workspace,                                        \
    bool *restrict F,                                                   \
    const int ntasks,                                                   \
    const int nthreads,                                                 \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_ROWSCALE_PROTO(GB_jit_kernel_rowscale)            \
GrB_Info GB_jit_kernel_rowscale                                         \
(                                                                       \
    GrB_Matrix C,                                                       \
    const GrB_Matrix D,                                                 \
    const GrB_Matrix B,                                                 \
    const int nthreads,                                                 \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_SELECT_BITMAP_PROTO(GB_jit_kernel_select_bitmap)  \
GrB_Info GB_jit_kernel_select_bitmap                                    \
(                                                                       \
    GrB_Matrix C,                                                       \
    GrB_Matrix A,                                                       \
    const GB_void *restrict ythunk,                                     \
    const int nthreads,                                                 \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_SELECT_PHASE1_PROTO(GB_jit_kernel_select_phase1)  \
GrB_Info GB_jit_kernel_select_phase1                                    \
(                                                                       \
    GrB_Matrix C,                                                       \
    uint64_t *restrict Wfirst,                                          \
    uint64_t *restrict Wlast,                                           \
    const GrB_Matrix A,                                                 \
    const GB_void *restrict ythunk,                                     \
    const int64_t *A_ek_slicing,                                        \
    const int A_ntasks,                                                 \
    const int A_nthreads,                                               \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_SELECT_PHASE2_PROTO(GB_jit_kernel_select_phase2)  \
GrB_Info GB_jit_kernel_select_phase2                                    \
(                                                                       \
    GrB_Matrix C,                                                       \
    const uint64_t *restrict Cp_kfirst,                                 \
    const GrB_Matrix A,                                                 \
    const GB_void *restrict ythunk,                                     \
    const int64_t *A_ek_slicing,                                        \
    const int A_ntasks,                                                 \
    const int A_nthreads,                                               \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_SPLIT_BITMAP_PROTO(GB_jit_kernel_split_bitmap)    \
GrB_Info GB_jit_kernel_split_bitmap                                     \
(                                                                       \
    GrB_Matrix C,                                                       \
    GrB_Matrix A,                                                       \
    const int64_t avstart,                                              \
    const int64_t aistart,                                              \
    const int C_nthreads,                                               \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_SPLIT_FULL_PROTO(GB_jit_kernel_split_full)        \
GrB_Info GB_jit_kernel_split_full                                       \
(                                                                       \
    GrB_Matrix C,                                                       \
    GrB_Matrix A,                                                       \
    const int64_t avstart,                                              \
    const int64_t aistart,                                              \
    const int C_nthreads,                                               \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_SPLIT_SPARSE_PROTO(GB_jit_kernel_split_sparse)    \
GrB_Info GB_jit_kernel_split_sparse                                     \
(                                                                       \
    GrB_Matrix C,                                                       \
    GrB_Matrix A,                                                       \
    const int64_t akstart,                                              \
    const int64_t aistart,                                              \
    const void *Wp_workspace,                                           \
    const int64_t *C_ek_slicing,                                        \
    const int C_ntasks,                                                 \
    const int C_nthreads,                                               \
    const GB_callback_struct *restrict my_callback                      \
)

// used for all subassign kernels:
#define GB_JIT_KERNEL_SUBASSIGN_PROTO(GB_jit_kernel_subassign_any)      \
GrB_Info GB_jit_kernel_subassign_any                                    \
(                                                                       \
    GrB_Matrix C,                                                       \
    const bool C_replace,                                               \
    const void *I_input,                                                \
    const int64_t ni,                                                   \
    const int64_t nI,                                                   \
    const int Ikind,                                                    \
    const int64_t Icolon [3],                                           \
    const void *J_input,                                                \
    const int64_t nj,                                                   \
    const int64_t nJ,                                                   \
    const int Jkind,                                                    \
    const int64_t Jcolon [3],                                           \
    const GrB_Matrix M,                                                 \
    const bool Mask_comp,                                               \
    const bool Mask_struct,                                             \
    const GrB_BinaryOp accum,                                           \
    const GrB_Matrix A,                                                 \
    const void *scalar,                                                 \
    const GrB_Type scalar_type,                                         \
    const GrB_Matrix S,                                                 \
    const int assign_kind,                                              \
    GB_Werk Werk,                                                       \
    const int nthreads_max,                                             \
    double chunk,                                                       \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_TRANS_BIND1ST_PROTO(GB_jit_kernel_trans_bind1st)  \
GrB_Info GB_jit_kernel_trans_bind1st                                    \
(                                                                       \
    GrB_Matrix C,                                                       \
    const GB_void *x_input,                                             \
    const GrB_Matrix A,                                                 \
    void **Workspaces,                                                  \
    const int64_t *restrict A_slice,                                    \
    const int nworkspaces,                                              \
    const int nthreads,                                                 \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_TRANS_BIND2ND_PROTO(GB_jit_kernel_trans_bind2nd)  \
GrB_Info GB_jit_kernel_trans_bind2nd                                    \
(                                                                       \
    GrB_Matrix C,                                                       \
    const GrB_Matrix A,                                                 \
    const GB_void *y_input,                                             \
    void **Workspaces,                                                  \
    const int64_t *restrict A_slice,                                    \
    const int nworkspaces,                                              \
    const int nthreads,                                                 \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_TRANS_UNOP_PROTO(GB_jit_kernel_trans_unop)        \
GrB_Info GB_jit_kernel_trans_unop                                       \
(                                                                       \
    GrB_Matrix C,                                                       \
    const GrB_Matrix A,                                                 \
    void **Workspaces,                                                  \
    const int64_t *restrict A_slice,                                    \
    const int nworkspaces,                                              \
    const int nthreads,                                                 \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_UNION_PROTO(GB_jit_kernel_union)                  \
GrB_Info GB_jit_kernel_union                                            \
(                                                                       \
    GrB_Matrix C,                                                       \
    const GrB_Matrix M,                                                 \
    const GrB_Matrix A,                                                 \
    const GrB_Matrix B,                                                 \
    const GB_void *alpha_scalar_in,                                     \
    const GB_void *beta_scalar_in,                                      \
    const bool Ch_is_Mh,                                                \
    const int64_t *restrict C_to_M,                                     \
    const int64_t *restrict C_to_A,                                     \
    const int64_t *restrict C_to_B,                                     \
    const GB_task_struct *restrict TaskList,                            \
    const int C_ntasks,                                                 \
    const int C_nthreads,                                               \
    const int64_t *M_ek_slicing,                                        \
    const int M_nthreads,                                               \
    const int M_ntasks,                                                 \
    const int64_t *A_ek_slicing,                                        \
    const int A_nthreads,                                               \
    const int A_ntasks,                                                 \
    const int64_t *B_ek_slicing,                                        \
    const int B_nthreads,                                               \
    const int B_ntasks,                                                 \
    const bool M_is_A,                                                  \
    const bool M_is_B,                                                  \
    const void *theta,                                                  \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_MASKER_PHASE1_PROTO(GB_jit_kernel_masker1)        \
GrB_Info GB_jit_kernel_masker1                                          \
(                                                                       \
    void *Rp_parameter,                                                 \
    int64_t *Rnvec_nonempty,                                            \
    GB_task_struct *restrict TaskList,                                  \
    const int R_ntasks,                                                 \
    const int R_nthreads,                                               \
    const int64_t Rnvec,                                                \
    const void *Rh_parameter,                                           \
    const int64_t *restrict R_to_M,                                     \
    const int64_t *restrict R_to_C,                                     \
    const int64_t *restrict R_to_Z,                                     \
    const GrB_Matrix M,                                                 \
    const bool Mask_comp,                                               \
    const bool Mask_struct,                                             \
    const GrB_Matrix C,                                                 \
    const GrB_Matrix Z,                                                 \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_MASKER_PHASE2_PROTO(GB_jit_kernel_masker2)        \
GrB_Info GB_jit_kernel_masker2                                          \
(                                                                       \
    GrB_Matrix R,                                                       \
    const GB_task_struct *restrict TaskList,                            \
    const int R_ntasks,                                                 \
    const int R_nthreads,                                               \
    const int64_t *restrict R_to_M,                                     \
    const int64_t *restrict R_to_C,                                     \
    const int64_t *restrict R_to_Z,                                     \
    const GrB_Matrix M,                                                 \
    const bool Mask_comp,                                               \
    const bool Mask_struct,                                             \
    const GrB_Matrix C,                                                 \
    const GrB_Matrix Z,                                                 \
    const int64_t *restrict C_ek_slicing,                               \
    const int C_nthreads,                                               \
    const int C_ntasks,                                                 \
    const int64_t *restrict M_ek_slicing,                               \
    const int M_nthreads,                                               \
    const int M_ntasks,                                                 \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_SUBREF_SPARSE_PROTO(GB_jit_kernel_subref_sparse)  \
GrB_Info GB_jit_kernel_subref_sparse                                    \
(                                                                       \
    GrB_Matrix C,                                                       \
    const GB_task_struct *restrict TaskList,                            \
    const int ntasks,                                                   \
    const int nthreads,                                                 \
    const bool post_sort,                                               \
    const void *Ihead_input,                                            \
    const void *Inext_input,                                            \
    const void *Ap_start_input,                                         \
    const void *Ap_end_input,                                           \
    const int64_t nI,                                                   \
    const int64_t Icolon [3],                                           \
    const GrB_Matrix A,                                                 \
    const void *I_input,                                                \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_BITMAP_SUBREF_PROTO(GB_jit_kernel_bitmap_subref)  \
GrB_Info GB_jit_kernel_bitmap_subref                                    \
(                                                                       \
    GrB_Matrix C,                                                       \
    GrB_Matrix A,                                                       \
    const void *I_input,                                                \
    const int64_t nI,                                                   \
    const int64_t Icolon [3],                                           \
    const void *J_input,                                                \
    const int64_t nJ,                                                   \
    const int64_t Jcolon [3],                                           \
    GB_Werk Werk,                                                       \
    const int nthreads_max,                                             \
    double chunk,                                                       \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_ISO_EXPAND_PROTO(GB_jit_kernel_iso_expand)        \
GrB_Info GB_jit_kernel_iso_expand                                       \
(                                                                       \
    void *restrict X,                                                   \
    const int64_t n,                                                    \
    const void *restrict scalar,                                        \
    const int nthreads,                                                 \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_UNJUMBLE_PROTO(GB_jit_kernel_unjumble)            \
GrB_Info GB_jit_kernel_unjumble                                         \
(                                                                       \
    const GrB_Matrix A,                                                 \
    const int64_t *A_slice,                                             \
    const int ntasks,                                                   \
    const int nthreads,                                                 \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_CONVERT_B2S_PROTO(GB_jit_kernel_convert_b2s)      \
GrB_Info GB_jit_kernel_convert_b2s                                      \
(                                                                       \
    const void *Cp_input,                                               \
    void *Ci_input,                                                     \
    void *Cj_input,                                                     \
    void *Cx_new,                                                       \
    const GrB_Matrix A,                                                 \
    const void *W_input,                                                \
    const int nthreads,                                                 \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_KRONER_PROTO(GB_jit_kernel_kroner)                \
GrB_Info GB_jit_kernel_kroner                                           \
(                                                                       \
    GrB_Matrix C,                                                       \
    const GrB_Matrix A,                                                 \
    const GrB_Matrix B,                                                 \
    const int nthreads,                                                 \
    const void *theta,                                                  \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_KERNEL_SORT_PROTO(GB_jit_kernel_sort)                    \
GrB_Info GB_jit_kernel_sort                                             \
(                                                                       \
    GrB_Matrix C,                                                       \
    int nthreads,                                                       \
    GB_Werk Werk,                                                       \
    const GB_callback_struct *restrict my_callback                      \
)

//------------------------------------------------------------------------------
// CUDA JIT prototypes
//------------------------------------------------------------------------------

#define GB_JIT_CUDA_KERNEL_REDUCE_PROTO(GB_jit_kernel_reduce)           \
GrB_Info GB_jit_kernel_reduce                                           \
(                                                                       \
    GB_void *zscalar,                                                   \
    GrB_Matrix V,                                                       \
    const GrB_Matrix A,                                                 \
    cudaStream_t stream,                                                \
    int32_t gridsz,                                                     \
    int32_t blocksz,                                                    \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_CUDA_KERNEL_ROWSCALE_PROTO(GB_jit_kernel_rowscale)       \
GrB_Info GB_jit_kernel_rowscale                                         \
(                                                                       \
    GrB_Matrix C,                                                       \
    GrB_Matrix D,                                                       \
    GrB_Matrix B,                                                       \
    cudaStream_t stream,                                                \
    int32_t gridsz,                                                     \
    int32_t blocksz,                                                    \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_CUDA_KERNEL_COLSCALE_PROTO(GB_jit_kernel_colscale)       \
GrB_Info GB_jit_kernel_colscale                                         \
(                                                                       \
    GrB_Matrix C,                                                       \
    GrB_Matrix A,                                                       \
    GrB_Matrix D,                                                       \
    cudaStream_t stream,                                                \
    int32_t gridsz,                                                     \
    int32_t blocksz,                                                    \
    const GB_callback_struct *restrict my_callback                      \
)

#define GB_JIT_CUDA_KERNEL_APPLY_BIND1ST_PROTO(GB_jit_kernel_apply_bind1st) \
GrB_Info GB_jit_kernel_apply_bind1st                                        \
(                                                                           \
    GB_void *Cx,                                                            \
    const GB_void *scalarx,                                                 \
    GrB_Matrix B,                                                           \
    cudaStream_t stream,                                                    \
    int32_t gridsz,                                                         \
    int32_t blocksz,                                                        \
    const GB_callback_struct *restrict my_callback                          \
)                                                                           \

#define GB_JIT_CUDA_KERNEL_APPLY_BIND2ND_PROTO(GB_jit_kernel_apply_bind2nd) \
GrB_Info GB_jit_kernel_apply_bind2nd                                        \
(                                                                           \
    GB_void *Cx,                                                            \
    GrB_Matrix A,                                                           \
    const GB_void *scalarx,                                                 \
    cudaStream_t stream,                                                    \
    int32_t gridsz,                                                         \
    int32_t blocksz,                                                        \
    const GB_callback_struct *restrict my_callback                          \
)                                                                           \

#define GB_JIT_CUDA_KERNEL_APPLY_UNOP_PROTO(GB_jit_kernel_apply_unop)       \
GrB_Info GB_jit_kernel_apply_unop                                           \
(                                                                           \
    GB_void *Cx,                                                            \
    GrB_Matrix A,                                                           \
    const GB_void *ythunk,                                                  \
    cudaStream_t stream,                                                    \
    int32_t gridsz,                                                         \
    int32_t blocksz,                                                        \
    const GB_callback_struct *restrict my_callback                          \
)                                                                           \

#define GB_JIT_CUDA_KERNEL_SELECT_BITMAP_PROTO(GB_jit_kernel_select_bitmap) \
GrB_Info GB_jit_kernel_select_bitmap                                        \
(                                                                           \
    GrB_Matrix C,                                                           \
    GrB_Matrix A,                                                           \
    const GB_void *ythunk,                                                  \
    cudaStream_t stream,                                                    \
    int32_t gridsz,                                                         \
    int32_t blocksz,                                                        \
    const GB_callback_struct *restrict my_callback                          \
)                                                                           \

#define GB_JIT_CUDA_KERNEL_SELECT_SPARSE_PROTO(GB_jit_kernel_select_sparse) \
GrB_Info GB_jit_kernel_select_sparse                                        \
(                                                                           \
    GrB_Matrix C,                                                           \
    GrB_Matrix A,                                                           \
    const GB_void *ythunk,                                                  \
    cudaStream_t stream,                                                    \
    int32_t gridsz,                                                         \
    int32_t blocksz,                                                        \
    const GB_callback_struct *restrict my_callback                          \
)

#define GB_JIT_CUDA_KERNEL_DOT3_PROTO(GB_jit_kernel_AxB_dot3)           \
GrB_Info GB_jit_kernel_AxB_dot3                                         \
(                                                                       \
    GrB_Matrix C,                                                       \
    const GrB_Matrix M,                                                 \
    const GrB_Matrix A,                                                 \
    const GrB_Matrix B,                                                 \
    cudaStream_t stream,                                                \
    int device,                                                         \
    int number_of_sms,                                                  \
    const void *theta,                                                  \
    const GB_callback_struct *restrict my_callback                      \
)

//------------------------------------------------------------------------------
// shorthand macros for GB_prejit.c:
//------------------------------------------------------------------------------

#define JIT_DOT2(g) GB_JIT_KERNEL_AXB_DOT2_PROTO(g) ;
#define JIT_DO2N(g) GB_JIT_KERNEL_AXB_DOT2N_PROTO(g) ;
#define JIT_DOT3(g) GB_JIT_KERNEL_AXB_DOT3_PROTO(g) ;
#define JIT_DOT4(g) GB_JIT_KERNEL_AXB_DOT4_PROTO(g) ;
#define JIT_SAXB(g) GB_JIT_KERNEL_AXB_SAXBIT_PROTO(g) ;
#define JIT_SAX3(g) GB_JIT_KERNEL_AXB_SAXPY3_PROTO(g) ;
#define JIT_SAX4(g) GB_JIT_KERNEL_AXB_SAXPY4_PROTO(g) ;
#define JIT_SAX5(g) GB_JIT_KERNEL_AXB_SAXPY5_PROTO(g) ;
#define JIT_ADD(g)  GB_JIT_KERNEL_ADD_PROTO(g) ;
#define JIT_AP1(g)  GB_JIT_KERNEL_APPLY_BIND1ST_PROTO(g) ;
#define JIT_AP2(g)  GB_JIT_KERNEL_APPLY_BIND2ND_PROTO(g) ;
#define JIT_AP0(g)  GB_JIT_KERNEL_APPLY_UNOP_PROTO(g) ;
#define JIT_BLD(g)  GB_JIT_KERNEL_BUILD_PROTO(g) ;
#define JIT_COLS(g) GB_JIT_KERNEL_COLSCALE_PROTO(g) ;
#define JIT_CONB(g) GB_JIT_KERNEL_CONCAT_BITMAP_PROTO(g) ;
#define JIT_CONF(g) GB_JIT_KERNEL_CONCAT_FULL_PROTO(g) ;
#define JIT_CONS(g) GB_JIT_KERNEL_CONCAT_SPARSE_PROTO(g) ;
#define JIT_CS2B(g) GB_JIT_KERNEL_CONVERT_S2B_PROTO(g) ;
#define JIT_CB2S(g) GB_JIT_KERNEL_CONVERT_B2S_PROTO(g) ;
#define JIT_EM2(g)  GB_JIT_KERNEL_EMULT_02_PROTO(g) ;
#define JIT_EM3(g)  GB_JIT_KERNEL_EMULT_03_PROTO(g) ;
#define JIT_EM4(g)  GB_JIT_KERNEL_EMULT_04_PROTO(g) ;
#define JIT_EM8(g)  GB_JIT_KERNEL_EMULT_08_PROTO(g) ;
#define JIT_EMB(g)  GB_JIT_KERNEL_EMULT_BITMAP_PROTO(g) ;
#define JIT_EWFA(g) GB_JIT_KERNEL_EWISE_FULLA_PROTO(g) ;
#define JIT_EWFN(g) GB_JIT_KERNEL_EWISE_FULLN_PROTO(g) ;
#define JIT_RED(g)  GB_JIT_KERNEL_REDUCE_PROTO(g) ;
#define JIT_ROWS(g) GB_JIT_KERNEL_ROWSCALE_PROTO(g) ;
#define JIT_SELB(g) GB_JIT_KERNEL_SELECT_BITMAP_PROTO(g) ;
#define JIT_SEL1(g) GB_JIT_KERNEL_SELECT_PHASE1_PROTO(g) ;
#define JIT_SEL2(g) GB_JIT_KERNEL_SELECT_PHASE2_PROTO(g) ;
#define JIT_SPB(g)  GB_JIT_KERNEL_SPLIT_BITMAP_PROTO(g) ;
#define JIT_SPF(g)  GB_JIT_KERNEL_SPLIT_FULL_PROTO(g) ;
#define JIT_SPS(g)  GB_JIT_KERNEL_SPLIT_SPARSE_PROTO(g) ;
#define JIT_SUB(g)  GB_JIT_KERNEL_SUBASSIGN_PROTO(g) ;
#define JIT_TR1(g)  GB_JIT_KERNEL_TRANS_BIND1ST_PROTO(g) ;
#define JIT_TR2(g)  GB_JIT_KERNEL_TRANS_BIND2ND_PROTO(g) ;
#define JIT_TR0(g)  GB_JIT_KERNEL_TRANS_UNOP_PROTO(g) ;
#define JIT_UNI(g)  GB_JIT_KERNEL_UNION_PROTO(g) ;
#define JIT_UOP(g)  GB_JIT_KERNEL_USER_OP_PROTO(g) ;
#define JIT_UTYP(g) GB_JIT_KERNEL_USER_TYPE_PROTO(g) ;
#define JIT_MAS1(g) GB_JIT_KERNEL_MASKER_PHASE1_PROTO(g) ;
#define JIT_MAS2(g) GB_JIT_KERNEL_MASKER_PHASE2_PROTO(g) ;
#define JIT_SREF(g) GB_JIT_KERNEL_SUBREF_SPARSE_PROTO(g) ;
#define JIT_BREF(g) GB_JIT_KERNEL_BITMAP_SUBREF_PROTO(g) ;
#define JIT_ISOE(g) GB_JIT_KERNEL_ISO_EXPAND_PROTO(g) ;
#define JIT_UNJU(g) GB_JIT_KERNEL_UNJUMBLE_PROTO(g) ;
#define JIT_SORT(g) GB_JIT_KERNEL_SORT_PROTO(g) ;
#define JIT_KRON(g) GB_JIT_KERNEL_KRONER_PROTO(g) ;
#define JIT_Q(q)    GB_JIT_QUERY_PROTO(q) ;

//------------------------------------------------------------------------------
// shorthand macros for GB_cuda_prejit.c:
//------------------------------------------------------------------------------

#define JIT_CUDA_RED(g)  GB_JIT_CUDA_KERNEL_REDUCE_PROTO(g) ;
#define JIT_CUDA_DOT3(g) GB_JIT_CUDA_KERNEL_DOT3_PROTO(g) ;

//------------------------------------------------------------------------------
// GB_GET_CALLBACK: get function pointer from the callback struct for JIT kernel
//------------------------------------------------------------------------------

#undef GB_GET_CALLBACK
#ifdef GB_JIT_RUNTIME
    // JIT kernels (CPU and CUDA) require the function pointers
    #define GB_GET_CALLBACKS                    \
        GB_abort = my_callback->GB_abort_func
    #define GB_GET_CALLBACK(function) \
        function ## _f function = my_callback->function ## _func
#else
    // PreJIT kernels link against -lgraphblas and do not need function pointers
    #define GB_GET_CALLBACKS
    #define GB_GET_CALLBACK(function)
#endif

#endif