blob: 498cf51034a568f84d7bffd8fdc8047cdc696a97 [file] [log] [blame]
Gian Marco Iodice6c113ed2023-01-19 17:14:26 +00001/*
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 Do0250fa62023-07-24 15:47:34 +010027#include "src/ITile.h"
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010028
Gian Marco Iodice6c113ed2023-01-19 17:14:26 +000029#include <string>
30
31namespace ckw
32{
33// Forward declarations
34class TileInfo;
35
36/** OpenCL specific tile */
Gunes Bayir5e842512023-07-25 22:32:05 +010037class CLTile : public ITile, public IVectorAccess
Gian Marco Iodice6c113ed2023-01-19 17:14:26 +000038{
39public:
Viet-Hoa Do0250fa62023-07-24 15:47:34 +010040 /** Initialize a new instance of @ref CLTile class for variable tile.
Gian Marco Iodice6c113ed2023-01-19 17:14:26 +000041 *
42 * @param[in] name Tile name
43 * @param[in] info Tile info
44 */
Nikolaj Jensenacea4072023-07-03 09:44:42 +010045 CLTile(const std::string &name, const TileInfo &info);
Gian Marco Iodice6c113ed2023-01-19 17:14:26 +000046
Viet-Hoa Do0250fa62023-07-24 15:47:34 +010047 /** 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 Iodice6c113ed2023-01-19 17:14:26 +000057 // Inherited method overridden
Viet-Hoa Do0250fa62023-07-24 15:47:34 +010058 const std::string &name() const override;
59
60 const TileInfo &info() const override;
61
Viet-Hoa Do25d26f42023-07-20 17:31:47 +010062 TileVariable scalar(int32_t row, int32_t col) const override;
Nikolaj Jensenacea4072023-07-03 09:44:42 +010063
Viet-Hoa Do25d26f42023-07-20 17:31:47 +010064 TileVariable vector(int32_t row) const override;
Nikolaj Jensenacea4072023-07-03 09:44:42 +010065
Viet-Hoa Do25d26f42023-07-20 17:31:47 +010066 TileVariable vector(int32_t row, int32_t col_start, int32_t width) const override;
Nikolaj Jensenacea4072023-07-03 09:44:42 +010067
Gian Marco Iodice6c113ed2023-01-19 17:14:26 +000068 std::vector<TileVariable> all() const override;
Nikolaj Jensenacea4072023-07-03 09:44:42 +010069
Viet-Hoa Do25d26f42023-07-20 17:31:47 +010070 bool is_assignable() const override;
Gian Marco Iodice6c113ed2023-01-19 17:14:26 +000071
Viet-Hoa Do0250fa62023-07-24 15:47:34 +010072 std::vector<int32_t> supported_vector_lengths() const override;
73
Gian Marco Iodice6c113ed2023-01-19 17:14:26 +000074private:
Viet-Hoa Do0250fa62023-07-24 15:47:34 +010075 void validate_tile_info(const TileInfo &info) const;
76
Gian Marco Iodice6c113ed2023-01-19 17:14:26 +000077 std::string create_var_name(int32_t row) const;
Viet-Hoa Do0250fa62023-07-24 15:47:34 +010078
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010079 TileInfo _info{DataType::Unknown};
80 std::string _basename{""};
81 bool _is_constant{false};
Viet-Hoa Do0250fa62023-07-24 15:47:34 +010082 TileContainer _vals{};
Gian Marco Iodice6c113ed2023-01-19 17:14:26 +000083};
84} // namespace ckw
85
86#endif /* COMPUTE_KERNEL_WRITER_SRC_CL_CLTILE_H */