Path: blob/21.2-virgl/src/gallium/frontends/clover/core/program.hpp
4572 views
//1// Copyright 2012 Francisco Jerez2//3// Permission is hereby granted, free of charge, to any person obtaining a4// copy of this software and associated documentation files (the "Software"),5// to deal in the Software without restriction, including without limitation6// the rights to use, copy, modify, merge, publish, distribute, sublicense,7// and/or sell copies of the Software, and to permit persons to whom the8// Software is furnished to do so, subject to the following conditions:9//10// The above copyright notice and this permission notice shall be included in11// all copies or substantial portions of the Software.12//13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL16// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR17// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,18// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR19// OTHER DEALINGS IN THE SOFTWARE.20//2122#ifndef CLOVER_CORE_PROGRAM_HPP23#define CLOVER_CORE_PROGRAM_HPP2425#include <map>2627#include "core/object.hpp"28#include "core/context.hpp"29#include "core/module.hpp"3031namespace clover {32typedef std::vector<std::pair<std::string, std::string>> header_map;3334class program : public ref_counter, public _cl_program {35private:36typedef adaptor_range<37evals, const std::vector<intrusive_ref<device>> &> device_range;3839public:40enum class il_type { none, source, spirv };4142program(clover::context &ctx,43std::string &&il,44enum il_type il_type);45program(clover::context &ctx,46const ref_vector<device> &devs = {},47const std::vector<module> &binaries = {});4849program(const program &prog) = delete;50program &51operator=(const program &prog) = delete;5253void compile(const ref_vector<device> &devs, const std::string &opts,54const header_map &headers = {});55void link(const ref_vector<device> &devs, const std::string &opts,56const ref_vector<program> &progs);5758const std::string &source() const;59enum il_type il_type() const;6061device_range devices() const;6263struct build {64build(const module &m = {}, const std::string &opts = {},65const std::string &log = {}) : binary(m), opts(opts), log(log) {}6667cl_build_status status() const;68cl_program_binary_type binary_type() const;6970module binary;71std::string opts;72std::string log;73};7475const build &build(const device &dev) const;7677const std::vector<module::symbol> &symbols() const;7879unsigned kernel_ref_count() const;8081const intrusive_ref<clover::context> context;8283friend class kernel;8485private:86std::vector<intrusive_ref<device>> _devices;87std::map<const device *, struct build> _builds;88std::string _source;89ref_counter _kernel_ref_counter;90enum il_type _il_type;91};92}9394#endif959697