blob: bddb86c0e4c9c3acab1e2de94b3a5ccd5fbb89c0 [file] [log] [blame]
Francisco Jerezc6db1b32012-04-20 16:56:19 +02001//
2// Copyright 2012 Francisco Jerez
3//
4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation
7// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8// and/or sell copies of the Software, and to permit persons to whom the
9// Software is furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
Kenneth Graunkef0cb66b2013-04-21 13:52:08 -070017// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20// OTHER DEALINGS IN THE SOFTWARE.
Francisco Jerezc6db1b32012-04-20 16:56:19 +020021//
22
Francisco Jerez099d2812013-09-15 15:29:34 -070023#ifndef CLOVER_CORE_QUEUE_HPP
24#define CLOVER_CORE_QUEUE_HPP
Francisco Jerezc6db1b32012-04-20 16:56:19 +020025
Francisco Jerez6db10252013-09-15 23:04:28 -070026#include <deque>
Tom Stellardf5469022015-05-07 13:57:14 +000027#include <mutex>
Francisco Jerez6db10252013-09-15 23:04:28 -070028
Francisco Jerezbff60c82013-10-06 13:51:01 -070029#include "core/object.hpp"
Francisco Jerezc6db1b32012-04-20 16:56:19 +020030#include "core/context.hpp"
Francisco Jerezebfdce02013-10-06 13:48:23 -070031#include "core/timestamp.hpp"
Francisco Jerezc6db1b32012-04-20 16:56:19 +020032#include "pipe/p_context.h"
33
34namespace clover {
Francisco Jerezc6db1b32012-04-20 16:56:19 +020035 class resource;
36 class mapping;
37 class hard_event;
Francisco Jerez9968d9d2013-10-01 11:57:32 -070038
39 class command_queue : public ref_counter, public _cl_command_queue {
40 public:
Francisco Jerezc4578d22014-02-18 15:07:11 +010041 command_queue(clover::context &ctx, clover::device &dev,
Francisco Jerez9968d9d2013-10-01 11:57:32 -070042 cl_command_queue_properties props);
Francisco Jerez9968d9d2013-10-01 11:57:32 -070043 ~command_queue();
44
Francisco Jerez5226eac2013-09-16 21:44:36 -070045 command_queue(const command_queue &q) = delete;
46 command_queue &
47 operator=(const command_queue &q) = delete;
48
Francisco Jerez9968d9d2013-10-01 11:57:32 -070049 void flush();
50
Francisco Jerez9b2fe7c2014-02-18 13:12:52 +010051 cl_command_queue_properties properties() const;
Francisco Jerez9968d9d2013-10-01 11:57:32 -070052 bool profiling_enabled() const;
53
Francisco Jerezc4578d22014-02-18 15:07:11 +010054 const intrusive_ref<clover::context> context;
55 const intrusive_ref<clover::device> device;
Francisco Jerez9968d9d2013-10-01 11:57:32 -070056
57 friend class resource;
58 friend class root_resource;
59 friend class mapping;
60 friend class hard_event;
Francisco Jerez04d0ab92013-09-15 22:20:43 -070061 friend class sampler;
Francisco Jerez35307f52013-09-17 23:20:11 -070062 friend class kernel;
Francisco Jerez9968d9d2013-10-01 11:57:32 -070063 friend class clover::timestamp::query;
64 friend class clover::timestamp::current;
65
66 private:
67 /// Serialize a hardware event with respect to the previous ones,
68 /// and push it to the pending list.
Francisco Jerezc4578d22014-02-18 15:07:11 +010069 void sequence(hard_event &ev);
Francisco Jerez9968d9d2013-10-01 11:57:32 -070070
Francisco Jerez9b2fe7c2014-02-18 13:12:52 +010071 cl_command_queue_properties props;
Francisco Jerez9968d9d2013-10-01 11:57:32 -070072 pipe_context *pipe;
Tom Stellardf5469022015-05-07 13:57:14 +000073 std::mutex queued_events_mutex;
Francisco Jerezc4578d22014-02-18 15:07:11 +010074 std::deque<intrusive_ref<hard_event>> queued_events;
Francisco Jerez9968d9d2013-10-01 11:57:32 -070075 };
Francisco Jerezc6db1b32012-04-20 16:56:19 +020076}
77
Francisco Jerezc6db1b32012-04-20 16:56:19 +020078#endif