Gian Marco Iodice | 6c113ed | 2023-01-19 17:14:26 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2023 Arm Limited. |
| 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
| 24 | #ifndef COMPUTE_KERNEL_WRITER_SRC_CL_CLTILE_H |
| 25 | #define COMPUTE_KERNEL_WRITER_SRC_CL_CLTILE_H |
| 26 | |
Viet-Hoa Do | 0250fa6 | 2023-07-24 15:47:34 +0100 | [diff] [blame] | 27 | #include "src/ITile.h" |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame^] | 28 | |
Gian Marco Iodice | 6c113ed | 2023-01-19 17:14:26 +0000 | [diff] [blame] | 29 | #include <string> |
| 30 | |
| 31 | namespace ckw |
| 32 | { |
| 33 | // Forward declarations |
| 34 | class TileInfo; |
| 35 | |
| 36 | /** OpenCL specific tile */ |
Gunes Bayir | 5e84251 | 2023-07-25 22:32:05 +0100 | [diff] [blame] | 37 | class CLTile : public ITile, public IVectorAccess |
Gian Marco Iodice | 6c113ed | 2023-01-19 17:14:26 +0000 | [diff] [blame] | 38 | { |
| 39 | public: |
Viet-Hoa Do | 0250fa6 | 2023-07-24 15:47:34 +0100 | [diff] [blame] | 40 | /** Initialize a new instance of @ref CLTile class for variable tile. |
Gian Marco Iodice | 6c113ed | 2023-01-19 17:14:26 +0000 | [diff] [blame] | 41 | * |
| 42 | * @param[in] name Tile name |
| 43 | * @param[in] info Tile info |
| 44 | */ |
Nikolaj Jensen | acea407 | 2023-07-03 09:44:42 +0100 | [diff] [blame] | 45 | CLTile(const std::string &name, const TileInfo &info); |
Gian Marco Iodice | 6c113ed | 2023-01-19 17:14:26 +0000 | [diff] [blame] | 46 | |
Viet-Hoa Do | 0250fa6 | 2023-07-24 15:47:34 +0100 | [diff] [blame] | 47 | /** Initialize a new instane of @ref CLTile class for compile-time constant tile. |
| 48 | * |
| 49 | * @note A constant tile does not need a name since this object does not return variable's name but rather |
| 50 | * values stored as string type |
| 51 | * |
| 52 | * @param[in] vals The tile container with the constant values as std::string |
| 53 | * @param[in] dt Datatype of the values stored in the tile container |
| 54 | */ |
| 55 | CLTile(const TileContainer &vals, DataType dt); |
| 56 | |
Gian Marco Iodice | 6c113ed | 2023-01-19 17:14:26 +0000 | [diff] [blame] | 57 | // Inherited method overridden |
Viet-Hoa Do | 0250fa6 | 2023-07-24 15:47:34 +0100 | [diff] [blame] | 58 | const std::string &name() const override; |
| 59 | |
| 60 | const TileInfo &info() const override; |
| 61 | |
Viet-Hoa Do | 25d26f4 | 2023-07-20 17:31:47 +0100 | [diff] [blame] | 62 | TileVariable scalar(int32_t row, int32_t col) const override; |
Nikolaj Jensen | acea407 | 2023-07-03 09:44:42 +0100 | [diff] [blame] | 63 | |
Viet-Hoa Do | 25d26f4 | 2023-07-20 17:31:47 +0100 | [diff] [blame] | 64 | TileVariable vector(int32_t row) const override; |
Nikolaj Jensen | acea407 | 2023-07-03 09:44:42 +0100 | [diff] [blame] | 65 | |
Viet-Hoa Do | 25d26f4 | 2023-07-20 17:31:47 +0100 | [diff] [blame] | 66 | TileVariable vector(int32_t row, int32_t col_start, int32_t width) const override; |
Nikolaj Jensen | acea407 | 2023-07-03 09:44:42 +0100 | [diff] [blame] | 67 | |
Gian Marco Iodice | 6c113ed | 2023-01-19 17:14:26 +0000 | [diff] [blame] | 68 | std::vector<TileVariable> all() const override; |
Nikolaj Jensen | acea407 | 2023-07-03 09:44:42 +0100 | [diff] [blame] | 69 | |
Viet-Hoa Do | 25d26f4 | 2023-07-20 17:31:47 +0100 | [diff] [blame] | 70 | bool is_assignable() const override; |
Gian Marco Iodice | 6c113ed | 2023-01-19 17:14:26 +0000 | [diff] [blame] | 71 | |
Viet-Hoa Do | 0250fa6 | 2023-07-24 15:47:34 +0100 | [diff] [blame] | 72 | std::vector<int32_t> supported_vector_lengths() const override; |
| 73 | |
Gian Marco Iodice | 6c113ed | 2023-01-19 17:14:26 +0000 | [diff] [blame] | 74 | private: |
Viet-Hoa Do | 0250fa6 | 2023-07-24 15:47:34 +0100 | [diff] [blame] | 75 | void validate_tile_info(const TileInfo &info) const; |
| 76 | |
Gian Marco Iodice | 6c113ed | 2023-01-19 17:14:26 +0000 | [diff] [blame] | 77 | std::string create_var_name(int32_t row) const; |
Viet-Hoa Do | 0250fa6 | 2023-07-24 15:47:34 +0100 | [diff] [blame] | 78 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame^] | 79 | TileInfo _info{DataType::Unknown}; |
| 80 | std::string _basename{""}; |
| 81 | bool _is_constant{false}; |
Viet-Hoa Do | 0250fa6 | 2023-07-24 15:47:34 +0100 | [diff] [blame] | 82 | TileContainer _vals{}; |
Gian Marco Iodice | 6c113ed | 2023-01-19 17:14:26 +0000 | [diff] [blame] | 83 | }; |
| 84 | } // namespace ckw |
| 85 | |
| 86 | #endif /* COMPUTE_KERNEL_WRITER_SRC_CL_CLTILE_H */ |