forked from bytedance/monolith
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcuCollections.patch
1870 lines (1813 loc) · 81.5 KB
/
cuCollections.patch
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
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff --git a/.gitignore b/.gitignore
index 4146530..8edb720 100644
--- a/.gitignore
+++ b/.gitignore
@@ -81,9 +81,6 @@ cpp/thirdparty/googletest/
/html
/latex
-#Java
-target
-
# Translations
*.mo
*.pot
diff --git a/include/cuco/detail/__config b/include/cuco/detail/__config
index c76a1bb..248dff1 100644
--- a/include/cuco/detail/__config
+++ b/include/cuco/detail/__config
@@ -16,7 +16,7 @@
#pragma once
- #include <nv/target>
+ #include <cuco/detail/nv/target>
// WAR for libcudacxx/296
#define CUCO_CUDA_MINIMUM_ARCH _NV_FIRST_ARG(__CUDA_ARCH_LIST__)
diff --git a/include/cuco/detail/nv/detail/__preprocessor b/include/cuco/detail/nv/detail/__preprocessor
new file mode 100644
index 0000000..3485565
--- /dev/null
+++ b/include/cuco/detail/nv/detail/__preprocessor
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of libcu++, the C++ Standard Library for your entire system,
+// under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#if defined(__GNUC__)
+#pragma GCC system_header
+#endif
+
+// For all compilers and dialects this header defines:
+// _NV_EVAL
+// _NV_IF
+// _NV_CONCAT_EVAL
+// For C++11 and up it defines:
+// _NV_STRIP_PAREN
+// _NV_DISPATCH_N_ARY
+// _NV_FIRST_ARG
+// _NV_REMOVE_PAREN
+
+#if defined(_NV_TARGET_CPP11)
+# define _NV_EVAL1(...) __VA_ARGS__
+# define _NV_EVAL(...) _NV_EVAL1(__VA_ARGS__)
+#else
+# define _NV_EVAL1(x) x
+# define _NV_EVAL(x) _NV_EVAL1(x)
+#endif // C++11
+
+#define _NV_CONCAT_EVAL1(l, r) _NV_EVAL(l ## r)
+#define _NV_CONCAT_EVAL(l, r) _NV_CONCAT_EVAL1(l, r)
+
+#define _NV_IF_0(t, f) f
+#define _NV_IF_1(t, f) t
+
+#define _NV_IF_BIT(b) _NV_EVAL(_NV_IF_##b)
+#define _NV_IF__EVAL(fn, t, f) _NV_EVAL(fn(t, f))
+#define _NV_IF_EVAL(cond, t, f) _NV_IF__EVAL(_NV_IF_BIT(cond), t, f)
+
+#define _NV_IF1(cond, t, f) _NV_IF_EVAL(cond, t, f)
+#define _NV_IF(cond, t, f) _NV_IF1(_NV_EVAL(cond), _NV_EVAL(t), _NV_EVAL(f))
+
+#if defined(_NV_TARGET_CPP11)
+
+// The below mechanisms were derived from: https://gustedt.wordpress.com/2010/06/08/detect-empty-macro-arguments/
+
+#define _NV_ARG32(...) _NV_EVAL(_NV_ARG32_0(__VA_ARGS__))
+#define _NV_ARG32_0( \
+ _0, _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, ...) _31
+
+#define _NV_HAS_COMMA(...) _NV_ARG32(__VA_ARGS__, \
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0)
+
+#define _NV_TRIGGER_PARENTHESIS_(...) ,
+
+#define _NV_ISEMPTY(...) \
+ _NV_ISEMPTY0( \
+ /* test if there is just one argument, eventually an empty \
+ one */ \
+ _NV_EVAL(_NV_HAS_COMMA(__VA_ARGS__)), \
+ /* test if _TRIGGER_PARENTHESIS_ together with the argument \
+ adds a comma */ \
+ _NV_EVAL(_NV_HAS_COMMA(_NV_TRIGGER_PARENTHESIS_ __VA_ARGS__)), \
+ /* test if the argument together with a parenthesis \
+ adds a comma */ \
+ _NV_EVAL(_NV_HAS_COMMA(__VA_ARGS__ (/*empty*/))), \
+ /* test if placing it between _TRIGGER_PARENTHESIS_ and the \
+ parenthesis adds a comma */ \
+ _NV_EVAL(_NV_HAS_COMMA(_NV_TRIGGER_PARENTHESIS_ __VA_ARGS__ (/*empty*/))) \
+ )
+
+#define _NV_PASTE5(_0, _1, _2, _3, _4) _0 ## _1 ## _2 ## _3 ## _4
+#define _NV_ISEMPTY0(_0, _1, _2, _3) _NV_HAS_COMMA(_NV_PASTE5(_NV_IS_EMPTY_CASE_, _0, _1, _2, _3))
+#define _NV_IS_EMPTY_CASE_0001 ,
+
+
+#define _NV_REMOVE_PAREN(...) _NV_REMOVE_PAREN1(__VA_ARGS__)
+#define _NV_REMOVE_PAREN1(...) _NV_STRIP_PAREN(_NV_IF(_NV_TEST_PAREN(__VA_ARGS__), (_NV_STRIP_PAREN(__VA_ARGS__)), (__VA_ARGS__)))
+
+#define _NV_STRIP_PAREN2(...) __VA_ARGS__
+#define _NV_STRIP_PAREN1(...) _NV_STRIP_PAREN2 __VA_ARGS__
+#define _NV_STRIP_PAREN(...) _NV_STRIP_PAREN1(__VA_ARGS__)
+
+#define _NV_TEST_PAREN(...) _NV_TEST_PAREN1(__VA_ARGS__)
+#define _NV_TEST_PAREN1(...) _NV_TEST_PAREN2(_NV_TEST_PAREN_DUMMY __VA_ARGS__)
+#define _NV_TEST_PAREN2(...) _NV_TEST_PAREN3(_NV_CONCAT_EVAL(_, __VA_ARGS__))
+#define _NV_TEST_PAREN3(...) _NV_EVAL(_NV_FIRST_ARG(__VA_ARGS__))
+
+#define __NV_PAREN_YES 1
+#define __NV_PAREN_NO 0
+
+#define _NV_TEST_PAREN_DUMMY(...) _NV_PAREN_YES
+#define __NV_TEST_PAREN_DUMMY __NV_PAREN_NO,
+
+#define _NV_FIRST_ARG1(x, ...) x
+#define _NV_FIRST_ARG(x, ...) _NV_FIRST_ARG1(x)
+
+#define _NV_REMOVE_FIRST_ARGS1(...) __VA_ARGS__
+#define _NV_REMOVE_FIRST_ARGS(x, ...) _NV_REMOVE_FIRST_ARGS1(__VA_ARGS__)
+
+#define _NV_NUM_ARGS(...) _NV_NUM_ARGS0(__VA_ARGS__)
+#define _NV_NUM_ARGS0(...) _NV_EVAL(_NV_NUM_ARGS1(__VA_ARGS__))
+#define _NV_NUM_ARGS1(...) _NV_IF(_NV_ISEMPTY(__VA_ARGS__), 0, _NV_NUM_ARGS2(__VA_ARGS__))
+#define _NV_NUM_ARGS2(...) _NV_ARG32(__VA_ARGS__, \
+ 31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16, \
+ 15,14,13,12,11,10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
+
+#define _NV_DISPATCH_N_IMPL1(name, ...) _NV_EVAL(name(__VA_ARGS__))
+#define _NV_DISPATCH_N_IMPL0(depth, name, ...) _NV_DISPATCH_N_IMPL1(_NV_CONCAT_EVAL(name, depth), __VA_ARGS__)
+#define _NV_DISPATCH_N_IMPL(name, ...) _NV_DISPATCH_N_IMPL0(_NV_NUM_ARGS(__VA_ARGS__), name, __VA_ARGS__)
+#define _NV_DISPATCH_N_ARY(name, ...) _NV_DISPATCH_N_IMPL(name, __VA_ARGS__)
+
+#endif // C++11
\ No newline at end of file
diff --git a/include/cuco/detail/nv/detail/__target_macros b/include/cuco/detail/nv/detail/__target_macros
new file mode 100644
index 0000000..d67d923
--- /dev/null
+++ b/include/cuco/detail/nv/detail/__target_macros
@@ -0,0 +1,472 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of libcu++, the C++ Standard Library for your entire system,
+// under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _NV__TARGET_MACROS
+#define _NV__TARGET_MACROS
+
+#include "__preprocessor"
+
+#if defined(__GNUC__)
+#pragma GCC system_header
+#endif
+
+# define _NV_TARGET_ARCH_TO_SELECTOR_350 nv::target::sm_35
+# define _NV_TARGET_ARCH_TO_SELECTOR_370 nv::target::sm_37
+# define _NV_TARGET_ARCH_TO_SELECTOR_500 nv::target::sm_50
+# define _NV_TARGET_ARCH_TO_SELECTOR_520 nv::target::sm_52
+# define _NV_TARGET_ARCH_TO_SELECTOR_530 nv::target::sm_53
+# define _NV_TARGET_ARCH_TO_SELECTOR_600 nv::target::sm_60
+# define _NV_TARGET_ARCH_TO_SELECTOR_610 nv::target::sm_61
+# define _NV_TARGET_ARCH_TO_SELECTOR_620 nv::target::sm_62
+# define _NV_TARGET_ARCH_TO_SELECTOR_700 nv::target::sm_70
+# define _NV_TARGET_ARCH_TO_SELECTOR_720 nv::target::sm_72
+# define _NV_TARGET_ARCH_TO_SELECTOR_750 nv::target::sm_75
+# define _NV_TARGET_ARCH_TO_SELECTOR_800 nv::target::sm_80
+# define _NV_TARGET_ARCH_TO_SELECTOR_860 nv::target::sm_86
+# define _NV_TARGET_ARCH_TO_SELECTOR_870 nv::target::sm_87
+
+# define _NV_TARGET_ARCH_TO_SM_350 35
+# define _NV_TARGET_ARCH_TO_SM_370 37
+# define _NV_TARGET_ARCH_TO_SM_500 50
+# define _NV_TARGET_ARCH_TO_SM_520 52
+# define _NV_TARGET_ARCH_TO_SM_530 53
+# define _NV_TARGET_ARCH_TO_SM_600 60
+# define _NV_TARGET_ARCH_TO_SM_610 61
+# define _NV_TARGET_ARCH_TO_SM_620 62
+# define _NV_TARGET_ARCH_TO_SM_700 70
+# define _NV_TARGET_ARCH_TO_SM_720 72
+# define _NV_TARGET_ARCH_TO_SM_750 75
+# define _NV_TARGET_ARCH_TO_SM_800 80
+# define _NV_TARGET_ARCH_TO_SM_860 86
+# define _NV_TARGET_ARCH_TO_SM_870 87
+
+// Only enable when compiling for CUDA/stdpar
+#if defined(_NV_COMPILER_NVCXX) && defined(_NVHPC_CUDA)
+
+# define _NV_TARGET_VAL_SM_35 nv::target::sm_35
+# define _NV_TARGET_VAL_SM_37 nv::target::sm_37
+# define _NV_TARGET_VAL_SM_50 nv::target::sm_50
+# define _NV_TARGET_VAL_SM_52 nv::target::sm_52
+# define _NV_TARGET_VAL_SM_53 nv::target::sm_53
+# define _NV_TARGET_VAL_SM_60 nv::target::sm_60
+# define _NV_TARGET_VAL_SM_61 nv::target::sm_61
+# define _NV_TARGET_VAL_SM_62 nv::target::sm_62
+# define _NV_TARGET_VAL_SM_70 nv::target::sm_70
+# define _NV_TARGET_VAL_SM_72 nv::target::sm_72
+# define _NV_TARGET_VAL_SM_75 nv::target::sm_75
+# define _NV_TARGET_VAL_SM_80 nv::target::sm_80
+# define _NV_TARGET_VAL_SM_86 nv::target::sm_86
+# define _NV_TARGET_VAL_SM_87 nv::target::sm_87
+
+# define _NV_TARGET___NV_IS_HOST nv::target::is_host
+# define _NV_TARGET___NV_IS_DEVICE nv::target::is_device
+
+# define _NV_TARGET___NV_ANY_TARGET (nv::target::any_target)
+# define _NV_TARGET___NV_NO_TARGET (nv::target::no_target)
+
+# if defined(NV_TARGET_SM_INTEGER_LIST)
+# define NV_TARGET_MINIMUM_SM_SELECTOR _NV_FIRST_ARG(NV_TARGET_SM_SELECTOR_LIST)
+# define NV_TARGET_MINIMUM_SM_INTEGER _NV_FIRST_ARG(NV_TARGET_SM_INTEGER_LIST)
+# define __CUDA_MINIMUM_ARCH__ _NV_CONCAT_EVAL(_NV_FIRST_ARG(NV_TARGET_SM_INTEGER_LIST), 0)
+# endif
+
+# define _NV_TARGET_PROVIDES(q) nv::target::provides(q)
+# define _NV_TARGET_IS_EXACTLY(q) nv::target::is_exactly(q)
+
+#elif defined(_NV_COMPILER_NVCC) || defined (_NV_COMPILER_CLANG_CUDA)
+
+# define _NV_TARGET_VAL_SM_35 350
+# define _NV_TARGET_VAL_SM_37 370
+# define _NV_TARGET_VAL_SM_50 500
+# define _NV_TARGET_VAL_SM_52 520
+# define _NV_TARGET_VAL_SM_53 530
+# define _NV_TARGET_VAL_SM_60 600
+# define _NV_TARGET_VAL_SM_61 610
+# define _NV_TARGET_VAL_SM_62 620
+# define _NV_TARGET_VAL_SM_70 700
+# define _NV_TARGET_VAL_SM_72 720
+# define _NV_TARGET_VAL_SM_75 750
+# define _NV_TARGET_VAL_SM_80 800
+# define _NV_TARGET_VAL_SM_86 860
+# define _NV_TARGET_VAL_SM_87 870
+
+# if defined(__CUDA_ARCH__)
+# define _NV_TARGET_VAL __CUDA_ARCH__
+# define NV_TARGET_MINIMUM_SM_SELECTOR _NV_CONCAT_EVAL(_NV_TARGET_ARCH_TO_SELECTOR_, __CUDA_ARCH__)
+# define NV_TARGET_MINIMUM_SM_INTEGER _NV_CONCAT_EVAL(_NV_TARGET_ARCH_TO_SM_, __CUDA_ARCH__)
+# define __CUDA_MINIMUM_ARCH__ __CUDA_ARCH__
+# endif
+
+# if defined(__CUDA_ARCH__)
+# define _NV_TARGET_IS_HOST 0
+# define _NV_TARGET_IS_DEVICE 1
+# else
+# define _NV_TARGET_IS_HOST 1
+# define _NV_TARGET_IS_DEVICE 0
+# endif
+
+# if defined(_NV_TARGET_VAL)
+# define _NV_DEVICE_CHECK(q) (q)
+# else
+# define _NV_DEVICE_CHECK(q) (0)
+# endif
+
+# define _NV_TARGET_PROVIDES(q) _NV_DEVICE_CHECK(_NV_TARGET_VAL >= q)
+# define _NV_TARGET_IS_EXACTLY(q) _NV_DEVICE_CHECK(_NV_TARGET_VAL == q)
+
+// NVCC/NVCXX not being used, only host dispatches allowed
+#else
+
+# define _NV_COMPILER_NVCC
+
+# define _NV_TARGET_VAL_SM_35 350
+# define _NV_TARGET_VAL_SM_37 370
+# define _NV_TARGET_VAL_SM_50 500
+# define _NV_TARGET_VAL_SM_52 520
+# define _NV_TARGET_VAL_SM_53 530
+# define _NV_TARGET_VAL_SM_60 600
+# define _NV_TARGET_VAL_SM_61 610
+# define _NV_TARGET_VAL_SM_62 620
+# define _NV_TARGET_VAL_SM_70 700
+# define _NV_TARGET_VAL_SM_72 720
+# define _NV_TARGET_VAL_SM_75 750
+# define _NV_TARGET_VAL_SM_80 800
+# define _NV_TARGET_VAL_SM_86 860
+# define _NV_TARGET_VAL_SM_87 870
+
+# define _NV_TARGET_VAL 0
+
+# define _NV_TARGET_IS_HOST 1
+# define _NV_TARGET_IS_DEVICE 0
+
+# define _NV_DEVICE_CHECK(q) (false)
+
+# define _NV_TARGET_PROVIDES(q) _NV_DEVICE_CHECK(_NV_TARGET_VAL >= q)
+# define _NV_TARGET_IS_EXACTLY(q) _NV_DEVICE_CHECK(_NV_TARGET_VAL == q)
+
+#endif
+
+#define _NV_TARGET___NV_PROVIDES_SM_35 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_35))
+#define _NV_TARGET___NV_PROVIDES_SM_37 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_37))
+#define _NV_TARGET___NV_PROVIDES_SM_50 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_50))
+#define _NV_TARGET___NV_PROVIDES_SM_52 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_52))
+#define _NV_TARGET___NV_PROVIDES_SM_53 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_53))
+#define _NV_TARGET___NV_PROVIDES_SM_60 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_60))
+#define _NV_TARGET___NV_PROVIDES_SM_61 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_61))
+#define _NV_TARGET___NV_PROVIDES_SM_62 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_62))
+#define _NV_TARGET___NV_PROVIDES_SM_70 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_70))
+#define _NV_TARGET___NV_PROVIDES_SM_72 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_72))
+#define _NV_TARGET___NV_PROVIDES_SM_75 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_75))
+#define _NV_TARGET___NV_PROVIDES_SM_80 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_80))
+#define _NV_TARGET___NV_PROVIDES_SM_86 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_86))
+#define _NV_TARGET___NV_PROVIDES_SM_87 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_87))
+
+#define _NV_TARGET___NV_IS_EXACTLY_SM_35 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_35))
+#define _NV_TARGET___NV_IS_EXACTLY_SM_37 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_37))
+#define _NV_TARGET___NV_IS_EXACTLY_SM_50 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_50))
+#define _NV_TARGET___NV_IS_EXACTLY_SM_52 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_52))
+#define _NV_TARGET___NV_IS_EXACTLY_SM_53 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_53))
+#define _NV_TARGET___NV_IS_EXACTLY_SM_60 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_60))
+#define _NV_TARGET___NV_IS_EXACTLY_SM_61 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_61))
+#define _NV_TARGET___NV_IS_EXACTLY_SM_62 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_62))
+#define _NV_TARGET___NV_IS_EXACTLY_SM_70 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_70))
+#define _NV_TARGET___NV_IS_EXACTLY_SM_72 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_72))
+#define _NV_TARGET___NV_IS_EXACTLY_SM_75 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_75))
+#define _NV_TARGET___NV_IS_EXACTLY_SM_80 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_80))
+#define _NV_TARGET___NV_IS_EXACTLY_SM_86 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_86))
+#define _NV_TARGET___NV_IS_EXACTLY_SM_87 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_87))
+
+#define NV_PROVIDES_SM_35 __NV_PROVIDES_SM_35
+#define NV_PROVIDES_SM_37 __NV_PROVIDES_SM_37
+#define NV_PROVIDES_SM_50 __NV_PROVIDES_SM_50
+#define NV_PROVIDES_SM_52 __NV_PROVIDES_SM_52
+#define NV_PROVIDES_SM_53 __NV_PROVIDES_SM_53
+#define NV_PROVIDES_SM_60 __NV_PROVIDES_SM_60
+#define NV_PROVIDES_SM_61 __NV_PROVIDES_SM_61
+#define NV_PROVIDES_SM_62 __NV_PROVIDES_SM_62
+#define NV_PROVIDES_SM_70 __NV_PROVIDES_SM_70
+#define NV_PROVIDES_SM_72 __NV_PROVIDES_SM_72
+#define NV_PROVIDES_SM_75 __NV_PROVIDES_SM_75
+#define NV_PROVIDES_SM_80 __NV_PROVIDES_SM_80
+#define NV_PROVIDES_SM_86 __NV_PROVIDES_SM_86
+#define NV_PROVIDES_SM_87 __NV_PROVIDES_SM_87
+
+#define NV_IS_EXACTLY_SM_35 __NV_IS_EXACTLY_SM_35
+#define NV_IS_EXACTLY_SM_37 __NV_IS_EXACTLY_SM_37
+#define NV_IS_EXACTLY_SM_50 __NV_IS_EXACTLY_SM_50
+#define NV_IS_EXACTLY_SM_52 __NV_IS_EXACTLY_SM_52
+#define NV_IS_EXACTLY_SM_53 __NV_IS_EXACTLY_SM_53
+#define NV_IS_EXACTLY_SM_60 __NV_IS_EXACTLY_SM_60
+#define NV_IS_EXACTLY_SM_61 __NV_IS_EXACTLY_SM_61
+#define NV_IS_EXACTLY_SM_62 __NV_IS_EXACTLY_SM_62
+#define NV_IS_EXACTLY_SM_70 __NV_IS_EXACTLY_SM_70
+#define NV_IS_EXACTLY_SM_72 __NV_IS_EXACTLY_SM_72
+#define NV_IS_EXACTLY_SM_75 __NV_IS_EXACTLY_SM_75
+#define NV_IS_EXACTLY_SM_80 __NV_IS_EXACTLY_SM_80
+#define NV_IS_EXACTLY_SM_86 __NV_IS_EXACTLY_SM_86
+#define NV_IS_EXACTLY_SM_87 __NV_IS_EXACTLY_SM_87
+
+#define NV_IS_HOST __NV_IS_HOST
+#define NV_IS_DEVICE __NV_IS_DEVICE
+
+#define NV_ANY_TARGET __NV_ANY_TARGET
+#define NV_NO_TARGET __NV_NO_TARGET
+
+// Platform invoke mechanisms
+#if defined(_NV_COMPILER_NVCXX) && defined(_NVHPC_CUDA)
+
+# define _NV_ARCH_COND(q) (_NV_TARGET_##q)
+
+# define _NV_BLOCK_EXPAND(...) _NV_REMOVE_PAREN(__VA_ARGS__)
+
+# define _NV_TARGET_IF(cond, t, ...) \
+ (if target _NV_ARCH_COND(cond) { \
+ _NV_BLOCK_EXPAND(t) \
+ } else { _NV_BLOCK_EXPAND(__VA_ARGS__) })
+
+#elif defined(_NV_COMPILER_NVCC) || defined (_NV_COMPILER_CLANG_CUDA)
+
+# if (_NV_TARGET___NV_IS_EXACTLY_SM_35)
+# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_35 1
+# else
+# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_35 0
+# endif
+
+# if (_NV_TARGET___NV_IS_EXACTLY_SM_37)
+# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_37 1
+# else
+# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_37 0
+# endif
+
+# if (_NV_TARGET___NV_IS_EXACTLY_SM_50)
+# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_50 1
+# else
+# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_50 0
+# endif
+
+# if (_NV_TARGET___NV_IS_EXACTLY_SM_52)
+# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_52 1
+# else
+# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_52 0
+# endif
+
+# if (_NV_TARGET___NV_IS_EXACTLY_SM_53)
+# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_53 1
+# else
+# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_53 0
+# endif
+
+# if (_NV_TARGET___NV_IS_EXACTLY_SM_60)
+# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_60 1
+# else
+# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_60 0
+# endif
+
+# if (_NV_TARGET___NV_IS_EXACTLY_SM_61)
+# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_61 1
+# else
+# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_61 0
+# endif
+
+# if (_NV_TARGET___NV_IS_EXACTLY_SM_62)
+# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_62 1
+# else
+# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_62 0
+# endif
+
+# if (_NV_TARGET___NV_IS_EXACTLY_SM_70)
+# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_70 1
+# else
+# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_70 0
+# endif
+
+# if (_NV_TARGET___NV_IS_EXACTLY_SM_72)
+# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_72 1
+# else
+# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_72 0
+# endif
+
+# if (_NV_TARGET___NV_IS_EXACTLY_SM_75)
+# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_75 1
+# else
+# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_75 0
+# endif
+
+# if (_NV_TARGET___NV_IS_EXACTLY_SM_80)
+# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_80 1
+# else
+# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_80 0
+# endif
+
+# if (_NV_TARGET___NV_IS_EXACTLY_SM_86)
+# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_86 1
+# else
+# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_86 0
+# endif
+
+# if (_NV_TARGET___NV_IS_EXACTLY_SM_87)
+# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_87 1
+# else
+# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_87 0
+# endif
+
+# if (_NV_TARGET_IS_HOST)
+# define _NV_TARGET_BOOL___NV_IS_HOST 1
+# define _NV_TARGET_BOOL___NV_IS_DEVICE 0
+# else
+# define _NV_TARGET_BOOL___NV_IS_HOST 0
+# define _NV_TARGET_BOOL___NV_IS_DEVICE 1
+# endif
+
+# define _NV_TARGET_BOOL___NV_ANY_TARGET 1
+# define _NV_TARGET_BOOL___NV_NO_TARGET 0
+
+// NVCC Greater than stuff
+
+# if (_NV_TARGET___NV_PROVIDES_SM_35)
+# define _NV_TARGET_BOOL___NV_PROVIDES_SM_35 1
+# else
+# define _NV_TARGET_BOOL___NV_PROVIDES_SM_35 0
+# endif
+
+# if (_NV_TARGET___NV_PROVIDES_SM_37)
+# define _NV_TARGET_BOOL___NV_PROVIDES_SM_37 1
+# else
+# define _NV_TARGET_BOOL___NV_PROVIDES_SM_37 0
+# endif
+
+# if (_NV_TARGET___NV_PROVIDES_SM_50)
+# define _NV_TARGET_BOOL___NV_PROVIDES_SM_50 1
+# else
+# define _NV_TARGET_BOOL___NV_PROVIDES_SM_50 0
+# endif
+
+# if (_NV_TARGET___NV_PROVIDES_SM_52)
+# define _NV_TARGET_BOOL___NV_PROVIDES_SM_52 1
+# else
+# define _NV_TARGET_BOOL___NV_PROVIDES_SM_52 0
+# endif
+
+# if (_NV_TARGET___NV_PROVIDES_SM_53)
+# define _NV_TARGET_BOOL___NV_PROVIDES_SM_53 1
+# else
+# define _NV_TARGET_BOOL___NV_PROVIDES_SM_53 0
+# endif
+
+# if (_NV_TARGET___NV_PROVIDES_SM_60)
+# define _NV_TARGET_BOOL___NV_PROVIDES_SM_60 1
+# else
+# define _NV_TARGET_BOOL___NV_PROVIDES_SM_60 0
+# endif
+
+# if (_NV_TARGET___NV_PROVIDES_SM_61)
+# define _NV_TARGET_BOOL___NV_PROVIDES_SM_61 1
+# else
+# define _NV_TARGET_BOOL___NV_PROVIDES_SM_61 0
+# endif
+
+# if (_NV_TARGET___NV_PROVIDES_SM_62)
+# define _NV_TARGET_BOOL___NV_PROVIDES_SM_62 1
+# else
+# define _NV_TARGET_BOOL___NV_PROVIDES_SM_62 0
+# endif
+
+# if (_NV_TARGET___NV_PROVIDES_SM_70)
+# define _NV_TARGET_BOOL___NV_PROVIDES_SM_70 1
+# else
+# define _NV_TARGET_BOOL___NV_PROVIDES_SM_70 0
+# endif
+
+# if (_NV_TARGET___NV_PROVIDES_SM_72)
+# define _NV_TARGET_BOOL___NV_PROVIDES_SM_72 1
+# else
+# define _NV_TARGET_BOOL___NV_PROVIDES_SM_72 0
+# endif
+
+# if (_NV_TARGET___NV_PROVIDES_SM_75)
+# define _NV_TARGET_BOOL___NV_PROVIDES_SM_75 1
+# else
+# define _NV_TARGET_BOOL___NV_PROVIDES_SM_75 0
+# endif
+
+# if (_NV_TARGET___NV_PROVIDES_SM_80)
+# define _NV_TARGET_BOOL___NV_PROVIDES_SM_80 1
+# else
+# define _NV_TARGET_BOOL___NV_PROVIDES_SM_80 0
+# endif
+
+# if (_NV_TARGET___NV_PROVIDES_SM_86)
+# define _NV_TARGET_BOOL___NV_PROVIDES_SM_86 1
+# else
+# define _NV_TARGET_BOOL___NV_PROVIDES_SM_86 0
+# endif
+
+# if (_NV_TARGET___NV_PROVIDES_SM_87)
+# define _NV_TARGET_BOOL___NV_PROVIDES_SM_87 1
+# else
+# define _NV_TARGET_BOOL___NV_PROVIDES_SM_87 0
+# endif
+
+# define _NV_ARCH_COND_CAT1(cond) _NV_TARGET_BOOL_##cond
+# define _NV_ARCH_COND_CAT(cond) _NV_EVAL(_NV_ARCH_COND_CAT1(cond))
+
+# define _NV_TARGET_EMPTY_PARAM ;
+
+# if defined(_NV_TARGET_CPP11)
+
+# define _NV_BLOCK_EXPAND(...) { _NV_REMOVE_PAREN(__VA_ARGS__) }
+# define _NV_TARGET_IF(cond, t, ...) _NV_IF( _NV_ARCH_COND_CAT(cond), t, __VA_ARGS__)
+
+# else // <C++11 fallback
+
+# define _NV_BLOCK_EXPAND(x) { x }
+
+# define _NV_TARGET_IF(cond, t) _NV_IF(_NV_ARCH_COND_CAT(cond), t, _NV_TARGET_EMPTY_PARAM)
+# define _NV_TARGET_IF_ELSE(cond, t, f) _NV_IF(_NV_ARCH_COND_CAT(cond), t, f)
+
+# endif
+
+#endif // _NV_COMPILER_NVCC
+
+#if defined(_NV_TARGET_CPP11)
+
+# define _NV_TARGET_DISPATCH_HANDLE0()
+# define _NV_TARGET_DISPATCH_HANDLE2(q, fn) _NV_TARGET_IF(q, fn)
+# define _NV_TARGET_DISPATCH_HANDLE4(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE2(__VA_ARGS__))
+# define _NV_TARGET_DISPATCH_HANDLE6(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE4(__VA_ARGS__))
+# define _NV_TARGET_DISPATCH_HANDLE8(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE6(__VA_ARGS__))
+# define _NV_TARGET_DISPATCH_HANDLE10(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE8(__VA_ARGS__))
+# define _NV_TARGET_DISPATCH_HANDLE12(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE10(__VA_ARGS__))
+# define _NV_TARGET_DISPATCH_HANDLE14(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE12(__VA_ARGS__))
+# define _NV_TARGET_DISPATCH_HANDLE16(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE14(__VA_ARGS__))
+# define _NV_TARGET_DISPATCH_HANDLE18(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE16(__VA_ARGS__))
+# define _NV_TARGET_DISPATCH_HANDLE20(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE18(__VA_ARGS__))
+# define _NV_TARGET_DISPATCH_HANDLE22(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE20(__VA_ARGS__))
+# define _NV_TARGET_DISPATCH_HANDLE24(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE22(__VA_ARGS__))
+# define _NV_TARGET_DISPATCH_HANDLE26(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE24(__VA_ARGS__))
+# define _NV_TARGET_DISPATCH_HANDLE28(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE26(__VA_ARGS__))
+# define _NV_TARGET_DISPATCH_HANDLE30(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE28(__VA_ARGS__))
+# define _NV_TARGET_DISPATCH_HANDLE32(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE30(__VA_ARGS__))
+
+# define _NV_TARGET_DISPATCH(...) _NV_BLOCK_EXPAND(_NV_DISPATCH_N_ARY(_NV_TARGET_DISPATCH_HANDLE, __VA_ARGS__))
+
+// NV_IF_TARGET supports a false statement provided as a variadic macro
+# define NV_IF_TARGET(cond, ...) _NV_BLOCK_EXPAND(_NV_TARGET_IF(cond, __VA_ARGS__))
+# define NV_IF_ELSE_TARGET(cond, t, f) _NV_BLOCK_EXPAND(_NV_TARGET_IF(cond, t, f))
+# define NV_DISPATCH_TARGET(...) _NV_TARGET_DISPATCH(__VA_ARGS__)
+
+#else // <C++11 fallback
+
+// NV_IF_TARGET does not support a fallback false statement in C++03 or C dialects
+# define NV_IF_TARGET(cond, t) _NV_BLOCK_EXPAND(_NV_TARGET_IF(cond, t))
+# define NV_IF_ELSE_TARGET(cond, t, f) _NV_BLOCK_EXPAND(_NV_TARGET_IF_ELSE(cond, t, f))
+
+#endif
+
+#endif // _NV__TARGET_MACROS
\ No newline at end of file
diff --git a/include/cuco/detail/nv/target b/include/cuco/detail/nv/target
new file mode 100644
index 0000000..f199ee7
--- /dev/null
+++ b/include/cuco/detail/nv/target
@@ -0,0 +1,201 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of libcu++, the C++ Standard Library for your entire system,
+// under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// This header contains a preview of a portability system that enables
+// CUDA C++ development with NVC++, NVCC, and supported host compilers.
+// These interfaces are not guaranteed to be stable.
+
+#ifndef __NV_TARGET_H
+#define __NV_TARGET_H
+
+#if defined(__NVCC__) || defined(__CUDACC_RTC__)
+# define _NV_COMPILER_NVCC
+#elif defined(__NVCOMPILER) && __cplusplus >= 201103L
+# define _NV_COMPILER_NVCXX
+#elif defined(__clang__) && defined(__CUDA__) && defined(__CUDA_ARCH__)
+// clang compiling CUDA code, device mode.
+# define _NV_COMPILER_CLANG_CUDA
+#endif
+
+#if defined(__CUDACC_RTC__)
+# define _NV_FUNCTION_ANNOTATION __device__
+#else
+# define _NV_FUNCTION_ANNOTATION
+#endif
+
+#if defined(_NV_COMPILER_NVCXX)
+# define _NV_BITSET_ATTRIBUTE [[nv::__target_bitset]]
+#else
+# define _NV_BITSET_ATTRIBUTE
+#endif
+
+#if (!defined(__ibmxl__)) && \
+ ((defined(__cplusplus) && __cplusplus >= 201103L) || \
+ (defined(_MSC_VER) && _MSVC_LANG >= 201103L))
+# define _NV_TARGET_CPP11
+#endif
+
+#if defined(_NV_TARGET_CPP11)
+
+namespace nv {
+ namespace target {
+ namespace detail {
+
+ typedef unsigned long long base_int_t;
+
+ // No host specialization
+ constexpr base_int_t all_hosts = 1;
+
+ // NVIDIA GPUs
+ constexpr base_int_t sm_35_bit = 1 << 1;
+ constexpr base_int_t sm_37_bit = 1 << 2;
+ constexpr base_int_t sm_50_bit = 1 << 3;
+ constexpr base_int_t sm_52_bit = 1 << 4;
+ constexpr base_int_t sm_53_bit = 1 << 5;
+ constexpr base_int_t sm_60_bit = 1 << 6;
+ constexpr base_int_t sm_61_bit = 1 << 7;
+ constexpr base_int_t sm_62_bit = 1 << 8;
+ constexpr base_int_t sm_70_bit = 1 << 9;
+ constexpr base_int_t sm_72_bit = 1 << 10;
+ constexpr base_int_t sm_75_bit = 1 << 11;
+ constexpr base_int_t sm_80_bit = 1 << 12;
+ constexpr base_int_t sm_86_bit = 1 << 13;
+ constexpr base_int_t sm_87_bit = 1 << 14;
+ constexpr base_int_t all_devices =
+ sm_35_bit | sm_37_bit |
+ sm_50_bit | sm_52_bit | sm_53_bit |
+ sm_60_bit | sm_61_bit | sm_62_bit |
+ sm_70_bit | sm_72_bit | sm_75_bit |
+ sm_80_bit | sm_86_bit | sm_87_bit;
+
+ // Store a set of targets as a set of bits
+ struct _NV_BITSET_ATTRIBUTE target_description {
+ base_int_t targets;
+ _NV_FUNCTION_ANNOTATION
+ constexpr target_description(base_int_t a) : targets(a) { }
+ };
+
+ // The type of the user-visible names of the NVIDIA GPU targets
+ enum class sm_selector : base_int_t {
+ sm_35 = 35, sm_37 = 37,
+ sm_50 = 50, sm_52 = 52, sm_53 = 53,
+ sm_60 = 60, sm_61 = 61, sm_62 = 62,
+ sm_70 = 70, sm_72 = 72, sm_75 = 75,
+ sm_80 = 80, sm_86 = 86, sm_87 = 87,
+ };
+ _NV_FUNCTION_ANNOTATION
+ constexpr base_int_t toint(sm_selector a) {
+ return static_cast<base_int_t>(a);
+ }
+ _NV_FUNCTION_ANNOTATION
+ constexpr base_int_t bitexact(sm_selector a) {
+ return toint(a) == 35 ? sm_35_bit :
+ toint(a) == 37 ? sm_37_bit :
+ toint(a) == 50 ? sm_50_bit :
+ toint(a) == 52 ? sm_52_bit :
+ toint(a) == 53 ? sm_53_bit :
+ toint(a) == 60 ? sm_60_bit :
+ toint(a) == 61 ? sm_61_bit :
+ toint(a) == 62 ? sm_62_bit :
+ toint(a) == 70 ? sm_70_bit :
+ toint(a) == 72 ? sm_72_bit :
+ toint(a) == 75 ? sm_75_bit :
+ toint(a) == 80 ? sm_80_bit :
+ toint(a) == 86 ? sm_86_bit :
+ toint(a) == 87 ? sm_87_bit : 0;
+ }
+ _NV_FUNCTION_ANNOTATION
+ constexpr base_int_t bitrounddown(sm_selector a) {
+ return toint(a) >= 87 ? sm_87_bit :
+ toint(a) >= 86 ? sm_86_bit :
+ toint(a) >= 80 ? sm_80_bit :
+ toint(a) >= 75 ? sm_75_bit :
+ toint(a) >= 72 ? sm_72_bit :
+ toint(a) >= 70 ? sm_70_bit :
+ toint(a) >= 62 ? sm_62_bit :
+ toint(a) >= 61 ? sm_61_bit :
+ toint(a) >= 60 ? sm_60_bit :
+ toint(a) >= 53 ? sm_53_bit :
+ toint(a) >= 52 ? sm_52_bit :
+ toint(a) >= 50 ? sm_50_bit :
+ toint(a) >= 37 ? sm_37_bit :
+ toint(a) >= 35 ? sm_35_bit : 0;
+ }
+
+ // Public API for NVIDIA GPUs
+
+ _NV_FUNCTION_ANNOTATION
+ constexpr target_description is_exactly(sm_selector a) {
+ return target_description(bitexact(a));
+ }
+
+ _NV_FUNCTION_ANNOTATION
+ constexpr target_description provides(sm_selector a) {
+ return target_description(~(bitrounddown(a) - 1) & all_devices);
+ }
+
+ // Boolean operations on target sets
+
+ _NV_FUNCTION_ANNOTATION
+ constexpr target_description operator&&(target_description a,
+ target_description b) {
+ return target_description(a.targets & b.targets);
+ }
+
+ _NV_FUNCTION_ANNOTATION
+ constexpr target_description operator||(target_description a,
+ target_description b) {
+ return target_description(a.targets | b.targets);
+ }
+
+ _NV_FUNCTION_ANNOTATION
+ constexpr target_description operator!(target_description a) {
+ return target_description(~a.targets & (all_devices | all_hosts));
+ }
+ }
+
+ using detail::target_description;
+ using detail::sm_selector;
+
+ // The predicates for basic host/device selection
+ constexpr target_description is_host =
+ target_description(detail::all_hosts);
+ constexpr target_description is_device =
+ target_description(detail::all_devices);
+ constexpr target_description any_target =
+ target_description(detail::all_hosts | detail::all_devices);
+ constexpr target_description no_target =
+ target_description(0);
+
+ // The public names for NVIDIA GPU architectures
+ constexpr sm_selector sm_35 = sm_selector::sm_35;
+ constexpr sm_selector sm_37 = sm_selector::sm_37;
+ constexpr sm_selector sm_50 = sm_selector::sm_50;
+ constexpr sm_selector sm_52 = sm_selector::sm_52;
+ constexpr sm_selector sm_53 = sm_selector::sm_53;
+ constexpr sm_selector sm_60 = sm_selector::sm_60;
+ constexpr sm_selector sm_61 = sm_selector::sm_61;
+ constexpr sm_selector sm_62 = sm_selector::sm_62;
+ constexpr sm_selector sm_70 = sm_selector::sm_70;
+ constexpr sm_selector sm_72 = sm_selector::sm_72;
+ constexpr sm_selector sm_75 = sm_selector::sm_75;
+ constexpr sm_selector sm_80 = sm_selector::sm_80;
+ constexpr sm_selector sm_86 = sm_selector::sm_86;
+ constexpr sm_selector sm_87 = sm_selector::sm_87;
+
+ using detail::is_exactly;
+ using detail::provides;
+ }
+}
+
+#endif // C++11
+
+#include "detail/__target_macros"
+
+#endif // __NV_TARGET_H
\ No newline at end of file
diff --git a/include/cuco/detail/pair.cuh b/include/cuco/detail/pair.cuh
index 7ea3988..846728b 100644
--- a/include/cuco/detail/pair.cuh
+++ b/include/cuco/detail/pair.cuh
@@ -24,6 +24,39 @@
#include <algorithm>
#include <tuple>
#include <type_traits>
+namespace std {
+template <class...>
+using void_t = void;
+
+template <bool B>
+using bool_constant = std::integral_constant<bool, B>;
+
+template <typename _Tp>
+struct has_unique_object_representations : bool_constant<__has_unique_object_representations(std::remove_cv_t<std::remove_all_extents_t<_Tp>>)> {};
+
+template <class T>
+inline constexpr bool has_unique_object_representations_v = has_unique_object_representations<T>::value;
+
+// Fangzhou Ai @ 2022/07/07 3:28 PM PST
+// This deprecated function cast is for older veriosn of cuCollection
+// template< class From, class To >
+// inline constexpr bool is_convertible_v = is_convertible<From, To>::value;
+
+template <typename Key, typename ProbeKey, typename KeyEqual>
+struct is_invocable :
+ std::is_constructible<
+ std::function<void(ProbeKey, KeyEqual)>,
+ std::reference_wrapper<typename std::remove_reference<Key>::type>
+ >
+{
+};
+
+template <typename Key, typename ProbeKey, typename KeyEqual>
+inline constexpr bool is_invocable_v = is_invocable<Key, ProbeKey, KeyEqual>::value;
+
+template <typename Base, typename Derived>
+inline constexpr bool is_base_of_v = is_base_of<Base, Derived>::value;
+} // namespace std
namespace cuco {
namespace detail {
diff --git a/include/cuco/detail/static_map.inl b/include/cuco/detail/static_map.inl
index 09e9d05..5e16f13 100644
--- a/include/cuco/detail/static_map.inl
+++ b/include/cuco/detail/static_map.inl
@@ -25,50 +25,17 @@
#include <cub/device/device_select.cuh>
namespace cuco {
-
-template <typename Key, typename Value, cuda::thread_scope Scope, typename Allocator>
-static_map<Key, Value, Scope, Allocator>::static_map(
- std::size_t capacity,
- sentinel::empty_key<Key> empty_key_sentinel,
- sentinel::empty_value<Value> empty_value_sentinel,
- Allocator const& alloc,
- cudaStream_t stream)
- : capacity_{std::max(capacity, std::size_t{1})}, // to avoid dereferencing a nullptr (Issue #72)
- empty_key_sentinel_{empty_key_sentinel.value},
- empty_value_sentinel_{empty_value_sentinel.value},
- erased_key_sentinel_{empty_key_sentinel.value},
- slot_allocator_{alloc},
- counter_allocator_{alloc}
-{
- slots_ = std::allocator_traits<slot_allocator_type>::allocate(slot_allocator_, capacity_);
- num_successes_ = std::allocator_traits<counter_allocator_type>::allocate(counter_allocator_, 1);
-
- auto constexpr block_size = 256;
- auto constexpr stride = 4;
- auto const grid_size = (capacity_ + stride * block_size - 1) / (stride * block_size);
- detail::initialize<block_size, atomic_key_type, atomic_mapped_type>
- <<<grid_size, block_size, 0, stream>>>(
- slots_, empty_key_sentinel_, empty_value_sentinel_, capacity_);
-}
-
-template <typename Key, typename Value, cuda::thread_scope Scope, typename Allocator>
-static_map<Key, Value, Scope, Allocator>::static_map(
+template <typename Key, typename Value,
+ Key empty_key_sentinel, Value empty_value_sentinel, Key erased_key_sentinel,
+ cuda::thread_scope Scope, typename Allocator>
+static_map<Key, Value, empty_key_sentinel, empty_value_sentinel, erased_key_sentinel, Scope, Allocator>::static_map(
std::size_t capacity,
- sentinel::empty_key<Key> empty_key_sentinel,
- sentinel::empty_value<Value> empty_value_sentinel,
- sentinel::erased_key<Key> erased_key_sentinel,
Allocator const& alloc,
cudaStream_t stream)
: capacity_{std::max(capacity, std::size_t{1})}, // to avoid dereferencing a nullptr (Issue #72)
- empty_key_sentinel_{empty_key_sentinel.value},
- empty_value_sentinel_{empty_value_sentinel.value},
- erased_key_sentinel_{erased_key_sentinel.value},
slot_allocator_{alloc},
counter_allocator_{alloc}
{
- CUCO_RUNTIME_EXPECTS(empty_key_sentinel_ != erased_key_sentinel_,
- "The empty key sentinel and erased key sentinel cannot be the same value.");
-
slots_ = std::allocator_traits<slot_allocator_type>::allocate(slot_allocator_, capacity_);
num_successes_ = std::allocator_traits<counter_allocator_type>::allocate(counter_allocator_, 1);
@@ -80,16 +47,20 @@ static_map<Key, Value, Scope, Allocator>::static_map(
slots_, empty_key_sentinel_, empty_value_sentinel_, capacity_);
}
-template <typename Key, typename Value, cuda::thread_scope Scope, typename Allocator>
-static_map<Key, Value, Scope, Allocator>::~static_map()
+template <typename Key, typename Value,
+ Key empty_key_sentinel, Value empty_value_sentinel, Key erased_key_sentinel,
+ cuda::thread_scope Scope, typename Allocator>
+static_map<Key, Value, empty_key_sentinel, empty_value_sentinel, erased_key_sentinel, Scope, Allocator>::~static_map()
{
std::allocator_traits<slot_allocator_type>::deallocate(slot_allocator_, slots_, capacity_);
std::allocator_traits<counter_allocator_type>::deallocate(counter_allocator_, num_successes_, 1);
}
-template <typename Key, typename Value, cuda::thread_scope Scope, typename Allocator>
+template <typename Key, typename Value,
+ Key empty_key_sentinel, Value empty_value_sentinel, Key erased_key_sentinel,
+ cuda::thread_scope Scope, typename Allocator>
template <typename InputIt, typename Hash, typename KeyEqual>
-void static_map<Key, Value, Scope, Allocator>::insert(
+void static_map<Key, Value, empty_key_sentinel, empty_value_sentinel, erased_key_sentinel, Scope, Allocator>::insert(
InputIt first, InputIt last, Hash hash, KeyEqual key_equal, cudaStream_t stream)
{
auto num_keys = std::distance(first, last);
@@ -116,13 +87,15 @@ void static_map<Key, Value, Scope, Allocator>::insert(
size_ += h_num_successes;
}
-template <typename Key, typename Value, cuda::thread_scope Scope, typename Allocator>
+template <typename Key, typename Value,
+ Key empty_key_sentinel, Value empty_value_sentinel, Key erased_key_sentinel,
+ cuda::thread_scope Scope, typename Allocator>
template <typename InputIt,
typename StencilIt,
typename Predicate,
typename Hash,
typename KeyEqual>
-void static_map<Key, Value, Scope, Allocator>::insert_if(InputIt first,
+void static_map<Key, Value, empty_key_sentinel, empty_value_sentinel, erased_key_sentinel, Scope, Allocator>::insert_if(InputIt first,
InputIt last,
StencilIt stencil,
Predicate pred,
@@ -153,14 +126,13 @@ void static_map<Key, Value, Scope, Allocator>::insert_if(InputIt first,
size_ += h_num_successes;
}
-template <typename Key, typename Value, cuda::thread_scope Scope, typename Allocator>
+template <typename Key, typename Value,
+ Key empty_key_sentinel, Value empty_value_sentinel, Key erased_key_sentinel,
+ cuda::thread_scope Scope, typename Allocator>
template <typename InputIt, typename Hash, typename KeyEqual>
-void static_map<Key, Value, Scope, Allocator>::erase(
+void static_map<Key, Value, empty_key_sentinel, empty_value_sentinel, erased_key_sentinel, Scope, Allocator>::erase(
InputIt first, InputIt last, Hash hash, KeyEqual key_equal, cudaStream_t stream)
{
- CUCO_RUNTIME_EXPECTS(get_empty_key_sentinel() != get_erased_key_sentinel(),
- "You must provide a unique erased key sentinel value at map construction.");
-