Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C++] Introduce portable compiler assumptions #41020

Closed
felipecrv opened this issue Apr 5, 2024 · 1 comment
Closed

[C++] Introduce portable compiler assumptions #41020

felipecrv opened this issue Apr 5, 2024 · 1 comment

Comments

@felipecrv
Copy link
Contributor

Describe the enhancement requested

Compiler assumptions (standardized in C++23) [1] are supported in today's compilers via macros.

When used well they can hint the optimizer in ways that can improve performance, but more importantly, reduce binary-size in compute kernel loops that have to be specialized for many different types [2]

Like other features compiler features, this could become usable via a macro in macros.h.

[1] https://en.cppreference.com/w/cpp/language/attributes/assume
[2] While working on a refactoring of Take I was able to shave-off ~13Kbytes off compute/kernels/vector_selection_take_internal.cc.o on macOS.

Component(s)

C++

felipecrv added a commit that referenced this issue Apr 9, 2024
### Rationale for this change

Allow portable use of the "assumption" feature of modern GCC, Clang, and MSVC compilers.

### What changes are included in this PR?

 - Documenting of macros in `macros.h`
 - Addition of `ARROW_COMPILER_ASSUME`
 - One simple change where this macro simplifies the existing code while keeping the common case of a loop branch dependent only on local variables
 
### Are these changes tested?

By existing tests.
* GitHub Issue: #41020

Authored-by: Felipe Oliveira Carvalho <felipekde@gmail.com>
Signed-off-by: Felipe Oliveira Carvalho <felipekde@gmail.com>
@felipecrv felipecrv added this to the 17.0.0 milestone Apr 9, 2024
@felipecrv
Copy link
Contributor Author

Issue resolved by pull request 41021
#41021

verma-kartik pushed a commit to verma-kartik/arrow that referenced this issue Apr 11, 2024
…#41021)

### Rationale for this change

Allow portable use of the "assumption" feature of modern GCC, Clang, and MSVC compilers.

### What changes are included in this PR?

 - Documenting of macros in `macros.h`
 - Addition of `ARROW_COMPILER_ASSUME`
 - One simple change where this macro simplifies the existing code while keeping the common case of a loop branch dependent only on local variables
 
### Are these changes tested?

By existing tests.
* GitHub Issue: apache#41020

Authored-by: Felipe Oliveira Carvalho <felipekde@gmail.com>
Signed-off-by: Felipe Oliveira Carvalho <felipekde@gmail.com>
vibhatha pushed a commit to vibhatha/arrow that referenced this issue Apr 15, 2024
…#41021)

### Rationale for this change

Allow portable use of the "assumption" feature of modern GCC, Clang, and MSVC compilers.

### What changes are included in this PR?

 - Documenting of macros in `macros.h`
 - Addition of `ARROW_COMPILER_ASSUME`
 - One simple change where this macro simplifies the existing code while keeping the common case of a loop branch dependent only on local variables
 
### Are these changes tested?

By existing tests.
* GitHub Issue: apache#41020

Authored-by: Felipe Oliveira Carvalho <felipekde@gmail.com>
Signed-off-by: Felipe Oliveira Carvalho <felipekde@gmail.com>
tolleybot pushed a commit to tmct/arrow that referenced this issue May 2, 2024
…#41021)

### Rationale for this change

Allow portable use of the "assumption" feature of modern GCC, Clang, and MSVC compilers.

### What changes are included in this PR?

 - Documenting of macros in `macros.h`
 - Addition of `ARROW_COMPILER_ASSUME`
 - One simple change where this macro simplifies the existing code while keeping the common case of a loop branch dependent only on local variables
 
### Are these changes tested?

By existing tests.
* GitHub Issue: apache#41020

Authored-by: Felipe Oliveira Carvalho <felipekde@gmail.com>
Signed-off-by: Felipe Oliveira Carvalho <felipekde@gmail.com>
tolleybot pushed a commit to tmct/arrow that referenced this issue May 4, 2024
…#41021)

### Rationale for this change

Allow portable use of the "assumption" feature of modern GCC, Clang, and MSVC compilers.

### What changes are included in this PR?

 - Documenting of macros in `macros.h`
 - Addition of `ARROW_COMPILER_ASSUME`
 - One simple change where this macro simplifies the existing code while keeping the common case of a loop branch dependent only on local variables
 
### Are these changes tested?

By existing tests.
* GitHub Issue: apache#41020

Authored-by: Felipe Oliveira Carvalho <felipekde@gmail.com>
Signed-off-by: Felipe Oliveira Carvalho <felipekde@gmail.com>
rok pushed a commit to tmct/arrow that referenced this issue May 8, 2024
…#41021)

### Rationale for this change

Allow portable use of the "assumption" feature of modern GCC, Clang, and MSVC compilers.

### What changes are included in this PR?

 - Documenting of macros in `macros.h`
 - Addition of `ARROW_COMPILER_ASSUME`
 - One simple change where this macro simplifies the existing code while keeping the common case of a loop branch dependent only on local variables
 
### Are these changes tested?

By existing tests.
* GitHub Issue: apache#41020

Authored-by: Felipe Oliveira Carvalho <felipekde@gmail.com>
Signed-off-by: Felipe Oliveira Carvalho <felipekde@gmail.com>
rok pushed a commit to tmct/arrow that referenced this issue May 8, 2024
…#41021)

### Rationale for this change

Allow portable use of the "assumption" feature of modern GCC, Clang, and MSVC compilers.

### What changes are included in this PR?

 - Documenting of macros in `macros.h`
 - Addition of `ARROW_COMPILER_ASSUME`
 - One simple change where this macro simplifies the existing code while keeping the common case of a loop branch dependent only on local variables
 
### Are these changes tested?

By existing tests.
* GitHub Issue: apache#41020

Authored-by: Felipe Oliveira Carvalho <felipekde@gmail.com>
Signed-off-by: Felipe Oliveira Carvalho <felipekde@gmail.com>
vibhatha pushed a commit to vibhatha/arrow that referenced this issue May 25, 2024
…#41021)

### Rationale for this change

Allow portable use of the "assumption" feature of modern GCC, Clang, and MSVC compilers.

### What changes are included in this PR?

 - Documenting of macros in `macros.h`
 - Addition of `ARROW_COMPILER_ASSUME`
 - One simple change where this macro simplifies the existing code while keeping the common case of a loop branch dependent only on local variables
 
### Are these changes tested?

By existing tests.
* GitHub Issue: apache#41020

Authored-by: Felipe Oliveira Carvalho <felipekde@gmail.com>
Signed-off-by: Felipe Oliveira Carvalho <felipekde@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant