-
Notifications
You must be signed in to change notification settings - Fork 756
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement work_group_static / work_group_scratch_memory (#15061)
The patch partially implements `work_group_static` and update proposal. Implemented: - `work_group_static` to handle static allocation in kernel. - `get_dynamic_work_group_memory` to handle runtime allocation, but only on CUDA `work_group_static` is implemented by exposing `SYCLScope(WorkGroup)`, allowing the class to be decorated by the attribute and uses the same mechanism during lowering to place the variable in local memory. `get_dynamic_work_group_memory` uses a new builtin function, `__sycl_dynamicLocalMemoryPlaceholder `, which is lowered into referencing a 0 sized array GV when targeting NVPTX. The approach for SPIR will need to differ from this lowering. UR change oneapi-src/unified-runtime#1968, oneapi-src/unified-runtime#2403 --------- Signed-off-by: Lukas Sommer <[email protected]> Signed-off-by: Victor Lomuller <[email protected]> Co-authored-by: Lukas Sommer <[email protected]> Co-authored-by: Atharva Dubey <[email protected]> Co-authored-by: Marcos Maronas <[email protected]> Co-authored-by: Callum Fare <[email protected]> Co-authored-by: Martin Morrison-Grant <[email protected]>
- Loading branch information
1 parent
141b054
commit 54d534f
Showing
65 changed files
with
1,809 additions
and
381 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// Verify the use of wg_scope is correctly diagnosed. | ||
// RUN: %clang_cc1 -fsycl-is-device -verify %s | ||
|
||
class [[__sycl_detail__::wg_scope]] G1 {}; | ||
class [[__sycl_detail__::wg_scope]] G2 { | ||
G2() = default; | ||
G2(int i) : i(i) {} | ||
int i; | ||
}; | ||
|
||
class [[__sycl_detail__::wg_scope]] G3 { | ||
~G3() = default; | ||
}; | ||
|
||
class [[__sycl_detail__::wg_scope]] B4 { // expected-error {{SYCL work group scope only applies to class with a trivial default constructor}} | ||
B4() {} | ||
}; | ||
|
||
class [[__sycl_detail__::wg_scope]] B5 { // expected-error {{SYCL work group scope only applies to class with a trivial destructor}} | ||
~B5() {} | ||
}; | ||
|
||
class [[__sycl_detail__::wg_scope]] B6 { // expected-error {{SYCL work group scope only applies to class with a trivial default constructor}} | ||
B6() {} | ||
~B6() {} | ||
}; | ||
|
||
template <typename T> class [[__sycl_detail__::wg_scope]] B7 { // #B7 | ||
public: | ||
T obj; | ||
}; | ||
|
||
struct Valid {}; | ||
struct InvalidCtor { | ||
InvalidCtor() {} | ||
}; | ||
struct InvalidDtor { | ||
~InvalidDtor() {} | ||
}; | ||
struct InvalidCDtor { | ||
InvalidCDtor() {} | ||
~InvalidCDtor() {} | ||
}; | ||
|
||
B7<Valid> b7; | ||
// expected-error@#B7 {{SYCL work group scope only applies to class with a trivial default constructor}} | ||
// expected-note@+1 {{in instantiation of template class 'B7<InvalidCtor>' requested here}} | ||
B7<InvalidCtor> b9; | ||
// expected-error@#B7 {{SYCL work group scope only applies to class with a trivial destructor}} | ||
// expected-note@+1 {{in instantiation of template class 'B7<InvalidDtor>' requested here}} | ||
B7<InvalidDtor> b10; | ||
// expected-error@#B7 {{SYCL work group scope only applies to class with a trivial default constructor}} | ||
// expected-note@+1 {{in instantiation of template class 'B7<InvalidCDtor>' requested here}} | ||
B7<InvalidCDtor> b11; | ||
|
||
template <typename T> class [[__sycl_detail__::wg_scope]] B12 { // #B12 | ||
public: | ||
B12() = default; | ||
~B12() = default; | ||
T obj; | ||
}; | ||
|
||
B12<Valid> b12; | ||
// expected-error@#B12 {{SYCL work group scope only applies to class with a trivial default constructor}} | ||
// expected-note@+1 {{in instantiation of template class 'B12<InvalidCtor>' requested here}} | ||
B12<InvalidCtor> b13; | ||
|
||
class B14 { | ||
G1 field; // expected-error {{non-static data member is of a type with a SYCL work group scope attribute applied to it}} | ||
}; | ||
|
||
template <typename T> class B15 { | ||
T field; // #B15-field | ||
}; | ||
|
||
// expected-error@#B15-field {{non-static data member is of a type with a SYCL work group scope attribute applied to it}} | ||
// expected-note@+1 {{in instantiation of template class 'B15<G1>' requested here}} | ||
B15<G1> b15; | ||
|
||
G1 g16; | ||
static G1 g17; | ||
|
||
struct Wrap { | ||
static G1 g18; | ||
}; | ||
|
||
__attribute__((sycl_device)) void ref_func() { | ||
G1 g19; | ||
static G1 g20; | ||
|
||
(void)g16; | ||
(void)g17; | ||
(void)Wrap::g18; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.