libocca / occa

Portable and vendor neutral framework for parallel programming on heterogeneous platforms.
https://libocca.org
MIT License
382 stars 81 forks source link

Initial support for compiler attribute statements #729

Closed noelchalmers closed 6 months ago

noelchalmers commented 6 months ago

Description

This added a generic ability of the OCCA parser to allow qualifier_t tokens to take arguments, and adds the __attribute__ keyword as a qualifier. Consequently, some initial __attribute__ and dllexport__ statements should be possible.

This is useful when using some backend-specific compiler attributes on variables/functions, e.g.

@kernel
__attribute__((amdgpu_waves_per_eu(1,1)))
void myKernel(...)

or when needing specific variable traits, e.g. with AMD GPUs and MFMA instructions:

for(int l=0;l<64;++l;@inner(0)){
  __attribute__((__vector_size__(4 * 8))) double C = {0.};

  ...

  // C = A*B
  C = __builtin_amdgcn_mfma_f64_16x16x4f64(A, B, C, 0, 0, 0);
}
codecov[bot] commented 6 months ago

Codecov Report

Merging #729 (4b9dd4d) into development (c17644b) will decrease coverage by 0.28%. The diff coverage is 32.11%.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/libocca/occa/pull/729/graphs/tree.svg?width=650&height=150&src=pr&token=doaG4c84wZ&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libocca)](https://app.codecov.io/gh/libocca/occa/pull/729?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libocca) ```diff @@ Coverage Diff @@ ## development #729 +/- ## =============================================== - Coverage 75.24% 74.97% -0.28% =============================================== Files 298 298 Lines 19397 19487 +90 =============================================== + Hits 14595 14610 +15 - Misses 4802 4877 +75 ``` | [Files](https://app.codecov.io/gh/libocca/occa/pull/729?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libocca) | Coverage Δ | | |---|---|---| | [src/occa/internal/lang/keyword.cpp](https://app.codecov.io/gh/libocca/occa/pull/729?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libocca#diff-c3JjL29jY2EvaW50ZXJuYWwvbGFuZy9rZXl3b3JkLmNwcA==) | `82.19% <100.00%> (+0.18%)` | :arrow_up: | | [src/occa/internal/lang/modes/okl.cpp](https://app.codecov.io/gh/libocca/occa/pull/729?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libocca#diff-c3JjL29jY2EvaW50ZXJuYWwvbGFuZy9tb2Rlcy9va2wuY3Bw) | `93.67% <100.00%> (ø)` | | | [src/occa/internal/lang/qualifier.hpp](https://app.codecov.io/gh/libocca/occa/pull/729?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libocca#diff-c3JjL29jY2EvaW50ZXJuYWwvbGFuZy9xdWFsaWZpZXIuaHBw) | `100.00% <ø> (ø)` | | | [src/occa/internal/lang/type/vartype.cpp](https://app.codecov.io/gh/libocca/occa/pull/729?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libocca#diff-c3JjL29jY2EvaW50ZXJuYWwvbGFuZy90eXBlL3ZhcnR5cGUuY3Bw) | `83.20% <0.00%> (-1.33%)` | :arrow_down: | | [src/occa/internal/lang/variable.cpp](https://app.codecov.io/gh/libocca/occa/pull/729?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libocca#diff-c3JjL29jY2EvaW50ZXJuYWwvbGFuZy92YXJpYWJsZS5jcHA=) | `69.76% <0.00%> (-1.67%)` | :arrow_down: | | [src/occa/internal/lang/loaders/typeLoader.cpp](https://app.codecov.io/gh/libocca/occa/pull/729?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libocca#diff-c3JjL29jY2EvaW50ZXJuYWwvbGFuZy9sb2FkZXJzL3R5cGVMb2FkZXIuY3Bw) | `71.55% <39.39%> (-7.45%)` | :arrow_down: | | [src/occa/internal/lang/qualifier.cpp](https://app.codecov.io/gh/libocca/occa/pull/729?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libocca#diff-c3JjL29jY2EvaW50ZXJuYWwvbGFuZy9xdWFsaWZpZXIuY3Bw) | `61.72% <29.23%> (-22.28%)` | :arrow_down: | ... and [2 files with indirect coverage changes](https://app.codecov.io/gh/libocca/occa/pull/729/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libocca)