@@ -413,10 +413,188 @@ def SYCLMemref : AnyTypeOf<[
413
413
def IndexType : AnyTypeOf<[I32, I64, Index]>;
414
414
def SYCLGetIDResult : AnyTypeOf<[I64, SYCL_IDType]>;
415
415
def SYCLGetRangeResult : AnyTypeOf<[I64, SYCL_RangeType]>;
416
+ def SYCLIndexSpaceGetIDResult : AnyTypeOf<[Index, SYCL_IDType]>;
417
+ def SYCLIndexSpaceGetRangeResult : AnyTypeOf<[Index, SYCL_RangeType]>;
416
418
def SYCLGetResult : AnyTypeOf<[I64, MemRefOf<[I64]>]>;
417
419
def VectorEltTy : AnyTypeOf<[I1, I8, I16, I32, I64, F16, F32, F64]>;
418
420
def VectorSplatArg : MemRefOf<[VectorEltTy]>;
419
421
422
+ ////////////////////////////////////////////////////////////////////////////////
423
+ // SYCL GRID OPERATIONS
424
+ ////////////////////////////////////////////////////////////////////////////////
425
+
426
+ def SYCLNumWorkItemsOp : SYCL_Op<"num_work_items", [SYCLIndexSpaceGetRange]> {
427
+ let summary = "Retrieve the number of work-items.";
428
+ let description = [{
429
+ This operation returns the number of work-items in the index space. If the
430
+ optional argument is passed, the number of work-items in the given dimension
431
+ is returned.
432
+ }];
433
+
434
+ let arguments = (ins Optional<I32>:$dimension);
435
+ let results = (outs SYCLIndexSpaceGetRangeResult:$result);
436
+ let assemblyFormat = [{
437
+ `(` operands `)` attr-dict `:` functional-type(operands, results)
438
+ }];
439
+ }
440
+
441
+ def SYCLGlobalIDOp : SYCL_Op<"global_id", [SYCLIndexSpaceGetID]> {
442
+ let summary = "Retrieve the global ID of the item.";
443
+ let description = [{
444
+ This operation returns the global ID of the item in the index space. If the
445
+ optional argument is passed, the global ID of the item in the given
446
+ dimension is returned.
447
+ }];
448
+
449
+ let arguments = (ins Optional<I32>:$dimension);
450
+ let results = (outs SYCLIndexSpaceGetIDResult:$result);
451
+ let assemblyFormat = [{
452
+ `(` operands `)` attr-dict `:` functional-type(operands, results)
453
+ }];
454
+ }
455
+
456
+ def SYCLLocalIDOp : SYCL_Op<"local_id", [SYCLIndexSpaceGetID]> {
457
+ let summary = "Retrieve the local ID of the item.";
458
+ let description = [{
459
+ This operation returns the local ID of the item within the work-group. If
460
+ the optional argument is passed, the local ID of the item in the given
461
+ dimension is returned.
462
+ }];
463
+
464
+ let arguments = (ins Optional<I32>:$dimension);
465
+ let results = (outs SYCLIndexSpaceGetIDResult:$result);
466
+ let assemblyFormat = [{
467
+ `(` operands `)` attr-dict `:` functional-type(operands, results)
468
+ }];
469
+ }
470
+
471
+ def SYCLGlobalOffsetOp : SYCL_Op<"global_offset", [SYCLIndexSpaceGetID]>,
472
+ Deprecated<"deprecated in SYCL 2020"> {
473
+ let summary = "Retrieve the global offset of the item.";
474
+ let description = [{
475
+ This operation returns the global offset of the item in the index space. If
476
+ the optional argument is passed, the global offset of the item in the given
477
+ dimension is returned.
478
+
479
+ Note that this is deprecated in SYCL 2020.
480
+ }];
481
+
482
+ let arguments = (ins Optional<I32>:$dimension);
483
+ let results = (outs SYCLIndexSpaceGetIDResult:$result);
484
+ let assemblyFormat = [{
485
+ `(` operands `)` attr-dict `:` functional-type(operands, results)
486
+ }];
487
+ }
488
+
489
+ def SYCLNumWorkGroupsOp : SYCL_Op<"num_work_groups", [SYCLIndexSpaceGetRange]> {
490
+ let summary = "Retrieve the number of work-groups.";
491
+ let description = [{
492
+ This operation returns the number of work-groups in the index space. If the
493
+ optional argument is passed, the number of work-groups in the given
494
+ dimension is returned.
495
+ }];
496
+
497
+ let arguments = (ins Optional<I32>:$dimension);
498
+ let results = (outs SYCLIndexSpaceGetRangeResult:$result);
499
+ let assemblyFormat = [{
500
+ `(` operands `)` attr-dict `:` functional-type(operands, results)
501
+ }];
502
+ }
503
+
504
+ def SYCLWorkGroupSizeOp : SYCL_Op<"work_group_size", [SYCLIndexSpaceGetRange]> {
505
+ let summary = "Retrieve the number of work-items in a work-group.";
506
+ let description = [{
507
+ This operation returns the number of work-items per work-group. If the
508
+ optional argument is passed, the number of work-items per work-group in the
509
+ given dimension is returned.
510
+ }];
511
+
512
+ let arguments = (ins Optional<I32>:$dimension);
513
+ let results = (outs SYCLIndexSpaceGetRangeResult:$result);
514
+ let assemblyFormat = [{
515
+ `(` operands `)` attr-dict `:` functional-type(operands, results)
516
+ }];
517
+ }
518
+
519
+ def SYCLWorkGroupIDOp : SYCL_Op<"work_group_id", [SYCLIndexSpaceGetID]> {
520
+ let summary = "Retrieve the ID of the work-group.";
521
+ let description = [{
522
+ This operation returns the ID of the work-group. If the optional argument is
523
+ passed, the ID of the work-group in the given dimension is returned.
524
+ }];
525
+
526
+ let arguments = (ins Optional<I32>:$dimension);
527
+ let results = (outs SYCLIndexSpaceGetIDResult:$result);
528
+ let assemblyFormat = [{
529
+ `(` operands `)` attr-dict `:` functional-type(operands, results)
530
+ }];
531
+ }
532
+
533
+ def SYCLNumSubGroupsOp : SYCL_Op<"num_sub_groups"> {
534
+ let summary = "Retrieve the number of sub-groups.";
535
+ let description = [{
536
+ This operation returns the number of sub-groups.
537
+ }];
538
+
539
+ let arguments = (ins);
540
+ let results = (outs I32:$result);
541
+ let assemblyFormat = [{
542
+ attr-dict `:` functional-type(operands, results)
543
+ }];
544
+ }
545
+
546
+ def SYCLSubGroupMaxSizeOp : SYCL_Op<"sub_group_max_size"> {
547
+ let summary = "Retrieve the maximum size of a sub-group.";
548
+ let description = [{
549
+ This operation returns the maximum size of a sub-group.
550
+ }];
551
+
552
+ let arguments = (ins);
553
+ let results = (outs I32:$result);
554
+ let assemblyFormat = [{
555
+ attr-dict `:` functional-type(operands, results)
556
+ }];
557
+ }
558
+
559
+ def SYCLSubGroupSizeOp : SYCL_Op<"sub_group_size"> {
560
+ let summary = "Retrieve the sub-group size.";
561
+ let description = [{
562
+ This operation returns the sub-group size.
563
+ }];
564
+
565
+ let arguments = (ins);
566
+ let results = (outs I32:$result);
567
+ let assemblyFormat = [{
568
+ attr-dict `:` functional-type(operands, results)
569
+ }];
570
+ }
571
+
572
+ def SYCLSubGroupIDOp : SYCL_Op<"sub_group_id"> {
573
+ let summary = "Retrieve the ID of the sub-group.";
574
+ let description = [{
575
+ This operation returns the ID of the sub-group.
576
+ }];
577
+
578
+ let arguments = (ins);
579
+ let results = (outs I32:$result);
580
+ let assemblyFormat = [{
581
+ attr-dict `:` functional-type(operands, results)
582
+ }];
583
+ }
584
+
585
+ def SYCLSubGroupLocalIDOp : SYCL_Op<"sub_group_local_id"> {
586
+ let summary = "Retrieve the local ID of the sub-group.";
587
+ let description = [{
588
+ This operation returns the local ID of the sub-group.
589
+ }];
590
+
591
+ let arguments = (ins);
592
+ let results = (outs I32:$result);
593
+ let assemblyFormat = [{
594
+ attr-dict `:` functional-type(operands, results)
595
+ }];
596
+ }
597
+
420
598
////////////////////////////////////////////////////////////////////////////////
421
599
// CONSTRUCTOR OPERATION
422
600
////////////////////////////////////////////////////////////////////////////////
0 commit comments