From f0c925086d4cd90fef890e19224b3f4b07369f73 Mon Sep 17 00:00:00 2001 From: subtly Date: Thu, 9 Jul 2015 19:27:05 -0700 Subject: [PATCH 01/62] Fixes for #2337, #2349, #2288, #2333, #1398. --- libdevcore/Worker.cpp | 12 +++--- libp2p/Common.h | 38 +++++++++++++++++ libp2p/Host.cpp | 70 +++++++++++++++---------------- libp2p/NodeTable.cpp | 98 ++++++++++++++++--------------------------- libp2p/NodeTable.h | 26 ++++-------- test/libp2p/net.cpp | 29 +++++-------- 6 files changed, 136 insertions(+), 137 deletions(-) diff --git a/libdevcore/Worker.cpp b/libdevcore/Worker.cpp index d47955753..4c64eaa31 100644 --- a/libdevcore/Worker.cpp +++ b/libdevcore/Worker.cpp @@ -50,11 +50,13 @@ void Worker::startWorking() // cnote << "Trying to set Started: Thread was" << (unsigned)ex << "; " << ok; (void)ok; - startedWorking(); -// cnote << "Entering work loop..."; - workLoop(); -// cnote << "Finishing up worker thread..."; - doneWorking(); + try + { + startedWorking(); + workLoop(); + doneWorking(); + } + catch (...) {} // ex = WorkerState::Stopping; // m_state.compare_exchange_strong(ex, WorkerState::Stopped); diff --git a/libp2p/Common.h b/libp2p/Common.h index c124115f9..7c9950b39 100644 --- a/libp2p/Common.h +++ b/libp2p/Common.h @@ -37,6 +37,7 @@ #include #include #include +#include namespace ba = boost::asio; namespace bi = boost::asio::ip; @@ -214,6 +215,43 @@ struct Node virtual operator bool() const { return (bool)id; } }; +class DeadlineOp +{ +public: + DeadlineOp(ba::io_service& _io, unsigned _msInFuture, std::function const& _f): m_timer(new ba::deadline_timer(_io)) { m_timer->expires_from_now(boost::posix_time::milliseconds(_msInFuture)); m_timer->async_wait(_f); } + DeadlineOp(DeadlineOp&& _s): m_timer(_s.m_timer.release()) {} + DeadlineOp& operator=(DeadlineOp&& _s) { m_timer.reset(_s.m_timer.release()); return *this; } + + bool expired() { return m_timer->expires_from_now().total_milliseconds() <= 0; } + void cancel() { m_timer->cancel(); } + +private: + std::unique_ptr m_timer; +}; + +class DeadlineOps +{ +public: + DeadlineOps(ba::io_service& _io, unsigned _reapIntervalMs = 100): m_io(_io), m_reapIntervalMs(_reapIntervalMs), m_stopped({false}) { reap(); } + ~DeadlineOps() { m_stopped = true; } + + void schedule(unsigned _msInFuture, std::function const& _f) { if (m_stopped) return; DEV_GUARDED(x_timers) m_timers.emplace_back(m_io, _msInFuture, _f); } + + void stop() { m_stopped = true; DEV_GUARDED(x_timers) m_timers.clear(); } + +protected: + void reap() { DEV_GUARDED(x_timers) { auto t = m_timers.begin(); while (t != m_timers.end()) if (t->expired()) m_timers.erase(t); else t++; } schedule(m_reapIntervalMs, [this](boost::system::error_code const& ec){ if (!ec) reap(); }); } + +private: + ba::io_service& m_io; + unsigned m_reapIntervalMs; + + std::vector m_timers; + Mutex x_timers; + + std::atomic m_stopped; +}; + } /// Simple stream output for a NodeIPEndpoint. diff --git a/libp2p/Host.cpp b/libp2p/Host.cpp index f033298ef..8482f254a 100644 --- a/libp2p/Host.cpp +++ b/libp2p/Host.cpp @@ -120,6 +120,15 @@ Host::~Host() void Host::start() { startWorking(); + while (isWorking() && !haveNetwork()) + this_thread::sleep_for(chrono::milliseconds(10)); + + // network start failed! + if (isWorking()) + return; + + clog(NetWarn) << "Network start failed!"; + doneWorking(); } void Host::stop() @@ -130,11 +139,12 @@ void Host::stop() { // Although m_run is set by stop() or start(), it effects m_runTimer so x_runTimer is used instead of a mutex for m_run. - // when m_run == false, run() will cause this::run() to stop() ioservice Guard l(x_runTimer); // ignore if already stopped/stopping if (!m_run) return; + + // signal run() to prepare for shutdown and reset m_timer m_run = false; } @@ -143,14 +153,18 @@ void Host::stop() this_thread::sleep_for(chrono::milliseconds(50)); // stop worker thread - stopWorking(); + if (isWorking()) + stopWorking(); } void Host::doneWorking() { - // reset ioservice (allows manually polling network, below) + // reset ioservice (cancels all timers and allows manually polling network, below) m_ioService.reset(); + DEV_GUARDED(x_timers) + m_timers.clear(); + // shutdown acceptor m_tcp4Acceptor.cancel(); if (m_tcp4Acceptor.is_open()) @@ -170,15 +184,13 @@ void Host::doneWorking() // disconnect pending handshake, before peers, as a handshake may create a peer for (unsigned n = 0;; n = 0) { - { - Guard l(x_connecting); + DEV_GUARDED(x_connecting) for (auto i: m_connecting) if (auto h = i.lock()) { h->cancel(); n++; } - } if (!n) break; m_ioService.poll(); @@ -187,8 +199,7 @@ void Host::doneWorking() // disconnect peers for (unsigned n = 0;; n = 0) { - { - RecursiveGuard l(x_sessions); + DEV_RECURSIVE_GUARDED(x_sessions) for (auto i: m_sessions) if (auto p = i.second.lock()) if (p->isConnected()) @@ -196,7 +207,6 @@ void Host::doneWorking() p->disconnect(ClientQuit); n++; } - } if (!n) break; @@ -465,6 +475,9 @@ void Host::addNode(NodeId const& _node, NodeIPEndpoint const& _endpoint) void Host::requirePeer(NodeId const& _n, NodeIPEndpoint const& _endpoint) { + if (!m_run) + return; + Node node(_n, _endpoint, true); if (_n) { @@ -482,22 +495,21 @@ void Host::requirePeer(NodeId const& _n, NodeIPEndpoint const& _endpoint) p.reset(new Peer(node)); m_peers[_n] = p; } - connect(p); } else if (m_nodeTable) { - shared_ptr t(new boost::asio::deadline_timer(m_ioService)); - m_timers.push_back(t); - m_nodeTable->addNode(node); + shared_ptr t(new boost::asio::deadline_timer(m_ioService)); t->expires_from_now(boost::posix_time::milliseconds(600)); t->async_wait([this, _n](boost::system::error_code const& _ec) { - if (!_ec && m_nodeTable) - // FIXME RACE CONDITION (use weak_ptr or mutex). - if (auto n = m_nodeTable->node(_n)) - requirePeer(n.id, n.endpoint); + if (!_ec) + if (m_nodeTable) + if (auto n = m_nodeTable->node(_n)) + requirePeer(n.id, n.endpoint); }); + DEV_GUARDED(x_timers) + m_timers.push_back(t); } } @@ -512,8 +524,6 @@ void Host::connect(std::shared_ptr const& _p) { if (!m_run) return; - - _p->m_lastAttempted = std::chrono::system_clock::now(); if (havePeerSession(_p->id)) { @@ -539,6 +549,8 @@ void Host::connect(std::shared_ptr const& _p) m_pendingPeerConns.insert(nptr); } + _p->m_lastAttempted = std::chrono::system_clock::now(); + bi::tcp::endpoint ep(_p->endpoint); clog(NetConnect) << "Attempting connection to node" << _p->id << "@" << ep << "from" << id(); auto socket = make_shared(new bi::tcp::socket(m_ioService)); @@ -615,21 +627,13 @@ void Host::run(boost::system::error_code const&) m_nodeTable->processEvents(); // cleanup zombies - { - Guard l(x_connecting); - m_connecting.remove_if([](std::weak_ptr h){ return h.lock(); }); - } - { - Guard l(x_timers); + DEV_GUARDED(x_connecting); + m_connecting.remove_if([](std::weak_ptr h){ return h.expired(); }); + DEV_GUARDED(x_timers) m_timers.remove_if([](std::shared_ptr t) { - return t->expires_from_now().total_milliseconds() > 0; + return t->expires_from_now().total_milliseconds() < 0; }); - } - - for (auto p: m_sessions) - if (auto pp = p.second.lock()) - pp->serviceNodesRequest(); keepAlivePeers(); @@ -666,13 +670,9 @@ void Host::run(boost::system::error_code const&) pendingCount = m_pendingPeerConns.size(); int openSlots = m_idealPeerCount - peerCount() - pendingCount + reqConn; if (openSlots > 0) - { for (auto p: toConnect) if (!p->required && openSlots--) connect(p); - - m_nodeTable->discover(); - } } auto runcb = [this](boost::system::error_code const& error) { run(error); }; diff --git a/libp2p/NodeTable.cpp b/libp2p/NodeTable.cpp index 1a0b11734..389546605 100644 --- a/libp2p/NodeTable.cpp +++ b/libp2p/NodeTable.cpp @@ -43,33 +43,31 @@ NodeEntry::NodeEntry(NodeId const& _src, Public const& _pubk, NodeIPEndpoint con NodeTable::NodeTable(ba::io_service& _io, KeyPair const& _alias, NodeIPEndpoint const& _endpoint, bool _enabled): m_node(Node(_alias.pub(), _endpoint)), m_secret(_alias.sec()), - m_io(_io), - m_socket(new NodeSocket(m_io, *this, (bi::udp::endpoint)m_node.endpoint)), + m_socket(new NodeSocket(_io, *this, (bi::udp::endpoint)m_node.endpoint)), m_socketPointer(m_socket.get()), - m_bucketRefreshTimer(m_io), - m_evictionCheckTimer(m_io), - m_disabled(!_enabled) + m_timers(_io) { for (unsigned i = 0; i < s_bins; i++) - { m_state[i].distance = i; - m_state[i].modified = chrono::steady_clock::now() - chrono::seconds(1); - } - if (!m_disabled) + if (!_enabled) + return; + + try { m_socketPointer->connect(); - doRefreshBuckets(boost::system::error_code()); + doDiscovery(); + } + catch (std::exception const& _e) + { + clog(NetWarn) << "Exception connecting NodeTable socket: " << _e.what(); + clog(NetWarn) << "Discovery disabled."; } } NodeTable::~NodeTable() { - // Cancel scheduled tasks to ensure. - m_evictionCheckTimer.cancel(); - m_bucketRefreshTimer.cancel(); - - // Disconnect socket so that deallocation is safe. + m_timers.stop(); m_socketPointer->disconnect(); } @@ -117,16 +115,6 @@ shared_ptr NodeTable::addNode(Node const& _node, NodeRelation _relati return ret; } -void NodeTable::discover() -{ - static chrono::steady_clock::time_point s_lastDiscover = chrono::steady_clock::now() - std::chrono::seconds(30); - if (chrono::steady_clock::now() > s_lastDiscover + std::chrono::seconds(30)) - { - s_lastDiscover = chrono::steady_clock::now(); - discover(m_node.id); - } -} - list NodeTable::nodes() const { list nodes; @@ -164,8 +152,10 @@ shared_ptr NodeTable::nodeEntry(NodeId _id) return m_nodes.count(_id) ? m_nodes[_id] : shared_ptr(); } -void NodeTable::discover(NodeId _node, unsigned _round, shared_ptr>> _tried) +void NodeTable::doDiscover(NodeId _node, unsigned _round, shared_ptr>> _tried) { + // NOTE: ONLY called by doDiscovery! + if (!m_socketPointer->isOpen() || _round == s_maxSteps) return; @@ -195,6 +185,7 @@ void NodeTable::discover(NodeId _node, unsigned _round, shared_ptrinsert(tried.front()); tried.pop_front(); } - - auto self(shared_from_this()); - m_evictionCheckTimer.expires_from_now(boost::posix_time::milliseconds(c_reqTimeout.count() * 2)); - m_evictionCheckTimer.async_wait([this, self, _node, _round, _tried](boost::system::error_code const& _ec) + + m_timers.schedule(c_reqTimeout.count() * 2, [this, _node, _round, _tried](boost::system::error_code const& _ec) { - if (_ec) - return; - discover(_node, _round + 1, _tried); + if (!_ec) + doDiscover(_node, _round + 1, _tried); }); } @@ -310,15 +298,15 @@ void NodeTable::evict(shared_ptr _leastSeen, shared_ptr _n if (!m_socketPointer->isOpen()) return; - unsigned ec; + unsigned evicts; DEV_GUARDED(x_evictions) { m_evictions.push_back(EvictionTimeout(make_pair(_leastSeen->id,chrono::steady_clock::now()), _new->id)); - ec = m_evictions.size(); + evicts = m_evictions.size(); } - if (ec == 1) - doCheckEvictions(boost::system::error_code()); + if (evicts == 1) + doCheckEvictions(); ping(_leastSeen.get()); } @@ -354,8 +342,6 @@ void NodeTable::noteActiveNode(Public const& _pubk, bi::udp::endpoint const& _en { s.nodes.pop_front(); s.nodes.push_back(node); - s.touch(); - if (!removed && m_nodeEventHandler) m_nodeEventHandler->appendEvent(node->id, NodeEntryAdded); } @@ -363,8 +349,6 @@ void NodeTable::noteActiveNode(Public const& _pubk, bi::udp::endpoint const& _en else { s.nodes.push_back(node); - s.touch(); - if (!removed && m_nodeEventHandler) m_nodeEventHandler->appendEvent(node->id, NodeEntryAdded); } @@ -576,14 +560,9 @@ void NodeTable::onReceived(UDPSocketFace*, bi::udp::endpoint const& _from, bytes } } -void NodeTable::doCheckEvictions(boost::system::error_code const& _ec) +void NodeTable::doCheckEvictions() { - if (_ec || !m_socketPointer->isOpen()) - return; - - auto self(shared_from_this()); - m_evictionCheckTimer.expires_from_now(c_evictionCheckInterval); - m_evictionCheckTimer.async_wait([this, self](boost::system::error_code const& _ec) + m_timers.schedule(c_evictionCheckInterval.count(), [this](boost::system::error_code const& _ec) { if (_ec) return; @@ -605,28 +584,23 @@ void NodeTable::doCheckEvictions(boost::system::error_code const& _ec) dropNode(n); if (evictionsRemain) - doCheckEvictions(boost::system::error_code()); + doCheckEvictions(); }); } -void NodeTable::doRefreshBuckets(boost::system::error_code const& _ec) +void NodeTable::doDiscovery() { - if (_ec) - return; - - clog(NodeTableEvent) << "refreshing buckets"; - bool connected = m_socketPointer->isOpen(); - if (connected) + m_timers.schedule(c_bucketRefresh.count(), [this](boost::system::error_code const& ec) { + if (ec) + return; + + clog(NodeTableEvent) << "performing random discovery"; NodeId randNodeId; crypto::Nonce::get().ref().copyTo(randNodeId.ref().cropped(0, h256::size)); crypto::Nonce::get().ref().copyTo(randNodeId.ref().cropped(h256::size, h256::size)); - discover(randNodeId); - } - - auto runcb = [this](boost::system::error_code const& error) { doRefreshBuckets(error); }; - m_bucketRefreshTimer.expires_from_now(boost::posix_time::milliseconds(c_bucketRefresh.count())); - m_bucketRefreshTimer.async_wait(runcb); + doDiscover(randNodeId); + }); } void PingNode::streamRLP(RLPStream& _s) const diff --git a/libp2p/NodeTable.h b/libp2p/NodeTable.h index d31a356ef..4d6b02d99 100644 --- a/libp2p/NodeTable.h +++ b/libp2p/NodeTable.h @@ -128,6 +128,7 @@ class NodeTable: UDPSocketEvents, public std::enable_shared_from_this public: enum NodeRelation { Unknown = 0, Known }; + enum DiscoverType { Random = 0 }; /// Constructor requiring host for I/O, credentials, and IP Address and port to listen on. NodeTable(ba::io_service& _io, KeyPair const& _alias, NodeIPEndpoint const& _endpoint, bool _enabled = true); @@ -145,9 +146,6 @@ public: /// Add node. Node will be pinged and empty shared_ptr is returned if node has never been seen or NodeId is empty. std::shared_ptr addNode(Node const& _node, NodeRelation _relation = NodeRelation::Unknown); - /// To be called when node table is empty. Runs node discovery with m_node.id as the target in order to populate node-table. - void discover(); - /// Returns list of node ids active in node table. std::list nodes() const; @@ -184,16 +182,14 @@ private: /// Intervals /* todo: replace boost::posix_time; change constants to upper camelcase */ - boost::posix_time::milliseconds const c_evictionCheckInterval = boost::posix_time::milliseconds(75); ///< Interval at which eviction timeouts are checked. + std::chrono::milliseconds const c_evictionCheckInterval = std::chrono::milliseconds(75); ///< Interval at which eviction timeouts are checked. std::chrono::milliseconds const c_reqTimeout = std::chrono::milliseconds(300); ///< How long to wait for requests (evict, find iterations). std::chrono::milliseconds const c_bucketRefresh = std::chrono::milliseconds(7200); ///< Refresh interval prevents bucket from becoming stale. [Kademlia] struct NodeBucket { unsigned distance; - TimePoint modified; std::list> nodes; - void touch() { modified = std::chrono::steady_clock::now(); } }; /// Used to ping endpoint. @@ -210,7 +206,7 @@ private: /// Used to discovery nodes on network which are close to the given target. /// Sends s_alpha concurrent requests to nodes nearest to target, for nodes nearest to target, up to s_maxSteps rounds. - void discover(NodeId _target, unsigned _round = 0, std::shared_ptr>> _tried = std::shared_ptr>>()); + void doDiscover(NodeId _target, unsigned _round = 0, std::shared_ptr>> _tried = std::shared_ptr>>()); /// Returns nodes from node table which are closest to target. std::vector> nearestNodeEntries(NodeId _target); @@ -240,10 +236,10 @@ private: /// Tasks /// Called by evict() to ensure eviction check is scheduled to run and terminates when no evictions remain. Asynchronous. - void doCheckEvictions(boost::system::error_code const& _ec); + void doCheckEvictions(); - /// Purges and pings nodes for any buckets which haven't been touched for c_bucketRefresh seconds. - void doRefreshBuckets(boost::system::error_code const& _ec); + /// Looks up a random node at @c_bucketRefresh interval. + void doDiscovery(); std::unique_ptr m_nodeEventHandler; ///< Event handler for node events. @@ -251,7 +247,7 @@ private: Secret m_secret; ///< This nodes secret key. mutable Mutex x_nodes; ///< LOCK x_state first if both locks are required. Mutable for thread-safe copy in nodes() const. - std::unordered_map> m_nodes; ///< Nodes + std::unordered_map> m_nodes; ///< Known Node Endpoints mutable Mutex x_state; ///< LOCK x_state first if both x_nodes and x_state locks are required. std::array m_state; ///< State of p2p node network. @@ -264,15 +260,11 @@ private: Mutex x_findNodeTimeout; std::list m_findNodeTimeout; ///< Timeouts for pending Ping and FindNode requests. - - ba::io_service& m_io; ///< Used by bucket refresh timer. + std::shared_ptr m_socket; ///< Shared pointer for our UDPSocket; ASIO requires shared_ptr. NodeSocket* m_socketPointer; ///< Set to m_socket.get(). Socket is created in constructor and disconnected in destructor to ensure access to pointer is safe. - boost::asio::deadline_timer m_bucketRefreshTimer; ///< Timer which schedules and enacts bucket refresh. - boost::asio::deadline_timer m_evictionCheckTimer; ///< Timer for handling node evictions. - - bool m_disabled; ///< Disable discovery. + DeadlineOps m_timers; }; inline std::ostream& operator<<(std::ostream& _out, NodeTable const& _nodeTable) diff --git a/test/libp2p/net.cpp b/test/libp2p/net.cpp index 1e3e2e15c..7603a6d41 100644 --- a/test/libp2p/net.cpp +++ b/test/libp2p/net.cpp @@ -308,35 +308,17 @@ BOOST_AUTO_TEST_CASE(kademlia) if (test::Options::get().nonetwork) return; - // Not yet a 'real' test. TestNodeTableHost node(8); node.start(); - node.nodeTable->discover(); // ideally, joining with empty node table logs warning we can check for node.setup(); node.populate(); -// clog << "NodeTable:\n" << *node.nodeTable.get() << endl; - node.populateAll(); -// clog << "NodeTable:\n" << *node.nodeTable.get() << endl; - auto nodes = node.nodeTable->nodes(); nodes.sort(); - node.nodeTable->reset(); -// clog << "NodeTable:\n" << *node.nodeTable.get() << endl; - node.populate(1); -// clog << "NodeTable:\n" << *node.nodeTable.get() << endl; - - node.nodeTable->discover(); this_thread::sleep_for(chrono::milliseconds(2000)); -// clog << "NodeTable:\n" << *node.nodeTable.get() << endl; - BOOST_REQUIRE_EQUAL(node.nodeTable->count(), 8); - - auto netNodes = node.nodeTable->nodes(); - netNodes.sort(); - } BOOST_AUTO_TEST_CASE(udpOnce) @@ -355,6 +337,17 @@ BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE(netTypes) +BOOST_AUTO_TEST_CASE(deadlineTimer) +{ + ba::io_service io; + ba::deadline_timer t(io); + t.expires_from_now(boost::posix_time::milliseconds(1)); + this_thread::sleep_for(chrono::milliseconds(2)); + auto expire = t.expires_from_now().total_milliseconds(); + BOOST_REQUIRE(expire <= 0); + BOOST_REQUIRE_NO_THROW(t.wait()); +} + BOOST_AUTO_TEST_CASE(unspecifiedNode) { if (test::Options::get().nonetwork) From 7cb578cc1f4d605c79e1a6e06f6cb08f645d58aa Mon Sep 17 00:00:00 2001 From: subtly Date: Fri, 10 Jul 2015 11:19:00 -0700 Subject: [PATCH 02/62] log worker exceptions --- libdevcore/Worker.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libdevcore/Worker.cpp b/libdevcore/Worker.cpp index 4c64eaa31..c058ef7d4 100644 --- a/libdevcore/Worker.cpp +++ b/libdevcore/Worker.cpp @@ -56,7 +56,10 @@ void Worker::startWorking() workLoop(); doneWorking(); } - catch (...) {} + catch (std::exception const& _e) + { + clog(WarnChannel) << "Exception thrown in Worker thread: " _e.what(); + } // ex = WorkerState::Stopping; // m_state.compare_exchange_strong(ex, WorkerState::Stopped); From 614b61b67afaf1b291de9e8ccc6ee98ac95aaf65 Mon Sep 17 00:00:00 2001 From: subtly Date: Fri, 10 Jul 2015 16:50:05 -0700 Subject: [PATCH 03/62] Fix deadlineop/ops mutexes. Rerun discovery regardless of whether timer is cancelled, due to asio prematurely cancelling timer. --- libdevcore/Worker.cpp | 2 +- libp2p/Common.h | 35 +++++++++++++++++++---------------- libp2p/NodeTable.cpp | 11 ++++++++--- test/libp2p/net.cpp | 17 ++++++++++++++--- 4 files changed, 42 insertions(+), 23 deletions(-) diff --git a/libdevcore/Worker.cpp b/libdevcore/Worker.cpp index c058ef7d4..c4ea4996b 100644 --- a/libdevcore/Worker.cpp +++ b/libdevcore/Worker.cpp @@ -58,7 +58,7 @@ void Worker::startWorking() } catch (std::exception const& _e) { - clog(WarnChannel) << "Exception thrown in Worker thread: " _e.what(); + clog(WarnChannel) << "Exception thrown in Worker thread: " << _e.what(); } // ex = WorkerState::Stopping; diff --git a/libp2p/Common.h b/libp2p/Common.h index 7c9950b39..4718787a6 100644 --- a/libp2p/Common.h +++ b/libp2p/Common.h @@ -215,32 +215,35 @@ struct Node virtual operator bool() const { return (bool)id; } }; -class DeadlineOp -{ -public: - DeadlineOp(ba::io_service& _io, unsigned _msInFuture, std::function const& _f): m_timer(new ba::deadline_timer(_io)) { m_timer->expires_from_now(boost::posix_time::milliseconds(_msInFuture)); m_timer->async_wait(_f); } - DeadlineOp(DeadlineOp&& _s): m_timer(_s.m_timer.release()) {} - DeadlineOp& operator=(DeadlineOp&& _s) { m_timer.reset(_s.m_timer.release()); return *this; } - - bool expired() { return m_timer->expires_from_now().total_milliseconds() <= 0; } - void cancel() { m_timer->cancel(); } - -private: - std::unique_ptr m_timer; -}; - class DeadlineOps { + class DeadlineOp + { + public: + DeadlineOp(ba::io_service& _io, unsigned _msInFuture, std::function const& _f): m_timer(new ba::deadline_timer(_io)) { m_timer->expires_from_now(boost::posix_time::milliseconds(_msInFuture)); m_timer->async_wait(_f); } + ~DeadlineOp() {} + + DeadlineOp(DeadlineOp&& _s): m_timer(_s.m_timer.release()) {} + DeadlineOp& operator=(DeadlineOp&& _s) { m_timer.reset(_s.m_timer.release()); return *this; } + + bool expired() { Guard l(x_timer); return m_timer->expires_from_now().total_nanoseconds() <= 0; } + void wait() { Guard l(x_timer); m_timer->wait(); } + + private: + std::unique_ptr m_timer; + Mutex x_timer; + }; + public: DeadlineOps(ba::io_service& _io, unsigned _reapIntervalMs = 100): m_io(_io), m_reapIntervalMs(_reapIntervalMs), m_stopped({false}) { reap(); } - ~DeadlineOps() { m_stopped = true; } + ~DeadlineOps() { stop(); } void schedule(unsigned _msInFuture, std::function const& _f) { if (m_stopped) return; DEV_GUARDED(x_timers) m_timers.emplace_back(m_io, _msInFuture, _f); } void stop() { m_stopped = true; DEV_GUARDED(x_timers) m_timers.clear(); } protected: - void reap() { DEV_GUARDED(x_timers) { auto t = m_timers.begin(); while (t != m_timers.end()) if (t->expired()) m_timers.erase(t); else t++; } schedule(m_reapIntervalMs, [this](boost::system::error_code const& ec){ if (!ec) reap(); }); } + void reap() { Guard l(x_timers); auto t = m_timers.begin(); while (t != m_timers.end()) if (t->expired()) { t->wait(); m_timers.erase(t); } else t++; m_timers.emplace_back(m_io, m_reapIntervalMs, [this](boost::system::error_code const& ec){ if (!ec) reap(); }); } private: ba::io_service& m_io; diff --git a/libp2p/NodeTable.cpp b/libp2p/NodeTable.cpp index 389546605..44ab0aa99 100644 --- a/libp2p/NodeTable.cpp +++ b/libp2p/NodeTable.cpp @@ -156,12 +156,13 @@ void NodeTable::doDiscover(NodeId _node, unsigned _round, shared_ptrisOpen() || _round == s_maxSteps) + if (!m_socketPointer->isOpen()) return; if (_round == s_maxSteps) { clog(NodeTableEvent) << "Terminating discover after " << _round << " rounds."; + doDiscovery(); return; } else if (!_round && !_tried) @@ -197,8 +198,9 @@ void NodeTable::doDiscover(NodeId _node, unsigned _round, shared_ptr= s_bucketSize) { + if (removed) + clog(NodeTableWarn) << "DANGER: Bucket overflow when swapping node position."; + // It's only contested iff nodeentry exists contested = s.nodes.front().lock(); if (!contested) diff --git a/test/libp2p/net.cpp b/test/libp2p/net.cpp index 7603a6d41..7e3719c34 100644 --- a/test/libp2p/net.cpp +++ b/test/libp2p/net.cpp @@ -341,11 +341,22 @@ BOOST_AUTO_TEST_CASE(deadlineTimer) { ba::io_service io; ba::deadline_timer t(io); - t.expires_from_now(boost::posix_time::milliseconds(1)); - this_thread::sleep_for(chrono::milliseconds(2)); + bool start = false; + boost::system::error_code ec; + std::atomic fired(0); + + thread thread([&](){ while(!start) this_thread::sleep_for(chrono::milliseconds(10)); io.run(); }); + t.expires_from_now(boost::posix_time::milliseconds(200)); + start = true; + t.async_wait([&](boost::system::error_code const& _ec){ ec = _ec; fired++; }); + BOOST_REQUIRE_NO_THROW(t.wait()); + this_thread::sleep_for(chrono::milliseconds(250)); auto expire = t.expires_from_now().total_milliseconds(); BOOST_REQUIRE(expire <= 0); - BOOST_REQUIRE_NO_THROW(t.wait()); + BOOST_REQUIRE(fired == 1); + BOOST_REQUIRE(!ec); + io.stop(); + thread.join(); } BOOST_AUTO_TEST_CASE(unspecifiedNode) From 2991bf40976896d50a53964dfbd7bbab147407d3 Mon Sep 17 00:00:00 2001 From: subtly Date: Sat, 11 Jul 2015 11:45:20 -0700 Subject: [PATCH 04/62] Use const, nudge buildbot. --- libp2p/Host.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libp2p/Host.cpp b/libp2p/Host.cpp index 8482f254a..d57741e61 100644 --- a/libp2p/Host.cpp +++ b/libp2p/Host.cpp @@ -185,7 +185,7 @@ void Host::doneWorking() for (unsigned n = 0;; n = 0) { DEV_GUARDED(x_connecting) - for (auto i: m_connecting) + for (auto const& i: m_connecting) if (auto h = i.lock()) { h->cancel(); From 24f189b40ae6b2aa3744c7c87380c7f214a4e310 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Tue, 14 Jul 2015 17:17:43 +0200 Subject: [PATCH 05/62] Check in the khronos ICD library Taken from: https://www.khronos.org/registry/cl/ --- CMakeLists.txt | 1 + khronos_icd/CMakeLists.txt | 31 + khronos_icd/LICENSE.txt | 38 + khronos_icd/Makefile | 30 + khronos_icd/OpenCL.def | 143 ++ khronos_icd/OpenCL.rc | 74 + khronos_icd/README.txt | 50 + khronos_icd/build_using_cmake.bat | 11 + khronos_icd/icd.c | 218 ++ khronos_icd/icd.h | 199 ++ khronos_icd/icd_dispatch.c | 2186 +++++++++++++++++ khronos_icd/icd_dispatch.h | 1283 ++++++++++ khronos_icd/icd_exports.map | 153 ++ khronos_icd/icd_linux.c | 178 ++ khronos_icd/icd_windows.c | 152 ++ khronos_icd/inc/README.txt | 14 + khronos_icd/test/CMakeLists.txt | 7 + khronos_icd/test/Makefile | 18 + khronos_icd/test/driver_stub/CMakeLists.txt | 10 + khronos_icd/test/driver_stub/Makefile | 14 + khronos_icd/test/driver_stub/cl.c | 1917 +++++++++++++++ khronos_icd/test/driver_stub/cl_ext.c | 35 + khronos_icd/test/driver_stub/cl_gl.c | 221 ++ khronos_icd/test/driver_stub/driver_stub.def | 3 + khronos_icd/test/driver_stub/icd.c | 185 ++ .../test/driver_stub/icd_driver_exports.map | 8 + khronos_icd/test/driver_stub/icd_structs.h | 18 + khronos_icd/test/driver_stub/rename_api.h | 106 + khronos_icd/test/inc/platform/icd_test_log.h | 20 + khronos_icd/test/loader_test/CMakeLists.txt | 15 + khronos_icd/test/loader_test/Makefile | 16 + khronos_icd/test/loader_test/callbacks.c | 43 + khronos_icd/test/loader_test/icd_test_match.c | 36 + khronos_icd/test/loader_test/main.c | 47 + khronos_icd/test/loader_test/param_struct.h | 1115 +++++++++ .../test/loader_test/test_buffer_object.c | 461 ++++ .../test/loader_test/test_cl_runtime.c | 64 + khronos_icd/test/loader_test/test_clgl.c | 345 +++ .../test/loader_test/test_create_calls.c | 767 ++++++ .../test/loader_test/test_image_objects.c | 362 +++ khronos_icd/test/loader_test/test_kernel.c | 596 +++++ khronos_icd/test/loader_test/test_platforms.c | 183 ++ .../test/loader_test/test_program_objects.c | 260 ++ .../test/loader_test/test_sampler_objects.c | 64 + khronos_icd/test/platform/CMakeLists.txt | 1 + khronos_icd/test/platform/Makefile | 15 + khronos_icd/test/platform/icd_test_log.c | 98 + 47 files changed, 11811 insertions(+) create mode 100644 khronos_icd/CMakeLists.txt create mode 100644 khronos_icd/LICENSE.txt create mode 100644 khronos_icd/Makefile create mode 100644 khronos_icd/OpenCL.def create mode 100644 khronos_icd/OpenCL.rc create mode 100644 khronos_icd/README.txt create mode 100644 khronos_icd/build_using_cmake.bat create mode 100644 khronos_icd/icd.c create mode 100644 khronos_icd/icd.h create mode 100644 khronos_icd/icd_dispatch.c create mode 100644 khronos_icd/icd_dispatch.h create mode 100644 khronos_icd/icd_exports.map create mode 100644 khronos_icd/icd_linux.c create mode 100644 khronos_icd/icd_windows.c create mode 100644 khronos_icd/inc/README.txt create mode 100644 khronos_icd/test/CMakeLists.txt create mode 100644 khronos_icd/test/Makefile create mode 100644 khronos_icd/test/driver_stub/CMakeLists.txt create mode 100644 khronos_icd/test/driver_stub/Makefile create mode 100644 khronos_icd/test/driver_stub/cl.c create mode 100644 khronos_icd/test/driver_stub/cl_ext.c create mode 100644 khronos_icd/test/driver_stub/cl_gl.c create mode 100644 khronos_icd/test/driver_stub/driver_stub.def create mode 100644 khronos_icd/test/driver_stub/icd.c create mode 100644 khronos_icd/test/driver_stub/icd_driver_exports.map create mode 100644 khronos_icd/test/driver_stub/icd_structs.h create mode 100644 khronos_icd/test/driver_stub/rename_api.h create mode 100644 khronos_icd/test/inc/platform/icd_test_log.h create mode 100644 khronos_icd/test/loader_test/CMakeLists.txt create mode 100644 khronos_icd/test/loader_test/Makefile create mode 100644 khronos_icd/test/loader_test/callbacks.c create mode 100644 khronos_icd/test/loader_test/icd_test_match.c create mode 100644 khronos_icd/test/loader_test/main.c create mode 100644 khronos_icd/test/loader_test/param_struct.h create mode 100644 khronos_icd/test/loader_test/test_buffer_object.c create mode 100644 khronos_icd/test/loader_test/test_cl_runtime.c create mode 100644 khronos_icd/test/loader_test/test_clgl.c create mode 100644 khronos_icd/test/loader_test/test_create_calls.c create mode 100644 khronos_icd/test/loader_test/test_image_objects.c create mode 100644 khronos_icd/test/loader_test/test_kernel.c create mode 100644 khronos_icd/test/loader_test/test_platforms.c create mode 100644 khronos_icd/test/loader_test/test_program_objects.c create mode 100644 khronos_icd/test/loader_test/test_sampler_objects.c create mode 100644 khronos_icd/test/platform/CMakeLists.txt create mode 100644 khronos_icd/test/platform/Makefile create mode 100644 khronos_icd/test/platform/icd_test_log.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 6cd9e338f..ef450f721 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -423,6 +423,7 @@ if (GENERAL OR MINER) add_subdirectory(libethash) if (ETHASHCL) add_subdirectory(libethash-cl) + add_subdirectory(khronos_icd) endif () endif () diff --git a/khronos_icd/CMakeLists.txt b/khronos_icd/CMakeLists.txt new file mode 100644 index 000000000..b0cbe58a3 --- /dev/null +++ b/khronos_icd/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required (VERSION 2.6) + +project (OPENCL_ICD_LOADER) + +set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/bin) +set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/bin) + +set (OPENCL_ICD_LOADER_SOURCES icd.c icd_dispatch.c) + +if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + list (APPEND OPENCL_ICD_LOADER_SOURCES icd_linux.c icd_exports.map) +else () + list (APPEND OPENCL_ICD_LOADER_SOURCES icd_windows.c OpenCL.def) + include_directories ($ENV{DXSDK_DIR}/Include) +endif () + +# Change this to point to a directory containing OpenCL header directory "CL" +# OR copy OpenCL headers to ./inc/CL/ +include_directories (./inc) + +add_library (OpenCL SHARED ${OPENCL_ICD_LOADER_SOURCES}) +set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1") + +if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,../icd_exports.map") +endif () + +target_link_libraries (OpenCL ${CMAKE_DL_LIBS}) + +enable_testing() +add_subdirectory (test) diff --git a/khronos_icd/LICENSE.txt b/khronos_icd/LICENSE.txt new file mode 100644 index 000000000..81a772bd4 --- /dev/null +++ b/khronos_icd/LICENSE.txt @@ -0,0 +1,38 @@ +Copyright (c) 2012 The Khronos Group Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software source and associated documentation files (the "Materials"), +to use, copy, modify and compile the Materials to create a binary under the +following terms and conditions: + +1. The Materials shall NOT be distributed to any third party; + +2. The binary may be distributed without restriction, including without +limitation the rights to use, copy, merge, publish, distribute, sublicense, +and/or sell copies, and to permit persons to whom the binary is furnished to +do so; + +3. All modifications to the Materials used to create a binary that is +distributed to third parties shall be provided to Khronos with an +unrestricted license to use for the purposes of implementing bug fixes and +enhancements to the Materials; + +4. If the binary is used as part of an OpenCL(TM) implementation, whether +binary is distributed together with or separately to that implementation, +then recipient must become an OpenCL Adopter and follow the published OpenCL +conformance process for that implementation, details at: +http://www.khronos.org/conformance/; + +5. The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Materials. + +THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN +THE MATERIALS. + +OpenCL is a trademark of Apple Inc. used under license by Khronos. + diff --git a/khronos_icd/Makefile b/khronos_icd/Makefile new file mode 100644 index 000000000..886c1dc59 --- /dev/null +++ b/khronos_icd/Makefile @@ -0,0 +1,30 @@ +.PHONY: default do_cmake do_build test package +.PHONY: clean clobber + +BUILD_DIR:=build +BIN_DIR:=bin + +ICD_VERSION:=$(shell grep FileVersion OpenCL.rc | sed "s/.*\([0-9]\+\.[0-9]\+\.[0-9]\+.[0-9]\+\).*/\1/") +PACKAGE_PATH:=/tmp/opencl-icd-${ICD_VERSION}.tgz + +default: do_build + +do_build: do_cmake + ${MAKE} -C ${BUILD_DIR} + +do_cmake: + mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR} && cmake .. + +test: + ${MAKE} -C ${BUILD_DIR} test + +package: clobber + rm -f ${PACKAGE_PATH} + tar -C .. -czf ${PACKAGE_PATH} --exclude .svn icd + @echo "Package created at ${PACKAGE_PATH}" + +clean: + ${MAKE} -C ${BUILD_DIR} clean + +clobber: + rm -rf ${BUILD_DIR} ${BIN_DIR} diff --git a/khronos_icd/OpenCL.def b/khronos_icd/OpenCL.def new file mode 100644 index 000000000..de92e385a --- /dev/null +++ b/khronos_icd/OpenCL.def @@ -0,0 +1,143 @@ +; Copyright (c) 2012 The Khronos Group Inc. +; +; Permission is hereby granted, free of charge, to any person obtaining a copy +; of this software source and associated documentation files (the "Materials"), +; to use, copy, modify and compile the Materials to create a binary under the +; following terms and conditions: +; +; 1. The Materials shall NOT be distributed to any third party; +; +; 2. The binary may be distributed without restriction, including without +; limitation the rights to use, copy, merge, publish, distribute, sublicense, +; and/or sell copies, and to permit persons to whom the binary is furnished to +; do so; +; +; 3. All modifications to the Materials used to create a binary that is +; distributed to third parties shall be provided to Khronos with an +; unrestricted license to use for the purposes of implementing bug fixes and +; enhancements to the Materials; +; +; 4. If the binary is used as part of an OpenCL(TM) implementation, whether +; binary is distributed together with or separately to that implementation, +; then recipient must become an OpenCL Adopter and follow the published OpenCL +; conformance process for that implementation, details at: +; http://www.khronos.org/conformance/; +; +; 5. The above copyright notice and this permission notice shall be included in +; all copies or substantial portions of the Materials. +; +; THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +; OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN +; THE MATERIALS. +; +; OpenCL is a trademark of Apple Inc. used under license by Khronos. + +EXPORTS + +; OpenCL 1.0 +clBuildProgram +clCreateBuffer +clCreateCommandQueue +clCreateContext +clCreateContextFromType +clCreateFromGLBuffer +clCreateFromGLRenderbuffer +clCreateFromGLTexture2D +clCreateFromGLTexture3D +clCreateImage2D +clCreateImage3D +clCreateKernel +clCreateKernelsInProgram +clCreateProgramWithBinary +clCreateProgramWithSource +clCreateSampler +clEnqueueAcquireGLObjects +clEnqueueBarrier +clEnqueueCopyBuffer +clEnqueueCopyBufferToImage +clEnqueueCopyImage +clEnqueueCopyImageToBuffer +clEnqueueMapBuffer +clEnqueueMapImage +clEnqueueMarker +clEnqueueNDRangeKernel +clEnqueueNativeKernel +clEnqueueReadBuffer +clEnqueueReadImage +clEnqueueReleaseGLObjects +clEnqueueTask +clEnqueueUnmapMemObject +clEnqueueWaitForEvents +clEnqueueWriteBuffer +clEnqueueWriteImage +clFinish +clFlush +clGetCommandQueueInfo +clGetContextInfo +clGetDeviceIDs +clGetDeviceInfo +clGetEventInfo +clGetEventProfilingInfo +clGetExtensionFunctionAddress +clGetGLObjectInfo +clGetGLTextureInfo +clGetImageInfo +clGetKernelInfo +clGetKernelWorkGroupInfo +clGetMemObjectInfo +clGetPlatformIDs +clGetPlatformInfo +clGetProgramBuildInfo +clGetProgramInfo +clGetSamplerInfo +clGetSupportedImageFormats +clReleaseCommandQueue +clReleaseContext +clReleaseEvent +clReleaseKernel +clReleaseMemObject +clReleaseProgram +clReleaseSampler +clRetainCommandQueue +clRetainContext +clRetainEvent +clRetainKernel +clRetainMemObject +clRetainProgram +clRetainSampler +clSetCommandQueueProperty +clSetKernelArg +clUnloadCompiler +clWaitForEvents + +; OpenCL 1.1 API +clCreateSubBuffer +clCreateUserEvent +clEnqueueCopyBufferRect +clEnqueueReadBufferRect +clEnqueueWriteBufferRect +clSetEventCallback +clSetMemObjectDestructorCallback +clSetUserEventStatus + +; OpenCL 1.2 API +clCompileProgram +clCreateFromGLTexture +clCreateImage +clCreateProgramWithBuiltInKernels +clCreateSubDevices +clEnqueueBarrierWithWaitList +clEnqueueFillBuffer +clEnqueueFillImage +clEnqueueMarkerWithWaitList +clEnqueueMigrateMemObjects +clGetExtensionFunctionAddressForPlatform +clGetKernelArgInfo +clLinkProgram +clReleaseDevice +clRetainDevice +clUnloadPlatformCompiler diff --git a/khronos_icd/OpenCL.rc b/khronos_icd/OpenCL.rc new file mode 100644 index 000000000..5cddfe553 --- /dev/null +++ b/khronos_icd/OpenCL.rc @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2012 The Khronos Group Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software source and associated documentation files (the "Materials"), + * to use, copy, modify and compile the Materials to create a binary under the + * following terms and conditions: + * + * 1. The Materials shall NOT be distributed to any third party; + * + * 2. The binary may be distributed without restriction, including without + * limitation the rights to use, copy, merge, publish, distribute, sublicense, + * and/or sell copies, and to permit persons to whom the binary is furnished to + * do so; + * + * 3. All modifications to the Materials used to create a binary that is + * distributed to third parties shall be provided to Khronos with an + * unrestricted license to use for the purposes of implementing bug fixes and + * enhancements to the Materials; + * + * 4. If the binary is used as part of an OpenCL(TM) implementation, whether + * binary is distributed together with or separately to that implementation, + * then recipient must become an OpenCL Adopter and follow the published OpenCL + * conformance process for that implementation, details at: + * http://www.khronos.org/conformance/; + * + * 5. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Materials. + * + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN + * THE MATERIALS. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include + +#ifdef RC_INVOKED + +VS_VERSION_INFO VERSIONINFO +FILEVERSION 1,2,11,0 +PRODUCTVERSION 1,2,11,0 +FILETYPE VFT_DLL + +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + BEGIN + VALUE "FileDescription" ,"OpenCL Client DLL" + VALUE "ProductName" ,"Khronos OpenCL ICD" + VALUE "LegalCopyright" ,"Copyright \251 The Khronos Group Inc 2011" + VALUE "FileVersion" ,"1.2.11.0" + + VALUE "CompanyName" ,"Khronos Group" + VALUE "InternalName" ,"OpenCL" + VALUE "OriginalFilename","OpenCL.dll" + END + END + + BLOCK "VarFileInfo" + BEGIN + // extend this line for localized versions + VALUE "Translation", 0x0409, 0x04E4 + END +END + +#endif + diff --git a/khronos_icd/README.txt b/khronos_icd/README.txt new file mode 100644 index 000000000..3b51170e9 --- /dev/null +++ b/khronos_icd/README.txt @@ -0,0 +1,50 @@ +== Building ICD and ICD Test == + +The build system will build ICD Loader library (OpenCL.dll or libOpenCL.so) and +ICD Loader Test binary (icd_loader_test) and some helper libraries for the test. + +=== Linux === + +Run "make" + +=== Windows === + +Run "build_using_cmake.bat" + +== Running ICD Test == + +ICD Test can be run using ctest, which is a companion to cmake. It can also be +run directly by executing icd_loader_test(.exe) executable from the bin folder. + +=== Linux === + +1. Add driver stub as an ICD + echo full/path/to/libOpenCLDriverStub.so > /etc/OpenCL/vendors/test.icd + +2. Run test using ctest + make test + +=== Windows === + +1. Add driver stub as an ICD by adding appropriate registry value + Key for 32-bit apps: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Khronos\OpenCL\Vendors + Key for 64-bit apps: HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenCL\Vendors + + Add a REG_DWORD value: + Name: c:/full/path/to/OpenCLDriverStub.dll + Data: 0 + + Note: The build_using_cmake.bat builds ICD test as a 32-bit binary. + +2. Run test using ctest.exe + cd build + ctest.exe + +== Cleanup == + +Manually remove the registry key or .icd files added for running the ICD test. + +The "build" and "bin" folders are autogenerated by the build so those may be +safely deleted without losing any source code (on Linux "make clobber" will +delete them). + diff --git a/khronos_icd/build_using_cmake.bat b/khronos_icd/build_using_cmake.bat new file mode 100644 index 000000000..f0044db7a --- /dev/null +++ b/khronos_icd/build_using_cmake.bat @@ -0,0 +1,11 @@ +call "%VS90COMNTOOLS%/vsvars32.bat" + +set BUILD_DIR=build +set BIN_DIR=bin + +mkdir %BUILD_DIR% +cd %BUILD_DIR% +cmake -G "NMake Makefiles" ../ +nmake +cd .. + diff --git a/khronos_icd/icd.c b/khronos_icd/icd.c new file mode 100644 index 000000000..c59a7d9b5 --- /dev/null +++ b/khronos_icd/icd.c @@ -0,0 +1,218 @@ +/* + * Copyright (c) 2012 The Khronos Group Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software source and associated documentation files (the "Materials"), + * to use, copy, modify and compile the Materials to create a binary under the + * following terms and conditions: + * + * 1. The Materials shall NOT be distributed to any third party; + * + * 2. The binary may be distributed without restriction, including without + * limitation the rights to use, copy, merge, publish, distribute, sublicense, + * and/or sell copies, and to permit persons to whom the binary is furnished to + * do so; + * + * 3. All modifications to the Materials used to create a binary that is + * distributed to third parties shall be provided to Khronos with an + * unrestricted license to use for the purposes of implementing bug fixes and + * enhancements to the Materials; + * + * 4. If the binary is used as part of an OpenCL(TM) implementation, whether + * binary is distributed together with or separately to that implementation, + * then recipient must become an OpenCL Adopter and follow the published OpenCL + * conformance process for that implementation, details at: + * http://www.khronos.org/conformance/; + * + * 5. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Materials. + * + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN + * THE MATERIALS. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include "icd.h" +#include "icd_dispatch.h" +#include +#include + +KHRicdState khrIcdState = {0}; + +// entrypoint to initialize the ICD and add all vendors +void khrIcdInitialize(void) +{ + // make sure we don't double-initialize + // TODO: this should use an atomic exchange to be thread-safe + if (khrIcdState.initialized) + { + return; + } + khrIcdState.initialized = CL_TRUE; + + // enumerate vendors present on the system + khrIcdOsVendorsEnumerate(); +} + +void khrIcdVendorAdd(const char *libraryName) +{ + void *library = NULL; + cl_int result = CL_SUCCESS; + pfn_clGetExtensionFunctionAddress p_clGetExtensionFunctionAddress = NULL; + pfn_clIcdGetPlatformIDs p_clIcdGetPlatformIDs = NULL; + cl_uint i = 0; + cl_uint platformCount = 0; + cl_platform_id *platforms = NULL; + + // require that the library name be valid + if (!libraryName) + { + goto Done; + } + KHR_ICD_TRACE("attempting to add vendor %s...\n", libraryName); + + // load its library and query its function pointers + library = khrIcdOsLibraryLoad(libraryName); + if (!library) + { + KHR_ICD_TRACE("failed to load library %s\n", libraryName); + goto Done; + } + + // get the library's clGetExtensionFunctionAddress pointer + p_clGetExtensionFunctionAddress = khrIcdOsLibraryGetFunctionAddress(library, "clGetExtensionFunctionAddress"); + if (!p_clGetExtensionFunctionAddress) + { + KHR_ICD_TRACE("failed to get function address clGetExtensionFunctionAddress\n"); + goto Done; + } + + // use that function to get the clIcdGetPlatformIDsKHR function pointer + p_clIcdGetPlatformIDs = p_clGetExtensionFunctionAddress("clIcdGetPlatformIDsKHR"); + if (!p_clIcdGetPlatformIDs) + { + KHR_ICD_TRACE("failed to get extension function address clIcdGetPlatformIDsKHR\n"); + goto Done; + } + + // query the number of platforms available and allocate space to store them + result = p_clIcdGetPlatformIDs(0, NULL, &platformCount); + if (CL_SUCCESS != result) + { + KHR_ICD_TRACE("failed clIcdGetPlatformIDs\n"); + goto Done; + } + platforms = (cl_platform_id *)malloc(platformCount * sizeof(cl_platform_id) ); + if (!platforms) + { + KHR_ICD_TRACE("failed to allocate memory\n"); + goto Done; + } + memset(platforms, 0, platformCount * sizeof(cl_platform_id) ); + result = p_clIcdGetPlatformIDs(platformCount, platforms, NULL); + if (CL_SUCCESS != result) + { + KHR_ICD_TRACE("failed clIcdGetPlatformIDs\n"); + goto Done; + } + + // for each platform, add it + for (i = 0; i < platformCount; ++i) + { + KHRicdVendor* vendor = NULL; + char *suffix; + size_t suffixSize; + + // call clGetPlatformInfo on the returned platform to get the suffix + if (!platforms[i]) + { + continue; + } + result = platforms[i]->dispatch->clGetPlatformInfo( + platforms[i], + CL_PLATFORM_ICD_SUFFIX_KHR, + 0, + NULL, + &suffixSize); + if (CL_SUCCESS != result) + { + continue; + } + suffix = (char *)malloc(suffixSize); + if (!suffix) + { + continue; + } + result = platforms[i]->dispatch->clGetPlatformInfo( + platforms[i], + CL_PLATFORM_ICD_SUFFIX_KHR, + suffixSize, + suffix, + NULL); + if (CL_SUCCESS != result) + { + free(suffix); + continue; + } + + // allocate a structure for the vendor + vendor = (KHRicdVendor*)malloc(sizeof(*vendor) ); + if (!vendor) + { + free(suffix); + KHR_ICD_TRACE("failed to allocate memory\n"); + continue; + } + memset(vendor, 0, sizeof(*vendor) ); + + // populate vendor data + vendor->library = khrIcdOsLibraryLoad(libraryName); + if (!vendor->library) + { + free(suffix); + free(vendor); + KHR_ICD_TRACE("failed get platform handle to library\n"); + continue; + } + vendor->clGetExtensionFunctionAddress = p_clGetExtensionFunctionAddress; + vendor->platform = platforms[i]; + vendor->suffix = suffix; + + // add this vendor to the list of vendors at the tail + { + KHRicdVendor **prevNextPointer = NULL; + for (prevNextPointer = &khrIcdState.vendors; *prevNextPointer; prevNextPointer = &( (*prevNextPointer)->next) ); + *prevNextPointer = vendor; + } + + KHR_ICD_TRACE("successfully added vendor %s with suffix %s\n", libraryName, suffix); + + } + +Done: + + if (library) + { + khrIcdOsLibraryUnload(library); + } +} + +void khrIcdContextPropertiesGetPlatform(const cl_context_properties *properties, cl_platform_id *outPlatform) +{ + const cl_context_properties *property = (cl_context_properties *)NULL; + *outPlatform = NULL; + for (property = properties; property && property[0]; property += 2) + { + if ((cl_context_properties)CL_CONTEXT_PLATFORM == property[0]) + { + *outPlatform = (cl_platform_id)property[1]; + } + } +} + diff --git a/khronos_icd/icd.h b/khronos_icd/icd.h new file mode 100644 index 000000000..637ed707c --- /dev/null +++ b/khronos_icd/icd.h @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2012 The Khronos Group Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software source and associated documentation files (the "Materials"), + * to use, copy, modify and compile the Materials to create a binary under the + * following terms and conditions: + * + * 1. The Materials shall NOT be distributed to any third party; + * + * 2. The binary may be distributed without restriction, including without + * limitation the rights to use, copy, merge, publish, distribute, sublicense, + * and/or sell copies, and to permit persons to whom the binary is furnished to + * do so; + * + * 3. All modifications to the Materials used to create a binary that is + * distributed to third parties shall be provided to Khronos with an + * unrestricted license to use for the purposes of implementing bug fixes and + * enhancements to the Materials; + * + * 4. If the binary is used as part of an OpenCL(TM) implementation, whether + * binary is distributed together with or separately to that implementation, + * then recipient must become an OpenCL Adopter and follow the published OpenCL + * conformance process for that implementation, details at: + * http://www.khronos.org/conformance/; + * + * 5. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Materials. + * + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN + * THE MATERIALS. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#ifndef _ICD_H_ +#define _ICD_H_ + +#include +#include + +/* + * type definitions + */ + +typedef CL_API_ENTRY cl_int (CL_API_CALL *pfn_clIcdGetPlatformIDs)( + cl_uint num_entries, + cl_platform_id *platforms, + cl_uint *num_platforms) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *pfn_clGetPlatformInfo)( + cl_platform_id platform, + cl_platform_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY void *(CL_API_CALL *pfn_clGetExtensionFunctionAddress)( + const char *function_name) CL_API_SUFFIX__VERSION_1_0; + +typedef struct KHRicdVendorRec KHRicdVendor; +typedef struct KHRicdStateRec KHRicdState; + +/* + * KHRicdVendor + * + * Data for a single ICD vendor platform. + */ +struct KHRicdVendorRec +{ + // the loaded library object (true type varies on Linux versus Windows) + void *library; + + // the extension suffix for this platform + char *suffix; + + // function pointer to the ICD platform IDs extracted from the library + pfn_clGetExtensionFunctionAddress clGetExtensionFunctionAddress; + + // the platform retrieved from clGetIcdPlatformIDsKHR + cl_platform_id platform; + + // next vendor in the list vendors + KHRicdVendor *next; +}; + + +/* + * KHRicdState + * + * The global state of all vendors + * + * TODO: write access to this structure needs to be protected via a mutex + */ + +struct KHRicdStateRec +{ + // has this structure been initialized + cl_bool initialized; + + // the list of vendors which have been loaded + KHRicdVendor *vendors; +}; + +// the global state +extern KHRicdState khrIcdState; + +/* + * khrIcd interface + */ + +// read vendors from system configuration and store the data +// loaded into khrIcdState. this will call the OS-specific +// function khrIcdEnumerateVendors. this is called at every +// dispatch function which may be a valid first call into the +// API (e.g, getPlatformIDs, etc). +void khrIcdInitialize(void); + +// go through the list of vendors (in /etc/OpenCL.conf or through +// the registry) and call khrIcdVendorAdd for each vendor encountered +// n.b, this call is OS-specific +void khrIcdOsVendorsEnumerate(void); + +// add a vendor's implementation to the list of libraries +void khrIcdVendorAdd(const char *libraryName); + +// dynamically load a library. returns NULL on failure +// n.b, this call is OS-specific +void *khrIcdOsLibraryLoad(const char *libraryName); + +// get a function pointer from a loaded library. returns NULL on failure. +// n.b, this call is OS-specific +void *khrIcdOsLibraryGetFunctionAddress(void *library, const char *functionName); + +// unload a library. +// n.b, this call is OS-specific +void khrIcdOsLibraryUnload(void *library); + +// parse properties and determine the platform to use from them +void khrIcdContextPropertiesGetPlatform( + const cl_context_properties *properties, + cl_platform_id *outPlatform); + +// internal tracing macros +#if 0 + #include + #define KHR_ICD_TRACE(...) \ + do \ + { \ + fprintf(stderr, "KHR ICD trace at %s:%d: ", __FILE__, __LINE__); \ + fprintf(stderr, __VA_ARGS__); \ + } while (0) + + #define KHR_ICD_ASSERT(x) \ + do \ + { \ + if (!(x)) \ + { \ + fprintf(stderr, "KHR ICD assert at %s:%d: %s failed", __FILE__, __LINE__, #x); \ + } \ + } while (0) +#else + #define KHR_ICD_TRACE(...) + #define KHR_ICD_ASSERT(x) +#endif + +// if handle is NULL then return invalid_handle_error_code +#define KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(handle,invalid_handle_error_code) \ + do \ + { \ + if (!handle) \ + { \ + return invalid_handle_error_code; \ + } \ + } while (0) + +// if handle is NULL then set errcode_ret to invalid_handle_error and return NULL +// (NULL being an invalid handle) +#define KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(handle,invalid_handle_error) \ + do \ + { \ + if (!handle) \ + { \ + if (errcode_ret) \ + { \ + *errcode_ret = invalid_handle_error; \ + } \ + return NULL; \ + } \ + } while (0) + + +#endif + diff --git a/khronos_icd/icd_dispatch.c b/khronos_icd/icd_dispatch.c new file mode 100644 index 000000000..ce2645a87 --- /dev/null +++ b/khronos_icd/icd_dispatch.c @@ -0,0 +1,2186 @@ +/* + * Copyright (c) 2012 The Khronos Group Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software source and associated documentation files (the "Materials"), + * to use, copy, modify and compile the Materials to create a binary under the + * following terms and conditions: + * + * 1. The Materials shall NOT be distributed to any third party; + * + * 2. The binary may be distributed without restriction, including without + * limitation the rights to use, copy, merge, publish, distribute, sublicense, + * and/or sell copies, and to permit persons to whom the binary is furnished to + * do so; + * + * 3. All modifications to the Materials used to create a binary that is + * distributed to third parties shall be provided to Khronos with an + * unrestricted license to use for the purposes of implementing bug fixes and + * enhancements to the Materials; + * + * 4. If the binary is used as part of an OpenCL(TM) implementation, whether + * binary is distributed together with or separately to that implementation, + * then recipient must become an OpenCL Adopter and follow the published OpenCL + * conformance process for that implementation, details at: + * http://www.khronos.org/conformance/; + * + * 5. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Materials. + * + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN + * THE MATERIALS. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include "icd_dispatch.h" +#include "icd.h" +#include +#include + +// Platform APIs +CL_API_ENTRY cl_int CL_API_CALL +clGetPlatformIDs(cl_uint num_entries, + cl_platform_id * platforms, + cl_uint * num_platforms) CL_API_SUFFIX__VERSION_1_0 +{ + KHRicdVendor* vendor = NULL; + cl_uint i; + + // initialize the platforms (in case they have not been already) + khrIcdInitialize(); + + if (!num_entries && platforms) + { + return CL_INVALID_VALUE; + } + if (!platforms && !num_platforms) + { + return CL_INVALID_VALUE; + } + // set num_platforms to 0 and set all platform pointers to NULL + if (num_platforms) + { + *num_platforms = 0; + } + for (i = 0; i < num_entries && platforms; ++i) + { + platforms[i] = NULL; + } + // return error if we have no platforms + if (!khrIcdState.vendors) + { + return CL_PLATFORM_NOT_FOUND_KHR; + } + // otherwise enumerate all platforms + for (vendor = khrIcdState.vendors; vendor; vendor = vendor->next) + { + if (num_entries && platforms) + { + *(platforms++) = vendor->platform; + --num_entries; + } + if (num_platforms) + { + ++(*num_platforms); + } + } + return CL_SUCCESS; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetPlatformInfo(cl_platform_id platform, + cl_platform_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + // initialize the platforms (in case they have not been already) + khrIcdInitialize(); + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); + return platform->dispatch->clGetPlatformInfo( + platform, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +// Device APIs +CL_API_ENTRY cl_int CL_API_CALL +clGetDeviceIDs(cl_platform_id platform, + cl_device_type device_type, + cl_uint num_entries, + cl_device_id * devices, + cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_0 +{ + // initialize the platforms (in case they have not been already) + khrIcdInitialize(); + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); + return platform->dispatch->clGetDeviceIDs( + platform, + device_type, + num_entries, + devices, + num_devices); +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetDeviceInfo( + cl_device_id device, + cl_device_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); + return device->dispatch->clGetDeviceInfo( + device, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clCreateSubDevices(cl_device_id in_device, + const cl_device_partition_property * properties, + cl_uint num_entries, + cl_device_id * out_devices, + cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_2 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(in_device, CL_INVALID_DEVICE); + return in_device->dispatch->clCreateSubDevices( + in_device, + properties, + num_entries, + out_devices, + num_devices); +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainDevice(cl_device_id device) CL_API_SUFFIX__VERSION_1_2 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); + return device->dispatch->clRetainDevice(device); +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseDevice(cl_device_id device) CL_API_SUFFIX__VERSION_1_2 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); + return device->dispatch->clReleaseDevice(device); +} + +// Context APIs +CL_API_ENTRY cl_context CL_API_CALL +clCreateContext(const cl_context_properties * properties, + cl_uint num_devices, + const cl_device_id * devices, + void (CL_CALLBACK *pfn_notify)(const char *, const void *, size_t, void *), + void * user_data, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + // initialize the platforms (in case they have not been already) + khrIcdInitialize(); + if (!num_devices || !devices) + { + if (errcode_ret) + { + *errcode_ret = CL_INVALID_VALUE; + } + return NULL; + } + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(devices[0], CL_INVALID_DEVICE); + return devices[0]->dispatch->clCreateContext( + properties, + num_devices, + devices, + pfn_notify, + user_data, + errcode_ret); +} + +CL_API_ENTRY cl_context CL_API_CALL +clCreateContextFromType(const cl_context_properties * properties, + cl_device_type device_type, + void (CL_CALLBACK *pfn_notify)(const char *, const void *, size_t, void *), + void * user_data, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_platform_id platform = NULL; + + // initialize the platforms (in case they have not been already) + khrIcdInitialize(); + + // determine the platform to use from the properties specified + khrIcdContextPropertiesGetPlatform(properties, &platform); + + // validate the platform handle and dispatch + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(platform, CL_INVALID_PLATFORM); + return platform->dispatch->clCreateContextFromType( + properties, + device_type, + pfn_notify, + user_data, + errcode_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainContext(cl_context context) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, CL_INVALID_CONTEXT); + return context->dispatch->clRetainContext(context); +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseContext(cl_context context) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, CL_INVALID_CONTEXT); + return context->dispatch->clReleaseContext(context); +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetContextInfo(cl_context context, + cl_context_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, CL_INVALID_CONTEXT); + return context->dispatch->clGetContextInfo( + context, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +// Command Queue APIs +CL_API_ENTRY cl_command_queue CL_API_CALL +clCreateCommandQueue(cl_context context, + cl_device_id device, + cl_command_queue_properties properties, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateCommandQueue( + context, + device, + properties, + errcode_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainCommandQueue(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clRetainCommandQueue(command_queue); +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseCommandQueue(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clReleaseCommandQueue(command_queue); +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetCommandQueueInfo(cl_command_queue command_queue, + cl_command_queue_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clGetCommandQueueInfo( + command_queue, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +// Memory Object APIs +CL_API_ENTRY cl_mem CL_API_CALL +clCreateBuffer(cl_context context, + cl_mem_flags flags, + size_t size, + void * host_ptr, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateBuffer( + context, + flags, + size, + host_ptr, + errcode_ret); +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateImage(cl_context context, + cl_mem_flags flags, + const cl_image_format * image_format, + const cl_image_desc * image_desc, + void * host_ptr, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateImage( + context, + flags, + image_format, + image_desc, + host_ptr, + errcode_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainMemObject(cl_mem memobj) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); + return memobj->dispatch->clRetainMemObject(memobj); +} + + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseMemObject(cl_mem memobj) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); + return memobj->dispatch->clReleaseMemObject(memobj); +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetSupportedImageFormats(cl_context context, + cl_mem_flags flags, + cl_mem_object_type image_type, + cl_uint num_entries, + cl_image_format * image_formats, + cl_uint * num_image_formats) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, CL_INVALID_CONTEXT); + return context->dispatch->clGetSupportedImageFormats( + context, + flags, + image_type, + num_entries, + image_formats, + num_image_formats); +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetMemObjectInfo(cl_mem memobj, + cl_mem_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); + return memobj->dispatch->clGetMemObjectInfo( + memobj, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetImageInfo(cl_mem image, + cl_image_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(image, CL_INVALID_MEM_OBJECT); + return image->dispatch->clGetImageInfo( + image, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +// Sampler APIs +CL_API_ENTRY cl_sampler CL_API_CALL +clCreateSampler(cl_context context, + cl_bool normalized_coords, + cl_addressing_mode addressing_mode, + cl_filter_mode filter_mode, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateSampler( + context, + normalized_coords, + addressing_mode, + filter_mode, + errcode_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainSampler(cl_sampler sampler) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(sampler, CL_INVALID_SAMPLER); + return sampler->dispatch->clRetainSampler(sampler); +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseSampler(cl_sampler sampler) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(sampler, CL_INVALID_SAMPLER); + return sampler->dispatch->clReleaseSampler(sampler); +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetSamplerInfo(cl_sampler sampler, + cl_sampler_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(sampler, CL_INVALID_SAMPLER); + return sampler->dispatch->clGetSamplerInfo( + sampler, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +// Program Object APIs +CL_API_ENTRY cl_program CL_API_CALL +clCreateProgramWithSource(cl_context context, + cl_uint count, + const char ** strings, + const size_t * lengths, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateProgramWithSource( + context, + count, + strings, + lengths, + errcode_ret); +} + +CL_API_ENTRY cl_program CL_API_CALL +clCreateProgramWithBinary(cl_context context, + cl_uint num_devices, + const cl_device_id * device_list, + const size_t * lengths, + const unsigned char ** binaries, + cl_int * binary_status, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateProgramWithBinary( + context, + num_devices, + device_list, + lengths, + binaries, + binary_status, + errcode_ret); +} + +CL_API_ENTRY cl_program CL_API_CALL +clCreateProgramWithBuiltInKernels(cl_context context, + cl_uint num_devices, + const cl_device_id * device_list, + const char * kernel_names, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateProgramWithBuiltInKernels( + context, + num_devices, + device_list, + kernel_names, + errcode_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainProgram(cl_program program) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return program->dispatch->clRetainProgram(program); +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseProgram(cl_program program) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return program->dispatch->clReleaseProgram(program); +} + +CL_API_ENTRY cl_int CL_API_CALL +clBuildProgram(cl_program program, + cl_uint num_devices, + const cl_device_id * device_list, + const char * options, + void (CL_CALLBACK *pfn_notify)(cl_program program, void * user_data), + void * user_data) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return program->dispatch->clBuildProgram( + program, + num_devices, + device_list, + options, + pfn_notify, + user_data); +} + +CL_API_ENTRY cl_int CL_API_CALL +clCompileProgram(cl_program program, + cl_uint num_devices, + const cl_device_id * device_list, + const char * options, + cl_uint num_input_headers, + const cl_program * input_headers, + const char ** header_include_names, + void (CL_CALLBACK * pfn_notify)(cl_program program, void * user_data), + void * user_data) CL_API_SUFFIX__VERSION_1_2 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return program->dispatch->clCompileProgram( + program, + num_devices, + device_list, + options, + num_input_headers, + input_headers, + header_include_names, + pfn_notify, + user_data); +} + +CL_API_ENTRY cl_program CL_API_CALL +clLinkProgram(cl_context context, + cl_uint num_devices, + const cl_device_id * device_list, + const char * options, + cl_uint num_input_programs, + const cl_program * input_programs, + void (CL_CALLBACK * pfn_notify)(cl_program program, void * user_data), + void * user_data, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clLinkProgram( + context, + num_devices, + device_list, + options, + num_input_programs, + input_programs, + pfn_notify, + user_data, + errcode_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clUnloadPlatformCompiler(cl_platform_id platform) CL_API_SUFFIX__VERSION_1_2 +{ + // initialize the platforms (in case they have not been already) + khrIcdInitialize(); + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); + return platform->dispatch->clUnloadPlatformCompiler(platform); +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetProgramInfo(cl_program program, + cl_program_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return program->dispatch->clGetProgramInfo( + program, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetProgramBuildInfo(cl_program program, + cl_device_id device, + cl_program_build_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return program->dispatch->clGetProgramBuildInfo( + program, + device, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +// Kernel Object APIs +CL_API_ENTRY cl_kernel CL_API_CALL +clCreateKernel(cl_program program, + const char * kernel_name, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(program, CL_INVALID_PROGRAM); + return program->dispatch->clCreateKernel( + program, + kernel_name, + errcode_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clCreateKernelsInProgram(cl_program program, + cl_uint num_kernels, + cl_kernel * kernels, + cl_uint * num_kernels_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return program->dispatch->clCreateKernelsInProgram( + program, + num_kernels, + kernels, + num_kernels_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainKernel(cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return kernel->dispatch->clRetainKernel(kernel); +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseKernel(cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return kernel->dispatch->clReleaseKernel(kernel); +} + +CL_API_ENTRY cl_int CL_API_CALL +clSetKernelArg(cl_kernel kernel, + cl_uint arg_index, + size_t arg_size, + const void * arg_value) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return kernel->dispatch->clSetKernelArg( + kernel, + arg_index, + arg_size, + arg_value); +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetKernelInfo(cl_kernel kernel, + cl_kernel_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return kernel->dispatch->clGetKernelInfo( + kernel, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetKernelArgInfo(cl_kernel kernel, + cl_uint arg_indx, + cl_kernel_arg_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_2 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return kernel->dispatch->clGetKernelArgInfo( + kernel, + arg_indx, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetKernelWorkGroupInfo(cl_kernel kernel, + cl_device_id device, + cl_kernel_work_group_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return kernel->dispatch->clGetKernelWorkGroupInfo( + kernel, + device, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +// Event Object APIs +CL_API_ENTRY cl_int CL_API_CALL +clWaitForEvents(cl_uint num_events, + const cl_event * event_list) CL_API_SUFFIX__VERSION_1_0 +{ + if (!num_events || !event_list) + { + return CL_INVALID_VALUE; + } + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event_list[0], CL_INVALID_EVENT); + return event_list[0]->dispatch->clWaitForEvents( + num_events, + event_list); +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetEventInfo(cl_event event, + cl_event_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); + return event->dispatch->clGetEventInfo( + event, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainEvent(cl_event event) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); + return event->dispatch->clRetainEvent(event); +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseEvent(cl_event event) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); + return event->dispatch->clReleaseEvent(event); +} + +// Profiling APIs +CL_API_ENTRY cl_int CL_API_CALL +clGetEventProfilingInfo(cl_event event, + cl_profiling_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); + return event->dispatch->clGetEventProfilingInfo( + event, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +// Flush and Finish APIs +CL_API_ENTRY cl_int CL_API_CALL +clFlush(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clFlush(command_queue); +} + +CL_API_ENTRY cl_int CL_API_CALL +clFinish(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clFinish(command_queue); +} + +// Enqueued Commands APIs +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReadBuffer(cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_read, + size_t offset, + size_t cb, + void * ptr, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueReadBuffer( + command_queue, + buffer, + blocking_read, + offset, + cb, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReadBufferRect( + cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_read, + const size_t * buffer_origin, + const size_t * host_origin, + const size_t * region, + size_t buffer_row_pitch, + size_t buffer_slice_pitch, + size_t host_row_pitch, + size_t host_slice_pitch, + void * ptr, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_1 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueReadBufferRect( + command_queue, + buffer, + blocking_read, + buffer_origin, + host_origin, + region, + buffer_row_pitch, + buffer_slice_pitch, + host_row_pitch, + host_slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueWriteBuffer(cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_write, + size_t offset, + size_t cb, + const void * ptr, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueWriteBuffer( + command_queue, + buffer, + blocking_write, + offset, + cb, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueWriteBufferRect( + cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_read, + const size_t * buffer_origin, + const size_t * host_origin, + const size_t * region, + size_t buffer_row_pitch, + size_t buffer_slice_pitch, + size_t host_row_pitch, + size_t host_slice_pitch, + const void * ptr, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_1 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueWriteBufferRect( + command_queue, + buffer, + blocking_read, + buffer_origin, + host_origin, + region, + buffer_row_pitch, + buffer_slice_pitch, + host_row_pitch, + host_slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueFillBuffer(cl_command_queue command_queue, + cl_mem buffer, + const void * pattern, + size_t pattern_size, + size_t offset, + size_t cb, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_2 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueFillBuffer( + command_queue, + buffer, + pattern, + pattern_size, + offset, + cb, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueCopyBuffer(cl_command_queue command_queue, + cl_mem src_buffer, + cl_mem dst_buffer, + size_t src_offset, + size_t dst_offset, + size_t cb, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueCopyBuffer( + command_queue, + src_buffer, + dst_buffer, + src_offset, + dst_offset, + cb, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueCopyBufferRect( + cl_command_queue command_queue, + cl_mem src_buffer, + cl_mem dst_buffer, + const size_t * src_origin, + const size_t * dst_origin, + const size_t * region, + size_t src_row_pitch, + size_t src_slice_pitch, + size_t dst_row_pitch, + size_t dst_slice_pitch, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_1 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueCopyBufferRect( + command_queue, + src_buffer, + dst_buffer, + src_origin, + dst_origin, + region, + src_row_pitch, + src_slice_pitch, + dst_row_pitch, + dst_slice_pitch, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReadImage(cl_command_queue command_queue, + cl_mem image, + cl_bool blocking_read, + const size_t * origin, + const size_t * region, + size_t row_pitch, + size_t slice_pitch, + void * ptr, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueReadImage( + command_queue, + image, + blocking_read, + origin, + region, + row_pitch, + slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueWriteImage(cl_command_queue command_queue, + cl_mem image, + cl_bool blocking_write, + const size_t * origin, + const size_t * region, + size_t input_row_pitch, + size_t input_slice_pitch, + const void * ptr, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueWriteImage( + command_queue, + image, + blocking_write, + origin, + region, + input_row_pitch, + input_slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueFillImage(cl_command_queue command_queue, + cl_mem image, + const void * fill_color, + const size_t origin[3], + const size_t region[3], + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_2 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueFillImage( + command_queue, + image, + fill_color, + origin, + region, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueCopyImage(cl_command_queue command_queue, + cl_mem src_image, + cl_mem dst_image, + const size_t * src_origin, + const size_t * dst_origin, + const size_t * region, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueCopyImage( + command_queue, + src_image, + dst_image, + src_origin, + dst_origin, + region, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueCopyImageToBuffer(cl_command_queue command_queue, + cl_mem src_image, + cl_mem dst_buffer, + const size_t * src_origin, + const size_t * region, + size_t dst_offset, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueCopyImageToBuffer( + command_queue, + src_image, + dst_buffer, + src_origin, + region, + dst_offset, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueCopyBufferToImage(cl_command_queue command_queue, + cl_mem src_buffer, + cl_mem dst_image, + size_t src_offset, + const size_t * dst_origin, + const size_t * region, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueCopyBufferToImage( + command_queue, + src_buffer, + dst_image, + src_offset, + dst_origin, + region, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY void * CL_API_CALL +clEnqueueMapBuffer(cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_map, + cl_map_flags map_flags, + size_t offset, + size_t cb, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueMapBuffer( + command_queue, + buffer, + blocking_map, + map_flags, + offset, + cb, + num_events_in_wait_list, + event_wait_list, + event, + errcode_ret); +} + +CL_API_ENTRY void * CL_API_CALL +clEnqueueMapImage(cl_command_queue command_queue, + cl_mem image, + cl_bool blocking_map, + cl_map_flags map_flags, + const size_t * origin, + const size_t * region, + size_t * image_row_pitch, + size_t * image_slice_pitch, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueMapImage( + command_queue, + image, + blocking_map, + map_flags, + origin, + region, + image_row_pitch, + image_slice_pitch, + num_events_in_wait_list, + event_wait_list, + event, + errcode_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueUnmapMemObject(cl_command_queue command_queue, + cl_mem memobj, + void * mapped_ptr, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueUnmapMemObject( + command_queue, + memobj, + mapped_ptr, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueMigrateMemObjects(cl_command_queue command_queue, + cl_uint num_mem_objects, + const cl_mem * mem_objects, + cl_mem_migration_flags flags, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_2 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueMigrateMemObjects( + command_queue, + num_mem_objects, + mem_objects, + flags, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueNDRangeKernel(cl_command_queue command_queue, + cl_kernel kernel, + cl_uint work_dim, + const size_t * global_work_offset, + const size_t * global_work_size, + const size_t * local_work_size, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueNDRangeKernel( + command_queue, + kernel, + work_dim, + global_work_offset, + global_work_size, + local_work_size, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueTask(cl_command_queue command_queue, + cl_kernel kernel, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueTask( + command_queue, + kernel, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueNativeKernel(cl_command_queue command_queue, + void (CL_CALLBACK * user_func)(void *), + void * args, + size_t cb_args, + cl_uint num_mem_objects, + const cl_mem * mem_list, + const void ** args_mem_loc, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueNativeKernel( + command_queue, + user_func, + args, + cb_args, + num_mem_objects, + mem_list, + args_mem_loc, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueMarkerWithWaitList(cl_command_queue command_queue, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_2 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueMarkerWithWaitList( + command_queue, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueBarrierWithWaitList(cl_command_queue command_queue, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_2 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueBarrierWithWaitList( + command_queue, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY void * CL_API_CALL +clGetExtensionFunctionAddressForPlatform(cl_platform_id platform, + const char * function_name) CL_API_SUFFIX__VERSION_1_2 +{ + // make sure the ICD is initialized + khrIcdInitialize(); + + // return any ICD-aware extensions + #define CL_COMMON_EXTENSION_ENTRYPOINT_ADD(name) if (!strcmp(function_name, #name) ) return (void *)&name + + // Are these core or ext? This is unclear, but they appear to be + // independent from cl_khr_gl_sharing. + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLBuffer); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLTexture); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLTexture2D); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLTexture3D); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLRenderbuffer); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetGLObjectInfo); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetGLTextureInfo); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireGLObjects); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseGLObjects); + + // cl_khr_gl_sharing + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetGLContextInfoKHR); + + // cl_khr_gl_event + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateEventFromGLsyncKHR); + +#if defined(_WIN32) + // cl_khr_d3d10_sharing + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetDeviceIDsFromD3D10KHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D10BufferKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D10Texture2DKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D10Texture3DKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireD3D10ObjectsKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseD3D10ObjectsKHR); + // cl_khr_d3d11_sharing + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetDeviceIDsFromD3D11KHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D11BufferKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D11Texture2DKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D11Texture3DKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireD3D11ObjectsKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseD3D11ObjectsKHR); + // cl_khr_dx9_media_sharing + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetDeviceIDsFromDX9MediaAdapterKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromDX9MediaSurfaceKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireDX9MediaSurfacesKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseDX9MediaSurfacesKHR); +#endif + + // cl_ext_device_fission + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateSubDevicesEXT); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clRetainDeviceEXT); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clReleaseDeviceEXT); + + // fall back to vendor extension detection + + // FIXME Now that we have a platform id here, we need to validate that it isn't NULL, so shouldn't we have an errcode_ret + // KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(platform, CL_INVALID_PLATFORM); + return platform->dispatch->clGetExtensionFunctionAddressForPlatform( + platform, + function_name); +} + +// Deprecated APIs +CL_API_ENTRY cl_int CL_API_CALL +clSetCommandQueueProperty(cl_command_queue command_queue, + cl_command_queue_properties properties, + cl_bool enable, + cl_command_queue_properties * old_properties) CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clSetCommandQueueProperty( + command_queue, + properties, + enable, + old_properties); +} + +CL_API_ENTRY cl_int CL_API_CALL +clCreateSubDevicesEXT( + cl_device_id in_device, + const cl_device_partition_property_ext * partition_properties, + cl_uint num_entries, + cl_device_id * out_devices, + cl_uint * num_devices) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(in_device, CL_INVALID_DEVICE); + return in_device->dispatch->clCreateSubDevicesEXT( + in_device, + partition_properties, + num_entries, + out_devices, + num_devices); +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainDeviceEXT(cl_device_id device) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); + return device->dispatch->clRetainDeviceEXT(device); +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseDeviceEXT(cl_device_id device) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); + return device->dispatch->clReleaseDeviceEXT(device); +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateImage2D(cl_context context, + cl_mem_flags flags, + const cl_image_format * image_format, + size_t image_width, + size_t image_height, + size_t image_row_pitch, + void * host_ptr, + cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateImage2D( + context, + flags, + image_format, + image_width, + image_height, + image_row_pitch, + host_ptr, + errcode_ret); +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateImage3D(cl_context context, + cl_mem_flags flags, + const cl_image_format * image_format, + size_t image_width, + size_t image_height, + size_t image_depth, + size_t image_row_pitch, + size_t image_slice_pitch, + void * host_ptr, + cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateImage3D( + context, + flags, + image_format, + image_width, + image_height, + image_depth, + image_row_pitch, + image_slice_pitch, + host_ptr, + errcode_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clUnloadCompiler(void) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED +{ + return CL_SUCCESS; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueMarker(cl_command_queue command_queue, + cl_event * event) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueMarker( + command_queue, + event); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueWaitForEvents(cl_command_queue command_queue, + cl_uint num_events, + const cl_event * event_list) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueWaitForEvents( + command_queue, + num_events, + event_list); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueBarrier(cl_command_queue command_queue) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueBarrier(command_queue); +} + +CL_API_ENTRY void * CL_API_CALL +clGetExtensionFunctionAddress(const char *function_name) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED +{ + size_t function_name_length = strlen(function_name); + KHRicdVendor* vendor = NULL; + + // make sure the ICD is initialized + khrIcdInitialize(); + + // return any ICD-aware extensions + #define CL_COMMON_EXTENSION_ENTRYPOINT_ADD(name) if (!strcmp(function_name, #name) ) return (void *)&name + + // Are these core or ext? This is unclear, but they appear to be + // independent from cl_khr_gl_sharing. + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLBuffer); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLTexture); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLTexture2D); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLTexture3D); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLRenderbuffer); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetGLObjectInfo); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetGLTextureInfo); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireGLObjects); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseGLObjects); + + // cl_khr_gl_sharing + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetGLContextInfoKHR); + + // cl_khr_gl_event + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateEventFromGLsyncKHR); + +#if defined(_WIN32) + // cl_khr_d3d10_sharing + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetDeviceIDsFromD3D10KHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D10BufferKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D10Texture2DKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D10Texture3DKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireD3D10ObjectsKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseD3D10ObjectsKHR); + // cl_khr_d3d11_sharing + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetDeviceIDsFromD3D11KHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D11BufferKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D11Texture2DKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D11Texture3DKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireD3D11ObjectsKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseD3D11ObjectsKHR); + // cl_khr_dx9_media_sharing + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetDeviceIDsFromDX9MediaAdapterKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromDX9MediaSurfaceKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireDX9MediaSurfacesKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseDX9MediaSurfacesKHR); +#endif + + // cl_ext_device_fission + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateSubDevicesEXT); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clRetainDeviceEXT); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clReleaseDeviceEXT); + + // fall back to vendor extension detection + for (vendor = khrIcdState.vendors; vendor; vendor = vendor->next) + { + size_t vendor_suffix_length = strlen(vendor->suffix); + if (vendor_suffix_length <= function_name_length && vendor_suffix_length > 0) + { + const char *function_suffix = function_name+function_name_length-vendor_suffix_length; + if (!strcmp(function_suffix, vendor->suffix) ) + { + return vendor->clGetExtensionFunctionAddress(function_name); + } + } + } + return NULL; +} + +// GL and other APIs +CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLBuffer( + cl_context context, + cl_mem_flags flags, + GLuint bufobj, + int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateFromGLBuffer( + context, + flags, + bufobj, + errcode_ret); +} + +CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLTexture( + cl_context context, + cl_mem_flags flags, + cl_GLenum target, + cl_GLint miplevel, + cl_GLuint texture, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateFromGLTexture( + context, + flags, + target, + miplevel, + texture, + errcode_ret); +} + +CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLTexture2D( + cl_context context, + cl_mem_flags flags, + GLenum target, + GLint miplevel, + GLuint texture, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateFromGLTexture2D( + context, + flags, + target, + miplevel, + texture, + errcode_ret); +} + +CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLTexture3D( + cl_context context, + cl_mem_flags flags, + GLenum target, + GLint miplevel, + GLuint texture, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateFromGLTexture3D( + context, + flags, + target, + miplevel, + texture, + errcode_ret); +} + +CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLRenderbuffer( + cl_context context, + cl_mem_flags flags, + GLuint renderbuffer, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateFromGLRenderbuffer( + context, + flags, + renderbuffer, + errcode_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL clGetGLObjectInfo( + cl_mem memobj, + cl_gl_object_type * gl_object_type, + GLuint * gl_object_name) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); + return memobj->dispatch->clGetGLObjectInfo( + memobj, + gl_object_type, + gl_object_name); +} + +CL_API_ENTRY cl_int CL_API_CALL clGetGLTextureInfo( + cl_mem memobj, + cl_gl_texture_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); + return memobj->dispatch->clGetGLTextureInfo( + memobj, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueAcquireGLObjects( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem * mem_objects, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueAcquireGLObjects( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueReleaseGLObjects( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem * mem_objects, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueReleaseGLObjects( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY cl_int CL_API_CALL clGetGLContextInfoKHR( + const cl_context_properties *properties, + cl_gl_context_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_platform_id platform = NULL; + + // initialize the platforms (in case they have not been already) + khrIcdInitialize(); + + // determine the platform to use from the properties specified + khrIcdContextPropertiesGetPlatform(properties, &platform); + + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); + return platform->dispatch->clGetGLContextInfoKHR( + properties, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +CL_API_ENTRY cl_event CL_API_CALL clCreateEventFromGLsyncKHR( + cl_context context, + cl_GLsync sync, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_1 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateEventFromGLsyncKHR( + context, + sync, + errcode_ret); +} + +#if defined(_WIN32) +/* + * + * cl_d3d10_sharing_khr + * + */ + +CL_API_ENTRY cl_int CL_API_CALL +clGetDeviceIDsFromD3D10KHR( + cl_platform_id platform, + cl_d3d10_device_source_khr d3d_device_source, + void *d3d_object, + cl_d3d10_device_set_khr d3d_device_set, + cl_uint num_entries, + cl_device_id *devices, + cl_uint *num_devices) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); + return platform->dispatch->clGetDeviceIDsFromD3D10KHR( + platform, + d3d_device_source, + d3d_object, + d3d_device_set, + num_entries, + devices, + num_devices); +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D10BufferKHR( + cl_context context, + cl_mem_flags flags, + ID3D10Buffer *resource, + cl_int *errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateFromD3D10BufferKHR( + context, + flags, + resource, + errcode_ret); +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D10Texture2DKHR( + cl_context context, + cl_mem_flags flags, + ID3D10Texture2D * resource, + UINT subresource, + cl_int * errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateFromD3D10Texture2DKHR( + context, + flags, + resource, + subresource, + errcode_ret); +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D10Texture3DKHR( + cl_context context, + cl_mem_flags flags, + ID3D10Texture3D *resource, + UINT subresource, + cl_int *errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateFromD3D10Texture3DKHR( + context, + flags, + resource, + subresource, + errcode_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueAcquireD3D10ObjectsKHR( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem *mem_objects, + cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueAcquireD3D10ObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReleaseD3D10ObjectsKHR( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem *mem_objects, + cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueReleaseD3D10ObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} + +/* + * + * cl_d3d11_sharing_khr + * + */ + +CL_API_ENTRY cl_int CL_API_CALL +clGetDeviceIDsFromD3D11KHR( + cl_platform_id platform, + cl_d3d11_device_source_khr d3d_device_source, + void * d3d_object, + cl_d3d11_device_set_khr d3d_device_set, + cl_uint num_entries, + cl_device_id * devices, + cl_uint * num_devices) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); + return platform->dispatch->clGetDeviceIDsFromD3D11KHR( + platform, + d3d_device_source, + d3d_object, + d3d_device_set, + num_entries, + devices, + num_devices); +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D11BufferKHR( + cl_context context, + cl_mem_flags flags, + ID3D11Buffer * resource, + cl_int * errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateFromD3D11BufferKHR( + context, + flags, + resource, + errcode_ret); +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D11Texture2DKHR( + cl_context context, + cl_mem_flags flags, + ID3D11Texture2D * resource, + UINT subresource, + cl_int * errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateFromD3D11Texture2DKHR( + context, + flags, + resource, + subresource, + errcode_ret); +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D11Texture3DKHR( + cl_context context, + cl_mem_flags flags, + ID3D11Texture3D * resource, + UINT subresource, + cl_int * errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateFromD3D11Texture3DKHR( + context, + flags, + resource, + subresource, + errcode_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueAcquireD3D11ObjectsKHR( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem * mem_objects, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueAcquireD3D11ObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReleaseD3D11ObjectsKHR( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem * mem_objects, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueReleaseD3D11ObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} + +/* + * + * cl_khr_dx9_media_sharing + * + */ + +CL_API_ENTRY cl_int CL_API_CALL +clGetDeviceIDsFromDX9MediaAdapterKHR( + cl_platform_id platform, + cl_uint num_media_adapters, + cl_dx9_media_adapter_type_khr * media_adapters_type, + void * media_adapters[], + cl_dx9_media_adapter_set_khr media_adapter_set, + cl_uint num_entries, + cl_device_id * devices, + cl_uint * num_devices) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); + return platform->dispatch->clGetDeviceIDsFromDX9MediaAdapterKHR( + platform, + num_media_adapters, + media_adapters_type, + media_adapters, + media_adapter_set, + num_entries, + devices, + num_devices); +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromDX9MediaSurfaceKHR( + cl_context context, + cl_mem_flags flags, + cl_dx9_media_adapter_type_khr adapter_type, + void * surface_info, + cl_uint plane, + cl_int * errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateFromDX9MediaSurfaceKHR( + context, + flags, + adapter_type, + surface_info, + plane, + errcode_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueAcquireDX9MediaSurfacesKHR( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem * mem_objects, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueAcquireDX9MediaSurfacesKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReleaseDX9MediaSurfacesKHR( + cl_command_queue command_queue, + cl_uint num_objects, + cl_mem * mem_objects, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueReleaseDX9MediaSurfacesKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} + +#endif + +CL_API_ENTRY cl_int CL_API_CALL +clSetEventCallback( + cl_event event, + cl_int command_exec_callback_type, + void (CL_CALLBACK *pfn_notify)(cl_event, cl_int, void *), + void *user_data) CL_API_SUFFIX__VERSION_1_1 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); + return event->dispatch->clSetEventCallback( + event, + command_exec_callback_type, + pfn_notify, + user_data); +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateSubBuffer( + cl_mem buffer, + cl_mem_flags flags, + cl_buffer_create_type buffer_create_type, + const void * buffer_create_info, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_1 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(buffer, CL_INVALID_MEM_OBJECT); + return buffer->dispatch->clCreateSubBuffer( + buffer, + flags, + buffer_create_type, + buffer_create_info, + errcode_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clSetMemObjectDestructorCallback( + cl_mem memobj, + void (CL_CALLBACK * pfn_notify)( cl_mem, void*), + void * user_data ) CL_API_SUFFIX__VERSION_1_1 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); + return memobj->dispatch->clSetMemObjectDestructorCallback( + memobj, + pfn_notify, + user_data); +} + +CL_API_ENTRY cl_event CL_API_CALL +clCreateUserEvent( + cl_context context, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_1 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateUserEvent( + context, + errcode_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clSetUserEventStatus( + cl_event event, + cl_int execution_status) CL_API_SUFFIX__VERSION_1_1 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); + return event->dispatch->clSetUserEventStatus( + event, + execution_status); +} + diff --git a/khronos_icd/icd_dispatch.h b/khronos_icd/icd_dispatch.h new file mode 100644 index 000000000..0d14fd08c --- /dev/null +++ b/khronos_icd/icd_dispatch.h @@ -0,0 +1,1283 @@ +/* + * Copyright (c) 2012 The Khronos Group Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software source and associated documentation files (the "Materials"), + * to use, copy, modify and compile the Materials to create a binary under the + * following terms and conditions: + * + * 1. The Materials shall NOT be distributed to any third party; + * + * 2. The binary may be distributed without restriction, including without + * limitation the rights to use, copy, merge, publish, distribute, sublicense, + * and/or sell copies, and to permit persons to whom the binary is furnished to + * do so; + * + * 3. All modifications to the Materials used to create a binary that is + * distributed to third parties shall be provided to Khronos with an + * unrestricted license to use for the purposes of implementing bug fixes and + * enhancements to the Materials; + * + * 4. If the binary is used as part of an OpenCL(TM) implementation, whether + * binary is distributed together with or separately to that implementation, + * then recipient must become an OpenCL Adopter and follow the published OpenCL + * conformance process for that implementation, details at: + * http://www.khronos.org/conformance/; + * + * 5. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Materials. + * + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN + * THE MATERIALS. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#ifndef _ICD_DISPATCH_H_ +#define _ICD_DISPATCH_H_ + +#ifndef CL_USE_DEPRECATED_OPENCL_1_0_APIS +#define CL_USE_DEPRECATED_OPENCL_1_0_APIS +#endif + +#ifndef CL_USE_DEPRECATED_OPENCL_1_1_APIS +#define CL_USE_DEPRECATED_OPENCL_1_1_APIS +#endif + +// cl.h +#include + +// cl_gl.h and required files +#ifdef _WIN32 +#include +#include +#include +#include +#include +#include +#endif +#include +#include +#include +#include + +/* + * + * function pointer typedefs + * + */ + +// Platform APIs +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetPlatformIDs)( + cl_uint num_entries, + cl_platform_id * platforms, + cl_uint * num_platforms) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetPlatformInfo)( + cl_platform_id platform, + cl_platform_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +// Device APIs +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetDeviceIDs)( + cl_platform_id platform, + cl_device_type device_type, + cl_uint num_entries, + cl_device_id * devices, + cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetDeviceInfo)( + cl_device_id device, + cl_device_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clCreateSubDevices)( + cl_device_id in_device, + const cl_device_partition_property * partition_properties, + cl_uint num_entries, + cl_device_id * out_devices, + cl_uint * num_devices); + +typedef CL_API_ENTRY cl_int (CL_API_CALL * KHRpfn_clRetainDevice)( + cl_device_id device) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY cl_int (CL_API_CALL * KHRpfn_clReleaseDevice)( + cl_device_id device) CL_API_SUFFIX__VERSION_1_2; + +// Context APIs +typedef CL_API_ENTRY cl_context (CL_API_CALL *KHRpfn_clCreateContext)( + const cl_context_properties * properties, + cl_uint num_devices, + const cl_device_id * devices, + void (CL_CALLBACK *pfn_notify)(const char *, const void *, size_t, void *), + void * user_data, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_context (CL_API_CALL *KHRpfn_clCreateContextFromType)( + const cl_context_properties * properties, + cl_device_type device_type, + void (CL_CALLBACK *pfn_notify)(const char *, const void *, size_t, void *), + void * user_data, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clRetainContext)( + cl_context context) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clReleaseContext)( + cl_context context) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetContextInfo)( + cl_context context, + cl_context_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +// Command Queue APIs +typedef CL_API_ENTRY cl_command_queue (CL_API_CALL *KHRpfn_clCreateCommandQueue)( + cl_context context, + cl_device_id device, + cl_command_queue_properties properties, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clRetainCommandQueue)( + cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clReleaseCommandQueue)( + cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetCommandQueueInfo)( + cl_command_queue command_queue, + cl_command_queue_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +// Memory Object APIs +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateBuffer)( + cl_context context, + cl_mem_flags flags, + size_t size, + void * host_ptr, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateImage)( + cl_context context, + cl_mem_flags flags, + const cl_image_format * image_format, + const cl_image_desc * image_desc, + void * host_ptr, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clRetainMemObject)(cl_mem memobj) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clReleaseMemObject)(cl_mem memobj) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetSupportedImageFormats)( + cl_context context, + cl_mem_flags flags, + cl_mem_object_type image_type, + cl_uint num_entries, + cl_image_format * image_formats, + cl_uint * num_image_formats) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetMemObjectInfo)( + cl_mem memobj, + cl_mem_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetImageInfo)( + cl_mem image, + cl_image_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +// Sampler APIs +typedef CL_API_ENTRY cl_sampler (CL_API_CALL *KHRpfn_clCreateSampler)( + cl_context context, + cl_bool normalized_coords, + cl_addressing_mode addressing_mode, + cl_filter_mode filter_mode, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clRetainSampler)(cl_sampler sampler) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clReleaseSampler)(cl_sampler sampler) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetSamplerInfo)( + cl_sampler sampler, + cl_sampler_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +// Program Object APIs +typedef CL_API_ENTRY cl_program (CL_API_CALL *KHRpfn_clCreateProgramWithSource)( + cl_context context, + cl_uint count, + const char ** strings, + const size_t * lengths, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_program (CL_API_CALL *KHRpfn_clCreateProgramWithBinary)( + cl_context context, + cl_uint num_devices, + const cl_device_id * device_list, + const size_t * lengths, + const unsigned char ** binaries, + cl_int * binary_status, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_program (CL_API_CALL *KHRpfn_clCreateProgramWithBuiltInKernels)( + cl_context context, + cl_uint num_devices, + const cl_device_id * device_list, + const char * kernel_names, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clRetainProgram)(cl_program program) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clReleaseProgram)(cl_program program) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clBuildProgram)( + cl_program program, + cl_uint num_devices, + const cl_device_id * device_list, + const char * options, + void (CL_CALLBACK *pfn_notify)(cl_program program, void * user_data), + void * user_data) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clCompileProgram)( + cl_program program, + cl_uint num_devices, + const cl_device_id * device_list, + const char * options, + cl_uint num_input_headers, + const cl_program * input_headers, + const char ** header_include_names, + void (CL_CALLBACK * pfn_notify)(cl_program program, void * user_data), + void * user_data) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY cl_program (CL_API_CALL *KHRpfn_clLinkProgram)( + cl_context context, + cl_uint num_devices, + const cl_device_id * device_list, + const char * options, + cl_uint num_input_programs, + const cl_program * input_programs, + void (CL_CALLBACK * pfn_notify)(cl_program program, void * user_data), + void * user_data, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clUnloadPlatformCompiler)( + cl_platform_id platform) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetProgramInfo)( + cl_program program, + cl_program_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetProgramBuildInfo)( + cl_program program, + cl_device_id device, + cl_program_build_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +// Kernel Object APIs +typedef CL_API_ENTRY cl_kernel (CL_API_CALL *KHRpfn_clCreateKernel)( + cl_program program, + const char * kernel_name, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clCreateKernelsInProgram)( + cl_program program, + cl_uint num_kernels, + cl_kernel * kernels, + cl_uint * num_kernels_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clRetainKernel)(cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clReleaseKernel)(cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clSetKernelArg)( + cl_kernel kernel, + cl_uint arg_index, + size_t arg_size, + const void * arg_value) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetKernelInfo)( + cl_kernel kernel, + cl_kernel_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetKernelArgInfo)( + cl_kernel kernel, + cl_uint arg_indx, + cl_kernel_arg_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetKernelWorkGroupInfo)( + cl_kernel kernel, + cl_device_id device, + cl_kernel_work_group_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +// Event Object APIs +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clWaitForEvents)( + cl_uint num_events, + const cl_event * event_list) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetEventInfo)( + cl_event event, + cl_event_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clRetainEvent)(cl_event event) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clReleaseEvent)(cl_event event) CL_API_SUFFIX__VERSION_1_0; + +// Profiling APIs +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetEventProfilingInfo)( + cl_event event, + cl_profiling_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +// Flush and Finish APIs +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clFlush)(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clFinish)(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0; + +// Enqueued Commands APIs +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueReadBuffer)( + cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_read, + size_t offset, + size_t cb, + void * ptr, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueReadBufferRect)( + cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_read, + const size_t * buffer_origin, + const size_t * host_origin, + const size_t * region, + size_t buffer_row_pitch, + size_t buffer_slice_pitch, + size_t host_row_pitch, + size_t host_slice_pitch, + void * ptr, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_1; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueWriteBuffer)( + cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_write, + size_t offset, + size_t cb, + const void * ptr, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueWriteBufferRect)( + cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_read, + const size_t * buffer_origin, + const size_t * host_origin, + const size_t * region, + size_t buffer_row_pitch, + size_t buffer_slice_pitch, + size_t host_row_pitch, + size_t host_slice_pitch, + const void * ptr, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_1; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueFillBuffer)( + cl_command_queue command_queue, + cl_mem buffer, + const void * pattern, + size_t pattern_size, + size_t offset, + size_t cb, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueCopyBuffer)( + cl_command_queue command_queue, + cl_mem src_buffer, + cl_mem dst_buffer, + size_t src_offset, + size_t dst_offset, + size_t cb, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueCopyBufferRect)( + cl_command_queue command_queue, + cl_mem src_buffer, + cl_mem dst_buffer, + const size_t * src_origin, + const size_t * dst_origin, + const size_t * region, + size_t src_row_pitch, + size_t src_slice_pitch, + size_t dst_row_pitch, + size_t dst_slice_pitch, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_1; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueReadImage)( + cl_command_queue command_queue, + cl_mem image, + cl_bool blocking_read, + const size_t * origin, + const size_t * region, + size_t row_pitch, + size_t slice_pitch, + void * ptr, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueWriteImage)( + cl_command_queue command_queue, + cl_mem image, + cl_bool blocking_write, + const size_t * origin, + const size_t * region, + size_t input_row_pitch, + size_t input_slice_pitch, + const void * ptr, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueFillImage)( + cl_command_queue command_queue, + cl_mem image, + const void * fill_color, + const size_t origin[3], + const size_t region[3], + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueCopyImage)( + cl_command_queue command_queue, + cl_mem src_image, + cl_mem dst_image, + const size_t * src_origin, + const size_t * dst_origin, + const size_t * region, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueCopyImageToBuffer)( + cl_command_queue command_queue, + cl_mem src_image, + cl_mem dst_buffer, + const size_t * src_origin, + const size_t * region, + size_t dst_offset, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueCopyBufferToImage)( + cl_command_queue command_queue, + cl_mem src_buffer, + cl_mem dst_image, + size_t src_offset, + const size_t * dst_origin, + const size_t * region, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY void * (CL_API_CALL *KHRpfn_clEnqueueMapBuffer)( + cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_map, + cl_map_flags map_flags, + size_t offset, + size_t cb, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY void * (CL_API_CALL *KHRpfn_clEnqueueMapImage)( + cl_command_queue command_queue, + cl_mem image, + cl_bool blocking_map, + cl_map_flags map_flags, + const size_t * origin, + const size_t * region, + size_t * image_row_pitch, + size_t * image_slice_pitch, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueUnmapMemObject)( + cl_command_queue command_queue, + cl_mem memobj, + void * mapped_ptr, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueMigrateMemObjects)( + cl_command_queue command_queue, + cl_uint num_mem_objects, + const cl_mem * mem_objects, + cl_mem_migration_flags flags, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueNDRangeKernel)( + cl_command_queue command_queue, + cl_kernel kernel, + cl_uint work_dim, + const size_t * global_work_offset, + const size_t * global_work_size, + const size_t * local_work_size, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueTask)( + cl_command_queue command_queue, + cl_kernel kernel, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueNativeKernel)( + cl_command_queue command_queue, + void (CL_CALLBACK * user_func)(void *), + void * args, + size_t cb_args, + cl_uint num_mem_objects, + const cl_mem * mem_list, + const void ** args_mem_loc, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueMarkerWithWaitList)( + cl_command_queue command_queue, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueBarrierWithWaitList)( + cl_command_queue command_queue, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY void * (CL_API_CALL *KHRpfn_clGetExtensionFunctionAddressForPlatform)( + cl_platform_id platform, + const char * function_name) CL_API_SUFFIX__VERSION_1_2; + +// Deprecated APIs +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clSetCommandQueueProperty)( + cl_command_queue command_queue, + cl_command_queue_properties properties, + cl_bool enable, + cl_command_queue_properties * old_properties) CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateImage2D)( + cl_context context, + cl_mem_flags flags, + const cl_image_format * image_format, + size_t image_width, + size_t image_height, + size_t image_row_pitch, + void * host_ptr, + cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateImage3D)( + cl_context context, + cl_mem_flags flags, + const cl_image_format * image_format, + size_t image_width, + size_t image_height, + size_t image_depth, + size_t image_row_pitch, + size_t image_slice_pitch, + void * host_ptr, + cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clUnloadCompiler)(void) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueMarker)( + cl_command_queue command_queue, + cl_event * event) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueWaitForEvents)( + cl_command_queue command_queue, + cl_uint num_events, + const cl_event * event_list) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueBarrier)(cl_command_queue command_queue) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; + +typedef CL_API_ENTRY void * (CL_API_CALL *KHRpfn_clGetExtensionFunctionAddress)(const char *function_name) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; + +// GL and other APIs +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromGLBuffer)( + cl_context context, + cl_mem_flags flags, + GLuint bufobj, + int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromGLTexture)( + cl_context context, + cl_mem_flags flags, + cl_GLenum target, + cl_GLint miplevel, + cl_GLuint texture, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromGLTexture2D)( + cl_context context, + cl_mem_flags flags, + GLenum target, + GLint miplevel, + GLuint texture, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromGLTexture3D)( + cl_context context, + cl_mem_flags flags, + GLenum target, + GLint miplevel, + GLuint texture, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromGLRenderbuffer)( + cl_context context, + cl_mem_flags flags, + GLuint renderbuffer, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetGLObjectInfo)( + cl_mem memobj, + cl_gl_object_type * gl_object_type, + GLuint * gl_object_name) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetGLTextureInfo)( + cl_mem memobj, + cl_gl_texture_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueAcquireGLObjects)( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem * mem_objects, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueReleaseGLObjects)( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem * mem_objects, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0; + +/* cl_khr_gl_sharing */ +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetGLContextInfoKHR)( + const cl_context_properties *properties, + cl_gl_context_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret); + +/* cl_khr_gl_event */ +typedef CL_API_ENTRY cl_event (CL_API_CALL *KHRpfn_clCreateEventFromGLsyncKHR)( + cl_context context, + cl_GLsync sync, + cl_int *errcode_ret); + + +#if defined(_WIN32) + +/* cl_khr_d3d10_sharing */ + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetDeviceIDsFromD3D10KHR)( + cl_platform_id platform, + cl_d3d10_device_source_khr d3d_device_source, + void * d3d_object, + cl_d3d10_device_set_khr d3d_device_set, + cl_uint num_entries, + cl_device_id * devices, + cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromD3D10BufferKHR)( + cl_context context, + cl_mem_flags flags, + ID3D10Buffer * resource, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromD3D10Texture2DKHR)( + cl_context context, + cl_mem_flags flags, + ID3D10Texture2D * resource, + UINT subresource, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromD3D10Texture3DKHR)( + cl_context context, + cl_mem_flags flags, + ID3D10Texture3D * resource, + UINT subresource, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueAcquireD3D10ObjectsKHR)( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem * mem_objects, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueReleaseD3D10ObjectsKHR)( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem * mem_objects, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetDeviceIDsFromD3D10KHR( + cl_platform_id platform, + cl_d3d10_device_source_khr d3d_device_source, + void *d3d_object, + cl_d3d10_device_set_khr d3d_device_set, + cl_uint num_entries, + cl_device_id *devices, + cl_uint *num_devices); + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D10BufferKHR( + cl_context context, + cl_mem_flags flags, + ID3D10Buffer *resource, + cl_int *errcode_ret); + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D10Texture2DKHR( + cl_context context, + cl_mem_flags flags, + ID3D10Texture2D * resource, + UINT subresource, + cl_int * errcode_ret); + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D10Texture3DKHR( + cl_context context, + cl_mem_flags flags, + ID3D10Texture3D *resource, + UINT subresource, + cl_int *errcode_ret); + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueAcquireD3D10ObjectsKHR( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem *mem_objects, + cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event); + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReleaseD3D10ObjectsKHR( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem *mem_objects, + cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event); + +/* cl_khr_d3d11_sharing */ +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetDeviceIDsFromD3D11KHR)( + cl_platform_id platform, + cl_d3d11_device_source_khr d3d_device_source, + void * d3d_object, + cl_d3d11_device_set_khr d3d_device_set, + cl_uint num_entries, + cl_device_id * devices, + cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromD3D11BufferKHR)( + cl_context context, + cl_mem_flags flags, + ID3D11Buffer * resource, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromD3D11Texture2DKHR)( + cl_context context, + cl_mem_flags flags, + ID3D11Texture2D * resource, + UINT subresource, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromD3D11Texture3DKHR)( + cl_context context, + cl_mem_flags flags, + ID3D11Texture3D * resource, + UINT subresource, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueAcquireD3D11ObjectsKHR)( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem * mem_objects, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueReleaseD3D11ObjectsKHR)( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem * mem_objects, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_2; + +/* cl_khr_dx9_media_sharing */ +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetDeviceIDsFromDX9MediaAdapterKHR)( + cl_platform_id platform, + cl_uint num_media_adapters, + cl_dx9_media_adapter_type_khr * media_adapters_type, + void * media_adapters, + cl_dx9_media_adapter_set_khr media_adapter_set, + cl_uint num_entries, + cl_device_id * devices, + cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromDX9MediaSurfaceKHR)( + cl_context context, + cl_mem_flags flags, + cl_dx9_media_adapter_type_khr adapter_type, + void * surface_info, + cl_uint plane, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueAcquireDX9MediaSurfacesKHR)( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem * mem_objects, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueReleaseDX9MediaSurfacesKHR)( + cl_command_queue command_queue, + cl_uint num_objects, + cl_mem * mem_objects, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_2; + +/* cl_khr_d3d11_sharing */ +extern CL_API_ENTRY cl_int CL_API_CALL +clGetDeviceIDsFromD3D11KHR( + cl_platform_id platform, + cl_d3d11_device_source_khr d3d_device_source, + void * d3d_object, + cl_d3d11_device_set_khr d3d_device_set, + cl_uint num_entries, + cl_device_id * devices, + cl_uint * num_devices); + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D11BufferKHR( + cl_context context, + cl_mem_flags flags, + ID3D11Buffer * resource, + cl_int * errcode_ret); + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D11Texture2DKHR( + cl_context context, + cl_mem_flags flags, + ID3D11Texture2D * resource, + UINT subresource, + cl_int * errcode_ret); + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D11Texture3DKHR( + cl_context context, + cl_mem_flags flags, + ID3D11Texture3D * resource, + UINT subresource, + cl_int * errcode_ret); + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueAcquireD3D11ObjectsKHR( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem * mem_objects, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event); + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReleaseD3D11ObjectsKHR( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem * mem_objects, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event); + +/* cl_khr_dx9_media_sharing */ +extern CL_API_ENTRY cl_int CL_API_CALL +clGetDeviceIDsFromDX9MediaAdapterKHR( + cl_platform_id platform, + cl_uint num_media_adapters, + cl_dx9_media_adapter_type_khr * media_adapter_type, + void * media_adapters, + cl_dx9_media_adapter_set_khr media_adapter_set, + cl_uint num_entries, + cl_device_id * devices, + cl_uint * num_devices); + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromDX9MediaSurfaceKHR( + cl_context context, + cl_mem_flags flags, + cl_dx9_media_adapter_type_khr adapter_type, + void * surface_info, + cl_uint plane, + cl_int * errcode_ret); + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueAcquireDX9MediaSurfacesKHR( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem * mem_objects, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event); + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReleaseDX9MediaSurfacesKHR( + cl_command_queue command_queue, + cl_uint num_objects, + cl_mem * mem_objects, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event); + +#else + +/* cl_khr_d3d10_sharing */ +typedef void *KHRpfn_clGetDeviceIDsFromD3D10KHR; +typedef void *KHRpfn_clCreateFromD3D10BufferKHR; +typedef void *KHRpfn_clCreateFromD3D10Texture2DKHR; +typedef void *KHRpfn_clCreateFromD3D10Texture3DKHR; +typedef void *KHRpfn_clEnqueueAcquireD3D10ObjectsKHR; +typedef void *KHRpfn_clEnqueueReleaseD3D10ObjectsKHR; + +/* cl_khr_d3d11_sharing */ +typedef void *KHRpfn_clGetDeviceIDsFromD3D11KHR; +typedef void *KHRpfn_clCreateFromD3D11BufferKHR; +typedef void *KHRpfn_clCreateFromD3D11Texture2DKHR; +typedef void *KHRpfn_clCreateFromD3D11Texture3DKHR; +typedef void *KHRpfn_clEnqueueAcquireD3D11ObjectsKHR; +typedef void *KHRpfn_clEnqueueReleaseD3D11ObjectsKHR; + +/* cl_khr_dx9_media_sharing */ +typedef void *KHRpfn_clCreateFromDX9MediaSurfaceKHR; +typedef void *KHRpfn_clEnqueueAcquireDX9MediaSurfacesKHR; +typedef void *KHRpfn_clEnqueueReleaseDX9MediaSurfacesKHR; +typedef void *KHRpfn_clGetDeviceIDsFromDX9MediaAdapterKHR; + +#endif + +/* OpenCL 1.1 */ + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clSetEventCallback)( + cl_event /* event */, + cl_int /* command_exec_callback_type */, + void (CL_CALLBACK * /* pfn_notify */)(cl_event, cl_int, void *), + void * /* user_data */) CL_API_SUFFIX__VERSION_1_1; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateSubBuffer)( + cl_mem /* buffer */, + cl_mem_flags /* flags */, + cl_buffer_create_type /* buffer_create_type */, + const void * /* buffer_create_info */, + cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_1; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clSetMemObjectDestructorCallback)( + cl_mem /* memobj */, + void (CL_CALLBACK * /*pfn_notify*/)( cl_mem /* memobj */, void* /*user_data*/), + void * /*user_data */ ) CL_API_SUFFIX__VERSION_1_1; + +typedef CL_API_ENTRY cl_event (CL_API_CALL *KHRpfn_clCreateUserEvent)( + cl_context /* context */, + cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_1; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clSetUserEventStatus)( + cl_event /* event */, + cl_int /* execution_status */) CL_API_SUFFIX__VERSION_1_1; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clCreateSubDevicesEXT)( + cl_device_id in_device, + const cl_device_partition_property_ext * partition_properties, + cl_uint num_entries, + cl_device_id * out_devices, + cl_uint * num_devices); + +typedef CL_API_ENTRY cl_int (CL_API_CALL * KHRpfn_clRetainDeviceEXT)( + cl_device_id device) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL * KHRpfn_clReleaseDeviceEXT)( + cl_device_id device) CL_API_SUFFIX__VERSION_1_0; + +/* + * + * vendor dispatch table structure + * + * note that the types in the structure KHRicdVendorDispatch mirror the function + * names listed in the string table khrIcdVendorDispatchFunctionNames + * + */ + +typedef struct KHRicdVendorDispatchRec KHRicdVendorDispatch; + +struct KHRicdVendorDispatchRec +{ + KHRpfn_clGetPlatformIDs clGetPlatformIDs; + KHRpfn_clGetPlatformInfo clGetPlatformInfo; + KHRpfn_clGetDeviceIDs clGetDeviceIDs; + KHRpfn_clGetDeviceInfo clGetDeviceInfo; + KHRpfn_clCreateContext clCreateContext; + KHRpfn_clCreateContextFromType clCreateContextFromType; + KHRpfn_clRetainContext clRetainContext; + KHRpfn_clReleaseContext clReleaseContext; + KHRpfn_clGetContextInfo clGetContextInfo; + KHRpfn_clCreateCommandQueue clCreateCommandQueue; + KHRpfn_clRetainCommandQueue clRetainCommandQueue; + KHRpfn_clReleaseCommandQueue clReleaseCommandQueue; + KHRpfn_clGetCommandQueueInfo clGetCommandQueueInfo; + KHRpfn_clSetCommandQueueProperty clSetCommandQueueProperty; + KHRpfn_clCreateBuffer clCreateBuffer; + KHRpfn_clCreateImage2D clCreateImage2D; + KHRpfn_clCreateImage3D clCreateImage3D; + KHRpfn_clRetainMemObject clRetainMemObject; + KHRpfn_clReleaseMemObject clReleaseMemObject; + KHRpfn_clGetSupportedImageFormats clGetSupportedImageFormats; + KHRpfn_clGetMemObjectInfo clGetMemObjectInfo; + KHRpfn_clGetImageInfo clGetImageInfo; + KHRpfn_clCreateSampler clCreateSampler; + KHRpfn_clRetainSampler clRetainSampler; + KHRpfn_clReleaseSampler clReleaseSampler; + KHRpfn_clGetSamplerInfo clGetSamplerInfo; + KHRpfn_clCreateProgramWithSource clCreateProgramWithSource; + KHRpfn_clCreateProgramWithBinary clCreateProgramWithBinary; + KHRpfn_clRetainProgram clRetainProgram; + KHRpfn_clReleaseProgram clReleaseProgram; + KHRpfn_clBuildProgram clBuildProgram; + KHRpfn_clUnloadCompiler clUnloadCompiler; + KHRpfn_clGetProgramInfo clGetProgramInfo; + KHRpfn_clGetProgramBuildInfo clGetProgramBuildInfo; + KHRpfn_clCreateKernel clCreateKernel; + KHRpfn_clCreateKernelsInProgram clCreateKernelsInProgram; + KHRpfn_clRetainKernel clRetainKernel; + KHRpfn_clReleaseKernel clReleaseKernel; + KHRpfn_clSetKernelArg clSetKernelArg; + KHRpfn_clGetKernelInfo clGetKernelInfo; + KHRpfn_clGetKernelWorkGroupInfo clGetKernelWorkGroupInfo; + KHRpfn_clWaitForEvents clWaitForEvents; + KHRpfn_clGetEventInfo clGetEventInfo; + KHRpfn_clRetainEvent clRetainEvent; + KHRpfn_clReleaseEvent clReleaseEvent; + KHRpfn_clGetEventProfilingInfo clGetEventProfilingInfo; + KHRpfn_clFlush clFlush; + KHRpfn_clFinish clFinish; + KHRpfn_clEnqueueReadBuffer clEnqueueReadBuffer; + KHRpfn_clEnqueueWriteBuffer clEnqueueWriteBuffer; + KHRpfn_clEnqueueCopyBuffer clEnqueueCopyBuffer; + KHRpfn_clEnqueueReadImage clEnqueueReadImage; + KHRpfn_clEnqueueWriteImage clEnqueueWriteImage; + KHRpfn_clEnqueueCopyImage clEnqueueCopyImage; + KHRpfn_clEnqueueCopyImageToBuffer clEnqueueCopyImageToBuffer; + KHRpfn_clEnqueueCopyBufferToImage clEnqueueCopyBufferToImage; + KHRpfn_clEnqueueMapBuffer clEnqueueMapBuffer; + KHRpfn_clEnqueueMapImage clEnqueueMapImage; + KHRpfn_clEnqueueUnmapMemObject clEnqueueUnmapMemObject; + KHRpfn_clEnqueueNDRangeKernel clEnqueueNDRangeKernel; + KHRpfn_clEnqueueTask clEnqueueTask; + KHRpfn_clEnqueueNativeKernel clEnqueueNativeKernel; + KHRpfn_clEnqueueMarker clEnqueueMarker; + KHRpfn_clEnqueueWaitForEvents clEnqueueWaitForEvents; + KHRpfn_clEnqueueBarrier clEnqueueBarrier; + KHRpfn_clGetExtensionFunctionAddress clGetExtensionFunctionAddress; + KHRpfn_clCreateFromGLBuffer clCreateFromGLBuffer; + KHRpfn_clCreateFromGLTexture2D clCreateFromGLTexture2D; + KHRpfn_clCreateFromGLTexture3D clCreateFromGLTexture3D; + KHRpfn_clCreateFromGLRenderbuffer clCreateFromGLRenderbuffer; + KHRpfn_clGetGLObjectInfo clGetGLObjectInfo; + KHRpfn_clGetGLTextureInfo clGetGLTextureInfo; + KHRpfn_clEnqueueAcquireGLObjects clEnqueueAcquireGLObjects; + KHRpfn_clEnqueueReleaseGLObjects clEnqueueReleaseGLObjects; + KHRpfn_clGetGLContextInfoKHR clGetGLContextInfoKHR; + + KHRpfn_clGetDeviceIDsFromD3D10KHR clGetDeviceIDsFromD3D10KHR; + KHRpfn_clCreateFromD3D10BufferKHR clCreateFromD3D10BufferKHR; + KHRpfn_clCreateFromD3D10Texture2DKHR clCreateFromD3D10Texture2DKHR; + KHRpfn_clCreateFromD3D10Texture3DKHR clCreateFromD3D10Texture3DKHR; + KHRpfn_clEnqueueAcquireD3D10ObjectsKHR clEnqueueAcquireD3D10ObjectsKHR; + KHRpfn_clEnqueueReleaseD3D10ObjectsKHR clEnqueueReleaseD3D10ObjectsKHR; + + KHRpfn_clSetEventCallback clSetEventCallback; + KHRpfn_clCreateSubBuffer clCreateSubBuffer; + KHRpfn_clSetMemObjectDestructorCallback clSetMemObjectDestructorCallback; + KHRpfn_clCreateUserEvent clCreateUserEvent; + KHRpfn_clSetUserEventStatus clSetUserEventStatus; + KHRpfn_clEnqueueReadBufferRect clEnqueueReadBufferRect; + KHRpfn_clEnqueueWriteBufferRect clEnqueueWriteBufferRect; + KHRpfn_clEnqueueCopyBufferRect clEnqueueCopyBufferRect; + + KHRpfn_clCreateSubDevicesEXT clCreateSubDevicesEXT; + KHRpfn_clRetainDeviceEXT clRetainDeviceEXT; + KHRpfn_clReleaseDeviceEXT clReleaseDeviceEXT; + + KHRpfn_clCreateEventFromGLsyncKHR clCreateEventFromGLsyncKHR; + + KHRpfn_clCreateSubDevices clCreateSubDevices; + KHRpfn_clRetainDevice clRetainDevice; + KHRpfn_clReleaseDevice clReleaseDevice; + KHRpfn_clCreateImage clCreateImage; + KHRpfn_clCreateProgramWithBuiltInKernels clCreateProgramWithBuiltInKernels; + KHRpfn_clCompileProgram clCompileProgram; + KHRpfn_clLinkProgram clLinkProgram; + KHRpfn_clUnloadPlatformCompiler clUnloadPlatformCompiler; + KHRpfn_clGetKernelArgInfo clGetKernelArgInfo; + KHRpfn_clEnqueueFillBuffer clEnqueueFillBuffer; + KHRpfn_clEnqueueFillImage clEnqueueFillImage; + KHRpfn_clEnqueueMigrateMemObjects clEnqueueMigrateMemObjects; + KHRpfn_clEnqueueMarkerWithWaitList clEnqueueMarkerWithWaitList; + KHRpfn_clEnqueueBarrierWithWaitList clEnqueueBarrierWithWaitList; + KHRpfn_clGetExtensionFunctionAddressForPlatform clGetExtensionFunctionAddressForPlatform; + KHRpfn_clCreateFromGLTexture clCreateFromGLTexture; + + KHRpfn_clGetDeviceIDsFromD3D11KHR clGetDeviceIDsFromD3D11KHR; + KHRpfn_clCreateFromD3D11BufferKHR clCreateFromD3D11BufferKHR; + KHRpfn_clCreateFromD3D11Texture2DKHR clCreateFromD3D11Texture2DKHR; + KHRpfn_clCreateFromD3D11Texture3DKHR clCreateFromD3D11Texture3DKHR; + KHRpfn_clCreateFromDX9MediaSurfaceKHR clCreateFromDX9MediaSurfaceKHR; + KHRpfn_clEnqueueAcquireD3D11ObjectsKHR clEnqueueAcquireD3D11ObjectsKHR; + KHRpfn_clEnqueueReleaseD3D11ObjectsKHR clEnqueueReleaseD3D11ObjectsKHR; + + KHRpfn_clGetDeviceIDsFromDX9MediaAdapterKHR clGetDeviceIDsFromDX9MediaAdapterKHR; + KHRpfn_clEnqueueAcquireDX9MediaSurfacesKHR clEnqueueAcquireDX9MediaSurfacesKHR; + KHRpfn_clEnqueueReleaseDX9MediaSurfacesKHR clEnqueueReleaseDX9MediaSurfacesKHR; + +}; + +/* + * + * vendor dispatch table structure + * + */ + +struct _cl_platform_id +{ + KHRicdVendorDispatch *dispatch; +}; + +struct _cl_device_id +{ + KHRicdVendorDispatch *dispatch; +}; + +struct _cl_context +{ + KHRicdVendorDispatch *dispatch; +}; + +struct _cl_command_queue +{ + KHRicdVendorDispatch *dispatch; +}; + +struct _cl_mem +{ + KHRicdVendorDispatch *dispatch; +}; + +struct _cl_program +{ + KHRicdVendorDispatch *dispatch; +}; + +struct _cl_kernel +{ + KHRicdVendorDispatch *dispatch; +}; + +struct _cl_event +{ + KHRicdVendorDispatch *dispatch; +}; + +struct _cl_sampler +{ + KHRicdVendorDispatch *dispatch; +}; + +#endif // _ICD_DISPATCH_H_ + diff --git a/khronos_icd/icd_exports.map b/khronos_icd/icd_exports.map new file mode 100644 index 000000000..3d8a24ed7 --- /dev/null +++ b/khronos_icd/icd_exports.map @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2012 The Khronos Group Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software source and associated documentation files (the "Materials"), + * to use, copy, modify and compile the Materials to create a binary under the + * following terms and conditions: + * + * 1. The Materials shall NOT be distributed to any third party; + * + * 2. The binary may be distributed without restriction, including without + * limitation the rights to use, copy, merge, publish, distribute, sublicense, + * and/or sell copies, and to permit persons to whom the binary is furnished to + * do so; + * + * 3. All modifications to the Materials used to create a binary that is + * distributed to third parties shall be provided to Khronos with an + * unrestricted license to use for the purposes of implementing bug fixes and + * enhancements to the Materials; + * + * 4. If the binary is used as part of an OpenCL(TM) implementation, whether + * binary is distributed together with or separately to that implementation, + * then recipient must become an OpenCL Adopter and follow the published OpenCL + * conformance process for that implementation, details at: + * http://www.khronos.org/conformance/; + * + * 5. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Materials. + * + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN + * THE MATERIALS. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +OPENCL_1.0 { + global: + clBuildProgram; + clCreateBuffer; + clCreateCommandQueue; + clCreateContext; + clCreateContextFromType; + clCreateFromGLBuffer; + clCreateFromGLRenderbuffer; + clCreateFromGLTexture2D; + clCreateFromGLTexture3D; + clCreateImage2D; + clCreateImage3D; + clCreateKernel; + clCreateKernelsInProgram; + clCreateProgramWithBinary; + clCreateProgramWithSource; + clCreateSampler; + clEnqueueAcquireGLObjects; + clEnqueueBarrier; + clEnqueueCopyBuffer; + clEnqueueCopyBufferToImage; + clEnqueueCopyImage; + clEnqueueCopyImageToBuffer; + clEnqueueMapBuffer; + clEnqueueMapImage; + clEnqueueMarker; + clEnqueueNDRangeKernel; + clEnqueueNativeKernel; + clEnqueueReadBuffer; + clEnqueueReadImage; + clEnqueueReleaseGLObjects; + clEnqueueTask; + clEnqueueUnmapMemObject; + clEnqueueWaitForEvents; + clEnqueueWriteBuffer; + clEnqueueWriteImage; + clFinish; + clFlush; + clGetCommandQueueInfo; + clGetContextInfo; + clGetDeviceIDs; + clGetDeviceInfo; + clGetEventInfo; + clGetEventProfilingInfo; + clGetExtensionFunctionAddress; + clGetGLObjectInfo; + clGetGLTextureInfo; + clGetImageInfo; + clGetKernelInfo; + clGetKernelWorkGroupInfo; + clGetMemObjectInfo; + clGetPlatformIDs; + clGetPlatformInfo; + clGetProgramBuildInfo; + clGetProgramInfo; + clGetSamplerInfo; + clGetSupportedImageFormats; + clReleaseCommandQueue; + clReleaseContext; + clReleaseEvent; + clReleaseKernel; + clReleaseMemObject; + clReleaseProgram; + clReleaseSampler; + clRetainCommandQueue; + clRetainContext; + clRetainEvent; + clRetainKernel; + clRetainMemObject; + clRetainProgram; + clRetainSampler; + clSetCommandQueueProperty; + clSetKernelArg; + clUnloadCompiler; + clWaitForEvents; + + local: + /* Everything else is local to ICD. */ + *; +}; + +OPENCL_1.1 { + global: + clCreateSubBuffer; + clCreateUserEvent; + clEnqueueCopyBufferRect; + clEnqueueReadBufferRect; + clEnqueueWriteBufferRect; + clSetEventCallback; + clSetMemObjectDestructorCallback; + clSetUserEventStatus; +} OPENCL_1.0; + +OPENCL_1.2 { + global: + clCompileProgram; + clCreateFromGLTexture; + clCreateImage; + clCreateProgramWithBuiltInKernels; + clCreateSubDevices; + clEnqueueBarrierWithWaitList; + clEnqueueFillBuffer; + clEnqueueFillImage; + clEnqueueMarkerWithWaitList; + clEnqueueMigrateMemObjects; + clGetExtensionFunctionAddressForPlatform; + clGetKernelArgInfo; + clLinkProgram; + clReleaseDevice; + clRetainDevice; + clUnloadPlatformCompiler; +} OPENCL_1.1; diff --git a/khronos_icd/icd_linux.c b/khronos_icd/icd_linux.c new file mode 100644 index 000000000..26b7df937 --- /dev/null +++ b/khronos_icd/icd_linux.c @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2012 The Khronos Group Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software source and associated documentation files (the "Materials"), + * to use, copy, modify and compile the Materials to create a binary under the + * following terms and conditions: + * + * 1. The Materials shall NOT be distributed to any third party; + * + * 2. The binary may be distributed without restriction, including without + * limitation the rights to use, copy, merge, publish, distribute, sublicense, + * and/or sell copies, and to permit persons to whom the binary is furnished to + * do so; + * + * 3. All modifications to the Materials used to create a binary that is + * distributed to third parties shall be provided to Khronos with an + * unrestricted license to use for the purposes of implementing bug fixes and + * enhancements to the Materials; + * + * 4. If the binary is used as part of an OpenCL(TM) implementation, whether + * binary is distributed together with or separately to that implementation, + * then recipient must become an OpenCL Adopter and follow the published OpenCL + * conformance process for that implementation, details at: + * http://www.khronos.org/conformance/; + * + * 5. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Materials. + * + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN + * THE MATERIALS. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include "icd.h" +#include +#include +#include +#include +#include +#include + +/* + * + * Vendor enumeration functions + * + */ + +// go through the list of vendors in the two configuration files +void khrIcdOsVendorsEnumerate(void) +{ + DIR *dir = NULL; + struct dirent *dirEntry = NULL; + char *vendorPath = "/etc/OpenCL/vendors/"; + + // open the directory + dir = opendir(vendorPath); + if (NULL == dir) + { + KHR_ICD_TRACE("Failed to open path %s\n", vendorPath); + goto Cleanup; + } + + // attempt to load all files in the directory + for (dirEntry = readdir(dir); dirEntry; dirEntry = readdir(dir) ) + { + switch(dirEntry->d_type) + { + case DT_UNKNOWN: + case DT_REG: + case DT_LNK: + { + const char* extension = ".icd"; + FILE *fin = NULL; + char* fileName = NULL; + char* buffer = NULL; + long bufferSize = 0; + + // make sure the file name ends in .icd + if (strlen(extension) > strlen(dirEntry->d_name) ) + { + break; + } + if (strcmp(dirEntry->d_name + strlen(dirEntry->d_name) - strlen(extension), extension) ) + { + break; + } + + // allocate space for the full path of the vendor library name + fileName = malloc(strlen(dirEntry->d_name) + strlen(vendorPath) + 1); + if (!fileName) + { + KHR_ICD_TRACE("Failed allocate space for ICD file path\n"); + break; + } + sprintf(fileName, "%s%s", vendorPath, dirEntry->d_name); + + // open the file and read its contents + fin = fopen(fileName, "r"); + if (!fin) + { + free(fileName); + break; + } + fseek(fin, 0, SEEK_END); + bufferSize = ftell(fin); + + buffer = malloc(bufferSize+1); + if (!buffer) + { + free(fileName); + fclose(fin); + break; + } + memset(buffer, 0, bufferSize+1); + fseek(fin, 0, SEEK_SET); + if (bufferSize != (long)fread(buffer, 1, bufferSize, fin) ) + { + free(fileName); + free(buffer); + fclose(fin); + break; + } + // ignore a newline at the end of the file + if (buffer[bufferSize-1] == '\n') buffer[bufferSize-1] = '\0'; + + // load the string read from the file + khrIcdVendorAdd(buffer); + + free(fileName); + free(buffer); + fclose(fin); + } + break; + default: + break; + } + } + +Cleanup: + + // free resources and exit + if (dir) + { + closedir(dir); + } +} + +/* + * + * Dynamic library loading functions + * + */ + +// dynamically load a library. returns NULL on failure +void *khrIcdOsLibraryLoad(const char *libraryName) +{ + return dlopen (libraryName, RTLD_NOW); +} + +// get a function pointer from a loaded library. returns NULL on failure. +void *khrIcdOsLibraryGetFunctionAddress(void *library, const char *functionName) +{ + return dlsym(library, functionName); +} + +// unload a library +void khrIcdOsLibraryUnload(void *library) +{ + dlclose(library); +} + diff --git a/khronos_icd/icd_windows.c b/khronos_icd/icd_windows.c new file mode 100644 index 000000000..f30d4503c --- /dev/null +++ b/khronos_icd/icd_windows.c @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2012 The Khronos Group Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software source and associated documentation files (the "Materials"), + * to use, copy, modify and compile the Materials to create a binary under the + * following terms and conditions: + * + * 1. The Materials shall NOT be distributed to any third party; + * + * 2. The binary may be distributed without restriction, including without + * limitation the rights to use, copy, merge, publish, distribute, sublicense, + * and/or sell copies, and to permit persons to whom the binary is furnished to + * do so; + * + * 3. All modifications to the Materials used to create a binary that is + * distributed to third parties shall be provided to Khronos with an + * unrestricted license to use for the purposes of implementing bug fixes and + * enhancements to the Materials; + * + * 4. If the binary is used as part of an OpenCL(TM) implementation, whether + * binary is distributed together with or separately to that implementation, + * then recipient must become an OpenCL Adopter and follow the published OpenCL + * conformance process for that implementation, details at: + * http://www.khronos.org/conformance/; + * + * 5. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Materials. + * + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN + * THE MATERIALS. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include "icd.h" +#include +#include +#include + +/* + * + * Vendor enumeration functions + * + */ + +// go through the list of vendors in the registry and call khrIcdVendorAdd +// for each vendor encountered +void khrIcdOsVendorsEnumerate() +{ + LONG result; + const char* platformsName = "SOFTWARE\\Khronos\\OpenCL\\Vendors"; + HKEY platformsKey = NULL; + DWORD dwIndex; + + KHR_ICD_TRACE("Opening key HKLM\\%s...\n", platformsName); + result = RegOpenKeyExA( + HKEY_LOCAL_MACHINE, + platformsName, + 0, + KEY_READ, + &platformsKey); + if (ERROR_SUCCESS != result) + { + KHR_ICD_TRACE("Failed to open platforms key %s, continuing\n", platformsName); + return; + } + + // for each value + for (dwIndex = 0;; ++dwIndex) + { + char cszLibraryName[1024] = {0}; + DWORD dwLibraryNameSize = sizeof(cszLibraryName); + DWORD dwLibraryNameType = 0; + DWORD dwValue = 0; + DWORD dwValueSize = sizeof(dwValue); + + // read the value name + KHR_ICD_TRACE("Reading value %d...\n", dwIndex); + result = RegEnumValueA( + platformsKey, + dwIndex, + cszLibraryName, + &dwLibraryNameSize, + NULL, + &dwLibraryNameType, + (LPBYTE)&dwValue, + &dwValueSize); + // if RegEnumKeyEx fails, we are done with the enumeration + if (ERROR_SUCCESS != result) + { + KHR_ICD_TRACE("Failed to read value %d, done reading key.\n", dwIndex); + break; + } + KHR_ICD_TRACE("Value %s found...\n", cszLibraryName); + + // Require that the value be a DWORD and equal zero + if (REG_DWORD != dwLibraryNameType) + { + KHR_ICD_TRACE("Value not a DWORD, skipping\n"); + continue; + } + if (dwValue) + { + KHR_ICD_TRACE("Value not zero, skipping\n"); + continue; + } + + // add the library + khrIcdVendorAdd(cszLibraryName); + } + + result = RegCloseKey(platformsKey); + if (ERROR_SUCCESS != result) + { + KHR_ICD_TRACE("Failed to close platforms key %s, ignoring\n", platformsName); + } +} + +/* + * + * Dynamic library loading functions + * + */ + +// dynamically load a library. returns NULL on failure +void *khrIcdOsLibraryLoad(const char *libraryName) +{ + return (void *)LoadLibraryA(libraryName); +} + +// get a function pointer from a loaded library. returns NULL on failure. +void *khrIcdOsLibraryGetFunctionAddress(void *library, const char *functionName) +{ + if (!library || !functionName) + { + return NULL; + } + return GetProcAddress( (HMODULE)library, functionName); +} + +// unload a library. +void khrIcdOsLibraryUnload(void *library) +{ + FreeLibrary( (HMODULE)library); +} + diff --git a/khronos_icd/inc/README.txt b/khronos_icd/inc/README.txt new file mode 100644 index 000000000..cd635c13a --- /dev/null +++ b/khronos_icd/inc/README.txt @@ -0,0 +1,14 @@ +Copy OpenCL headers here, inside a directory named "CL", so that the inc folder +looks like this: + +inc/CL/cl_d3d10.h +inc/CL/cl_d3d11.h +inc/CL/cl_dx9_media_sharing.h +inc/CL/cl_ext.h +inc/CL/cl_gl_ext.h +inc/CL/cl_gl.h +inc/CL/cl.h +inc/CL/cl.hpp +inc/CL/cl_platform.h +inc/CL/opencl.h + diff --git a/khronos_icd/test/CMakeLists.txt b/khronos_icd/test/CMakeLists.txt new file mode 100644 index 000000000..ed84476d9 --- /dev/null +++ b/khronos_icd/test/CMakeLists.txt @@ -0,0 +1,7 @@ +include_directories (./inc) + +add_subdirectory (platform) +add_subdirectory (driver_stub) +add_subdirectory (loader_test) + +add_test (OPENCL_ICD_LOADER_TEST ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/icd_loader_test) diff --git a/khronos_icd/test/Makefile b/khronos_icd/test/Makefile new file mode 100644 index 000000000..db52dc5cc --- /dev/null +++ b/khronos_icd/test/Makefile @@ -0,0 +1,18 @@ + +.PHONY: all platform driver_stub loader_test clean + +all: platform driver_stub loader_test + +platform: + ${MAKE} -C platform + +driver_stub: + ${MAKE} -C driver_stub + +loader_test: + ${MAKE} -C loader_test + +clean: + ${MAKE} -C platform clean + ${MAKE} -C driver_stub clean + ${MAKE} -C loader_test clean diff --git a/khronos_icd/test/driver_stub/CMakeLists.txt b/khronos_icd/test/driver_stub/CMakeLists.txt new file mode 100644 index 000000000..13048172f --- /dev/null +++ b/khronos_icd/test/driver_stub/CMakeLists.txt @@ -0,0 +1,10 @@ + +set (OPENCL_DRIVER_STUB_SOURCES cl.c cl_ext.c cl_gl.c icd.c) + +if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + list (APPEND OPENCL_DRIVER_STUB_SOURCES driver_stub.def) +endif () + +add_library (OpenCLDriverStub SHARED ${OPENCL_DRIVER_STUB_SOURCES}) + +target_link_libraries (OpenCLDriverStub IcdLog) diff --git a/khronos_icd/test/driver_stub/Makefile b/khronos_icd/test/driver_stub/Makefile new file mode 100644 index 000000000..dd79b51cd --- /dev/null +++ b/khronos_icd/test/driver_stub/Makefile @@ -0,0 +1,14 @@ +CC := gcc +CFLAGS := -I ../inc -I ../../ -fPIC -g -O0 + +OUTDIR := ../../bin + +${OUTDIR}/libOpenCLDriverStub.so: cl.c cl_ext.c cl_gl.c icd.c + ${CC} ${CFLAGS} -shared -Wl,-soname,$@ \ + -Wl,--version-script,icd_driver_exports.map \ + -o $@ $^ ${OUTDIR}/libIcdLog.so + +.PHONY: clean + +clean: + rm -f ${OUTDIR}/libOpenCLDriverStub.so diff --git a/khronos_icd/test/driver_stub/cl.c b/khronos_icd/test/driver_stub/cl.c new file mode 100644 index 000000000..f84074e4a --- /dev/null +++ b/khronos_icd/test/driver_stub/cl.c @@ -0,0 +1,1917 @@ +#include +#include +#include + +#ifndef CL_USE_DEPRECATED_OPENCL_1_0_APIS +#define CL_USE_DEPRECATED_OPENCL_1_0_APIS +#endif + +#ifndef CL_USE_DEPRECATED_OPENCL_1_1_APIS +#define CL_USE_DEPRECATED_OPENCL_1_1_APIS +#endif + +// Need to rename all CL API functions to prevent ICD loader functions calling +// themselves via the dispatch table. Include this before cl headers. +#include "rename_api.h" + +#include +#include +#include "icd_structs.h" + +#define CL_PLATFORM_ICD_SUFFIX_KHR 0x0920 +CL_API_ENTRY cl_int CL_API_CALL +clIcdGetPlatformIDsKHR(cl_uint, cl_platform_id *, cl_uint *); + +struct _cl_platform_id +{ + CLIicdDispatchTable* dispatch; + const char *profile; + const char *version; + const char *name; + const char *vendor; + const char *extensions; + const char *suffix; +}; + +struct _cl_device_id +{ + CLIicdDispatchTable* dispatch; +}; + +struct _cl_context +{ + CLIicdDispatchTable* dispatch; +}; + +struct _cl_command_queue +{ + CLIicdDispatchTable* dispatch; +}; + +struct _cl_mem +{ + CLIicdDispatchTable* dispatch; +}; + +struct _cl_program +{ + CLIicdDispatchTable* dispatch; +}; + +struct _cl_kernel +{ + CLIicdDispatchTable* dispatch; +}; + +struct _cl_event +{ + CLIicdDispatchTable* dispatch; +}; + +struct _cl_sampler +{ + CLIicdDispatchTable* dispatch; +}; + +static CLIicdDispatchTable* dispatchTable = NULL; +static cl_platform_id platform = NULL; +static cl_bool initialized = CL_FALSE; + +CL_API_ENTRY cl_int CL_API_CALL +clGetPlatformIDs(cl_uint num_entries , + cl_platform_id * platforms , + cl_uint * num_platforms) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetPlatformIDs(%u, %p, %p)\n", + num_entries, + platforms, + num_platforms); + return_value = clIcdGetPlatformIDsKHR(num_entries, platforms, num_platforms); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetPlatformInfo(cl_platform_id platform, + cl_platform_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int result = CL_SUCCESS; + cl_int return_value = CL_SUCCESS; + const char *returnString = NULL; + size_t returnStringLength = 0; + /*test_icd_stub_log("clGetPlatformInfo(%p, %u, %u, %p, %p)\n", + platform, + param_name, + param_value_size, + param_value, + param_value_size_ret);*/ + + // validate the arguments + if (param_value_size == 0 && param_value != NULL) { + return CL_INVALID_VALUE; + } + // select the string to return + switch(param_name) { + case CL_PLATFORM_PROFILE: + returnString = platform->profile; + break; + case CL_PLATFORM_VERSION: + returnString = platform->version; + break; + case CL_PLATFORM_NAME: + returnString = platform->name; + break; + case CL_PLATFORM_VENDOR: + returnString = platform->vendor; + break; + case CL_PLATFORM_EXTENSIONS: + returnString = platform->extensions; + break; + case CL_PLATFORM_ICD_SUFFIX_KHR: + returnString = platform->suffix; + break; + default: + /*test_icd_stub_log("Value returned: %d\n", + CL_INVALID_VALUE);*/ + return CL_INVALID_VALUE; + break; + } + + // make sure the buffer passed in is big enough for the result + returnStringLength = strlen(returnString)+1; + if (param_value_size && param_value_size < returnStringLength) { + /*test_icd_stub_log("Value returned: %d\n", + CL_INVALID_VALUE);*/ + return CL_INVALID_VALUE; + } + + // pass the data back to the user + if (param_value) { + memcpy(param_value, returnString, returnStringLength); + } + if (param_value_size_ret) { + *param_value_size_ret = returnStringLength; + } + + /*test_icd_stub_log("Value returned: %d\n", + return_value);*/ + return return_value; +} + + +/* Device APIs */ +CL_API_ENTRY cl_int CL_API_CALL +clGetDeviceIDs(cl_platform_id platform, + cl_device_type device_type, + cl_uint num_entries, + cl_device_id * devices, + cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_SUCCESS; + + if ((num_entries > 1 || num_entries < 0) && devices != NULL) { + return_value = CL_INVALID_VALUE; + } + else { + cl_device_id obj = (cl_device_id) malloc(sizeof(cl_device_id)); + obj->dispatch = dispatchTable; + *devices = obj; + } + if (num_devices) { + *num_devices = 1; + } + + test_icd_stub_log("clGetDeviceIDs(%p, %x, %u, %p, %p)\n", + platform, + device_type, + num_entries, + devices, + num_devices); + test_icd_stub_log("Value returned: %d\n", CL_SUCCESS); + return CL_SUCCESS; +} + + + +CL_API_ENTRY cl_int CL_API_CALL +clGetDeviceInfo(cl_device_id device, + cl_device_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetDeviceInfo(%p, %u, %u, %p, %p)\n", + device, + param_name, + param_value_size, + param_value, + param_value_size_ret); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clCreateSubDevices(cl_device_id in_device, + const cl_device_partition_property *properties, + cl_uint num_entries, + cl_device_id *out_devices, + cl_uint *num_devices) CL_API_SUFFIX__VERSION_1_2 +{ + + cl_int return_value = CL_OUT_OF_RESOURCES; + + test_icd_stub_log("clCreateSubDevices(%p, %p, %u, %p, %p)\n", + in_device, + properties, + num_entries, + out_devices, + num_devices); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + + +CL_API_ENTRY cl_int CL_API_CALL +clRetainDevice(cl_device_id device) CL_API_SUFFIX__VERSION_1_2 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clRetainDevice(%p)\n", device); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseDevice(cl_device_id device) CL_API_SUFFIX__VERSION_1_2 + +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clReleaseDevice(%p)\n", device); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + + +/* Context APIs */ +CL_API_ENTRY cl_context CL_API_CALL +clCreateContext(const cl_context_properties * properties, + cl_uint num_devices , + const cl_device_id * devices, + void (CL_CALLBACK * pfn_notify)(const char *, const void *, size_t, void *), + void * user_data, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_context obj = (cl_context) malloc(sizeof(struct _cl_context)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clCreateContext(%p, %u, %p, %p, %p, %p)\n", + properties, + num_devices, + devices, + pfn_notify, + user_data, + errcode_ret); + pfn_notify(NULL, NULL, 0, NULL); + test_icd_stub_log("createcontext_callback(%p, %p, %u, %p)\n", + NULL, + NULL, + 0, + NULL); + + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + + +CL_API_ENTRY cl_context CL_API_CALL +clCreateContextFromType(const cl_context_properties * properties, + cl_device_type device_type, + void (CL_CALLBACK * pfn_notify)(const char *, const void *, size_t, void *), + void * user_data, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_context obj = (cl_context) malloc(sizeof(struct _cl_context)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clCreateContextFromType(%p, %x, %p, %p, %p)\n", + properties, + device_type, + pfn_notify, + user_data, + errcode_ret); + pfn_notify(NULL, NULL, 0, NULL); + + test_icd_stub_log ("createcontext_callback(%p, %p, %u, %p)\n", + NULL, + NULL, + 0, + NULL); + + test_icd_stub_log("Value returned: %p\n", + obj); + return obj; +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainContext(cl_context context) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clRetainContext(%p)\n", context); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseContext(cl_context context) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clReleaseContext(%p)\n", context); + free(context); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetContextInfo(cl_context context, + cl_context_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetContextInfo(%p, %u, %u, %p, %p)\n", + context, + param_name, + param_value_size, + param_value, + param_value_size_ret); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +/* Command Queue APIs */ +CL_API_ENTRY cl_command_queue CL_API_CALL +clCreateCommandQueue(cl_context context, + cl_device_id device, + cl_command_queue_properties properties, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_command_queue obj = (cl_command_queue) malloc(sizeof(struct _cl_command_queue)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clCreateCommandQueue(%p, %p, %x, %p)\n", + context, + device, + properties, + errcode_ret); + + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + +CL_API_ENTRY cl_int CL_API_CALL +clSetCommandQueueProperty(cl_command_queue command_queue , + cl_command_queue_properties properties , + cl_bool enable , + cl_command_queue_properties * old_properties) CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clSetCommandQueueProperty(%p, %p, %u, %p)\n", + command_queue, + properties, + enable, + old_properties); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainCommandQueue(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clRetainCommandQueue(%p)\n", command_queue); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseCommandQueue(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clReleaseCommandQueue(%p)\n", command_queue); + free(command_queue); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetCommandQueueInfo(cl_command_queue command_queue , + cl_command_queue_info param_name , + size_t param_value_size , + void * param_value , + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetCommandQueueInfo(%p, %u, %u, %p, %p)\n", + command_queue, + param_name, + param_value_size, + param_value, + param_value_size_ret); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + + + +/* Memory Object APIs */ +CL_API_ENTRY cl_mem CL_API_CALL +clCreateBuffer(cl_context context , + cl_mem_flags flags , + size_t size , + void * host_ptr , + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clCreateBuffer(%p, %x, %u, %p, %p)\n", + context, + flags, + size, + host_ptr, + errcode_ret); + + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateSubBuffer(cl_mem buffer , + cl_mem_flags flags , + cl_buffer_create_type buffer_create_type , + const void * buffer_create_info , + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_1 +{ + cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clCreateSubBuffer(%p, %x, %u, %p, %p)\n", + buffer, + flags, + buffer_create_type, + buffer_create_info, + errcode_ret); + + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateImage(cl_context context, + cl_mem_flags flags, + const cl_image_format * image_format, + const cl_image_desc * image_desc, + void * host_ptr, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2 +{ + cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clCreateImage(%p, %x, %p, %p, %p, %p)\n", + context, + flags, + image_format, + image_desc, + host_ptr, + errcode_ret); + + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateImage2D(cl_context context , + cl_mem_flags flags , + const cl_image_format * image_format , + size_t image_width , + size_t image_height , + size_t image_row_pitch , + void * host_ptr , + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clCreateImage2D(%p, %x, %p, %u, %u, %u, %p, %p)\n", + context, + flags, + image_format, + image_width, + image_height, + image_row_pitch, + host_ptr); + + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateImage3D(cl_context context, + cl_mem_flags flags, + const cl_image_format * image_format, + size_t image_width, + size_t image_height , + size_t image_depth , + size_t image_row_pitch , + size_t image_slice_pitch , + void * host_ptr , + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clCreateImage3D(%p, %x, %p, %u, %u, %u, %u, %u, %p, %p)\n", + context, + flags, + image_format, + image_width, + image_height, + image_depth, + image_row_pitch, + image_slice_pitch, + host_ptr, + errcode_ret); + + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainMemObject(cl_mem memobj) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clRetainMemObject(%p)\n", memobj); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseMemObject(cl_mem memobj) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clReleaseMemObject(%p)\n", memobj); + free(memobj); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetSupportedImageFormats(cl_context context, + cl_mem_flags flags, + cl_mem_object_type image_type , + cl_uint num_entries , + cl_image_format * image_formats , + cl_uint * num_image_formats) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetSupportedImageFormats(%p, %x, %u, %u, %p, %p)\n", + context, + flags, + image_type, + num_entries, + image_formats, + num_image_formats); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetMemObjectInfo(cl_mem memobj , + cl_mem_info param_name , + size_t param_value_size , + void * param_value , + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetMemObjectInfo(%p, %u, %u, %p, %p)\n", + memobj, + param_name, + param_value_size, + param_value, + param_value_size_ret); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetImageInfo(cl_mem image , + cl_image_info param_name , + size_t param_value_size , + void * param_value , + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetImageInfo(%p, %u, %u, %p, %p)\n", + image, + param_name, + param_value_size, + param_value, + param_value_size_ret); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clSetMemObjectDestructorCallback(cl_mem memobj , + void (CL_CALLBACK * pfn_notify)(cl_mem memobj , void* user_data), + void * user_data) CL_API_SUFFIX__VERSION_1_1 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clSetMemObjectDestructorCallback(%p, %p, %p)\n", + memobj, + pfn_notify, + user_data); + pfn_notify(memobj, NULL); + test_icd_stub_log("setmemobjectdestructor_callback(%p, %p)\n", + memobj, + NULL); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +/* Sampler APIs */ +CL_API_ENTRY cl_sampler CL_API_CALL +clCreateSampler(cl_context context , + cl_bool normalized_coords , + cl_addressing_mode addressing_mode , + cl_filter_mode filter_mode , + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_sampler obj = (cl_sampler) malloc(sizeof(struct _cl_sampler)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clCreateSampler(%p, %u, %u, %u, %p)\n", + context, + normalized_coords, + addressing_mode, + filter_mode, + errcode_ret); + + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainSampler(cl_sampler sampler) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clRetainSampler(%p)\n", sampler); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseSampler(cl_sampler sampler) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clReleaseSampler(%p)\n", sampler); + free(sampler); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetSamplerInfo(cl_sampler sampler , + cl_sampler_info param_name , + size_t param_value_size , + void * param_value , + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetSamplerInfo(%p, %u, %u, %p, %p)\n", + sampler, + param_name, + param_value_size, + param_value, + param_value_size_ret); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +/* Program Object APIs */ +CL_API_ENTRY cl_program CL_API_CALL +clCreateProgramWithSource(cl_context context , + cl_uint count , + const char ** strings , + const size_t * lengths , + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_program obj = (cl_program) malloc(sizeof(struct _cl_program)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clCreateProgramWithSource(%p, %u, %p, %p, %p)\n", + context, + count, + strings, + lengths, + errcode_ret); + + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + +CL_API_ENTRY cl_program CL_API_CALL +clCreateProgramWithBinary(cl_context context , + cl_uint num_devices , + const cl_device_id * device_list , + const size_t * lengths , + const unsigned char ** binaries , + cl_int * binary_status , + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_program obj = (cl_program) malloc(sizeof(struct _cl_program)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clCreateProgramWithBinary(%p, %u, %p, %p, %p, %p, %p)\n", + context, + num_devices, + device_list, + lengths, + binaries, + binary_status, + errcode_ret); + + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + +CL_API_ENTRY cl_program CL_API_CALL +clCreateProgramWithBuiltInKernels(cl_context context , + cl_uint num_devices , + const cl_device_id * device_list , + const char * kernel_names , + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2 +{ + cl_program obj = (cl_program) malloc(sizeof(struct _cl_program)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clCreateProgramWithBuiltInKernels(%p, %u, %p, %p, %p)\n", + context, + num_devices, + device_list, + kernel_names, + errcode_ret); + + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + + +CL_API_ENTRY cl_int CL_API_CALL +clRetainProgram(cl_program program) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clRetainProgram(%p)\n", + program); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseProgram(cl_program program) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clReleaseProgram(%p)\n", program); + free(program); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clBuildProgram(cl_program program , + cl_uint num_devices , + const cl_device_id * device_list , + const char * options , + void (CL_CALLBACK * pfn_notify)(cl_program program , void * user_data), + void * user_data) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clBuildProgram(%p, %u, %p, %p, %p, %p)\n", + program, + num_devices, + device_list, + options, + pfn_notify, + user_data); + pfn_notify(program, NULL); + test_icd_stub_log("program_callback(%p, %p)\n", program, NULL); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clUnloadCompiler(void) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clUnloadCompiler()\n"); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clCompileProgram(cl_program program , + cl_uint num_devices , + const cl_device_id * device_list , + const char * options , + cl_uint num_input_headers , + const cl_program * input_headers, + const char ** header_include_names , + void (CL_CALLBACK * pfn_notify)(cl_program program , void * user_data), + void * user_data) CL_API_SUFFIX__VERSION_1_2 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clCompileProgram(%p, %u, %p, %p, %u, %p, %p, %p)\n", + program, + num_devices, + device_list, + options, + num_input_headers, + header_include_names, + pfn_notify, + user_data); + pfn_notify(program, NULL); + test_icd_stub_log("program_callback(%p, %p)\n", program, NULL); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_program CL_API_CALL +clLinkProgram(cl_context context , + cl_uint num_devices , + const cl_device_id * device_list , + const char * options , + cl_uint num_input_programs , + const cl_program * input_programs , + void (CL_CALLBACK * pfn_notify)(cl_program program , void * user_data), + void * user_data , + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2 +{ + cl_program obj = (cl_program) malloc(sizeof(cl_program)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clLinkProgram(%p, %u, %p, %p, %u, %p, %p, %p, %p)\n", + context, + num_devices, + device_list, + options, + num_input_programs, + input_programs, + pfn_notify, + user_data, + errcode_ret); + pfn_notify(obj, NULL); + test_icd_stub_log("program_callback(%p, %p)\n", obj, NULL); + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + + +CL_API_ENTRY cl_int CL_API_CALL +clUnloadPlatformCompiler(cl_platform_id platform) CL_API_SUFFIX__VERSION_1_2 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clUnloadPlatformCompiler(%p)\n", platform); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetProgramInfo(cl_program program , + cl_program_info param_name , + size_t param_value_size , + void * param_value , + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetProgramInfo(%p, %u, %u, %p, %p)\n", + program, + param_name, + param_value_size, + param_value, + param_value_size_ret); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetProgramBuildInfo(cl_program program , + cl_device_id device , + cl_program_build_info param_name , + size_t param_value_size , + void * param_value , + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetProgramBuildInfo(%p, %p, %u, %u, %p, %p)\n", + program, + device, + param_name, + param_value_size, + param_value, + param_value_size_ret); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +/* Kernel Object APIs */ +CL_API_ENTRY cl_kernel CL_API_CALL +clCreateKernel(cl_program program , + const char * kernel_name , + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_kernel obj = (cl_kernel) malloc(sizeof(struct _cl_kernel)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clCreateKernel(%p, %p, %p)\n", + program, + kernel_name, + errcode_ret); + + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + +CL_API_ENTRY cl_int CL_API_CALL +clCreateKernelsInProgram(cl_program program , + cl_uint num_kernels , + cl_kernel * kernels , + cl_uint * num_kernels_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clCreateKernelsInProgram(%p, %u, %p, %p)\n", + program, + num_kernels, + kernels, + num_kernels_ret); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainKernel(cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clRetainKernel(%p)\n", kernel); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseKernel(cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clReleaseKernel(%p)\n", kernel); + free(kernel); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clSetKernelArg(cl_kernel kernel , + cl_uint arg_index , + size_t arg_size , + const void * arg_value) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clSetKernelArg(%p, %u, %u, %p)\n", + kernel, + arg_index, + arg_size, + arg_value); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetKernelInfo(cl_kernel kernel , + cl_kernel_info param_name , + size_t param_value_size , + void * param_value , + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetKernelInfo(%p, %u, %u, %p, %p)\n", + kernel, + param_name, + param_value_size, + param_value, + param_value_size_ret); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetKernelArgInfo(cl_kernel kernel , + cl_uint arg_indx , + cl_kernel_arg_info param_name , + size_t param_value_size , + void * param_value , + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_2 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetKernelArgInfo(%p, %u, %u, %u, %p, %p)\n", + kernel, + arg_indx, + param_name, + param_value_size, + param_value, + param_value_size_ret); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetKernelWorkGroupInfo(cl_kernel kernel , + cl_device_id device , + cl_kernel_work_group_info param_name , + size_t param_value_size , + void * param_value , + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetKernelWorkGroupInfo(%p, %p, %u, %u, %p, %p)\n", + kernel, + device, + param_name, + param_value_size, + param_value, + param_value_size_ret); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +/* Event Object APIs */ +CL_API_ENTRY cl_int CL_API_CALL +clWaitForEvents(cl_uint num_events , + const cl_event * event_list) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clWaitForEvents(%u, %p)\n", + num_events, + event_list); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetEventInfo(cl_event event , + cl_event_info param_name , + size_t param_value_size , + void * param_value , + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetEventInfo(%p, %u, %u, %p, %p)\n", + event, + param_name, + param_value_size, + param_value, + param_value_size_ret); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_event CL_API_CALL +clCreateUserEvent(cl_context context , + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_1 +{ + cl_event obj = (cl_event) malloc(sizeof(struct _cl_event)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clCreateUserEvent(%p, %p)\n", context, errcode_ret); + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainEvent(cl_event event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clRetainEvent(%p)\n", event); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseEvent(cl_event event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clReleaseEvent(%p)\n", event); + free(event); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clSetUserEventStatus(cl_event event , + cl_int execution_status) CL_API_SUFFIX__VERSION_1_1 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clSetUserEventStatus(%p, %d)\n", + event, + execution_status); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clSetEventCallback(cl_event event , + cl_int command_exec_callback_type , + void (CL_CALLBACK * pfn_notify)(cl_event, cl_int, void *), + void * user_data) CL_API_SUFFIX__VERSION_1_1 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clSetEventCallback(%p, %d, %p, %p)\n", + event, + command_exec_callback_type, + pfn_notify, + user_data); + pfn_notify(event, command_exec_callback_type, NULL); + test_icd_stub_log("setevent_callback(%p, %d, %p)\n", + event, + command_exec_callback_type, + NULL); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +/* Profiling APIs */ +CL_API_ENTRY cl_int CL_API_CALL +clGetEventProfilingInfo(cl_event event , + cl_profiling_info param_name , + size_t param_value_size , + void * param_value , + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetEventProfilingInfo(%p, %u, %u, %p, %p)\n", + event, + param_name, + param_value_size, + param_value, + param_value_size_ret); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +/* Flush and Finish APIs */ +CL_API_ENTRY cl_int CL_API_CALL +clFlush(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clFlush(%p)\n", command_queue); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clFinish(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clFinish(%p)\n", command_queue); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +/* Enqueued Commands APIs */ +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReadBuffer(cl_command_queue command_queue , + cl_mem buffer , + cl_bool blocking_read , + size_t offset , + size_t cb , + void * ptr , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueReadBuffer(%p, %p, %u, %u, %u, %p, %u, %p, %p)\n", + command_queue, + buffer, + blocking_read, + offset, + cb, + ptr, + num_events_in_wait_list, + event_wait_list, event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReadBufferRect(cl_command_queue command_queue , + cl_mem buffer , + cl_bool blocking_read , + const size_t * buffer_origin , + const size_t * host_origin , + const size_t * region , + size_t buffer_row_pitch , + size_t buffer_slice_pitch , + size_t host_row_pitch , + size_t host_slice_pitch , + void * ptr , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_1 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueReadBufferRect(%p, %p, %u, %p, %p, %p, %u, %u, %u, %u, %p, %u, %p, %p)\n", + command_queue, + buffer, + blocking_read, + buffer_origin, + host_origin, + region, + buffer_row_pitch, + buffer_slice_pitch, + host_row_pitch, + host_slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueWriteBuffer(cl_command_queue command_queue , + cl_mem buffer , + cl_bool blocking_write , + size_t offset , + size_t cb , + const void * ptr , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueWriteBuffer(%p, %p, %u, %u, %u, %p, %u, %p, %p)\n", + command_queue, + buffer, + blocking_write, + offset, + cb, + ptr, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueWriteBufferRect(cl_command_queue command_queue , + cl_mem buffer , + cl_bool blocking_write , + const size_t * buffer_origin , + const size_t * host_origin , + const size_t * region , + size_t buffer_row_pitch , + size_t buffer_slice_pitch , + size_t host_row_pitch , + size_t host_slice_pitch , + const void * ptr , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_1 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueWriteBufferRect(%p, %p, %u, %p, %p, %p, %u, %u, %u, %u, %p, %u, %p, %p)\n", + command_queue, + buffer, + blocking_write, + buffer_origin, + host_origin, + region, + buffer_row_pitch, + buffer_slice_pitch, + host_row_pitch, + host_slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueCopyBuffer(cl_command_queue command_queue , + cl_mem src_buffer , + cl_mem dst_buffer , + size_t src_offset , + size_t dst_offset , + size_t cb , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueCopyBuffer(%p, %p, %p, %u, %u, %u, %u, %p, %p)\n", + command_queue, + src_buffer, + dst_buffer, + src_offset, + dst_offset, + cb, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueCopyBufferRect(cl_command_queue command_queue , + cl_mem src_buffer , + cl_mem dst_buffer , + const size_t * src_origin , + const size_t * dst_origin , + const size_t * region , + size_t src_row_pitch , + size_t src_slice_pitch , + size_t dst_row_pitch , + size_t dst_slice_pitch , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_1 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueCopyBufferRect(%p, %p, %p, %p, %p, %p, %u, %u, %u, %u, %u, %p, %p)\n", + command_queue, + src_buffer, + dst_buffer, + src_origin, + dst_origin, + region, + src_row_pitch, + src_slice_pitch, + dst_row_pitch, + dst_slice_pitch, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueFillBuffer(cl_command_queue command_queue , + cl_mem buffer , + const void * pattern , + size_t pattern_size , + size_t offset , + size_t cb , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_2 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueFillBuffer(%p, %p, %p, %u, %u, %u, %u, %p, %p)\n", + command_queue, + buffer, + pattern, + pattern_size, + offset, + cb, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueFillImage(cl_command_queue command_queue , + cl_mem image , + const void * fill_color , + const size_t * origin , + const size_t * region , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_2 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueFillImage(%p, %p, %p, %p, %p, %u, %p, %p)\n", + command_queue, + image, + fill_color, + origin, + region, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReadImage(cl_command_queue command_queue , + cl_mem image , + cl_bool blocking_read , + const size_t * origin , + const size_t * region , + size_t row_pitch , + size_t slice_pitch , + void * ptr , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueReadImage(%p, %p, %u, %p, %p, %u, %u, %p, %u, %p, %p)\n", + command_queue, + image, + blocking_read, + origin, + region, + row_pitch, + slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueWriteImage(cl_command_queue command_queue , + cl_mem image , + cl_bool blocking_write , + const size_t * origin , + const size_t * region , + size_t input_row_pitch , + size_t input_slice_pitch , + const void * ptr , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueWriteImage(%p, %p, %u, %p, %p, %u, %u, %p, %u, %p, %p)\n", + command_queue, + image, + blocking_write, + origin, + region, + input_row_pitch, + input_slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueCopyImage(cl_command_queue command_queue , + cl_mem src_image , + cl_mem dst_image , + const size_t * src_origin , + const size_t * dst_origin , + const size_t * region , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueCopyImage(%p, %p, %p, %p, %p, %p, %u, %p, %p)\n", + command_queue, + src_image, + dst_image, + src_origin, + dst_origin, + region, + num_events_in_wait_list, + event_wait_list , + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueCopyImageToBuffer(cl_command_queue command_queue , + cl_mem src_image , + cl_mem dst_buffer , + const size_t * src_origin , + const size_t * region , + size_t dst_offset , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueCopyImageToBuffer(%p, %p, %p, %p, %p, %u, %u, %p, %p)\n", + command_queue, + src_image, + dst_buffer, + src_origin, + region, + dst_offset, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueCopyBufferToImage(cl_command_queue command_queue , + cl_mem src_buffer , + cl_mem dst_image , + size_t src_offset , + const size_t * dst_origin , + const size_t * region , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueCopyBufferToImage(%p, %p, %p, %u, %p, %p, %u, %p, %p)\n", + command_queue, + src_buffer, + dst_image, + src_offset, + dst_origin, + region, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY void * CL_API_CALL +clEnqueueMapBuffer(cl_command_queue command_queue , + cl_mem buffer , + cl_bool blocking_map , + cl_map_flags map_flags , + size_t offset , + size_t cb , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event , + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + void *return_value = (void *) malloc(sizeof(void *)); + test_icd_stub_log("clEnqueueMapBuffer(%p, %p, %u, %x, %u, %u, %u, %p, %p, %p)\n", + command_queue, + buffer, + blocking_map, + map_flags, + offset, + cb, + num_events_in_wait_list, + event_wait_list, + event, + errcode_ret); + + test_icd_stub_log("Value returned: %p\n", return_value); + return return_value; +} + +CL_API_ENTRY void * CL_API_CALL +clEnqueueMapImage(cl_command_queue command_queue , + cl_mem image , + cl_bool blocking_map , + cl_map_flags map_flags , + const size_t * origin , + const size_t * region , + size_t * image_row_pitch , + size_t * image_slice_pitch , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event , + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + void *return_value = (void *) malloc(sizeof(void *)); + test_icd_stub_log("clEnqueueMapImage(%p, %p, %u, %x, %p, %p, %p, %p, %u, %p, %p, %p)\n", + command_queue, + image, + blocking_map, + map_flags, + origin, + region, + image_row_pitch, + image_slice_pitch, + num_events_in_wait_list, + event_wait_list, + event, + errcode_ret); + + test_icd_stub_log("Value returned: %p\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueUnmapMemObject(cl_command_queue command_queue , + cl_mem memobj , + void * mapped_ptr , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueUnmapMemObject(%p, %p, %p, %u, %p, %p)\n", + command_queue, + memobj, + mapped_ptr, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueMigrateMemObjects(cl_command_queue command_queue , + cl_uint num_mem_objects , + const cl_mem * mem_objects , + cl_mem_migration_flags flags , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_2 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueMigrateMemObjects(%p, %u, %p, %x, %u, %p, %p)\n", + command_queue, + num_mem_objects, + mem_objects, + flags, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueNDRangeKernel(cl_command_queue command_queue , + cl_kernel kernel , + cl_uint work_dim , + const size_t * global_work_offset , + const size_t * global_work_size , + const size_t * local_work_size , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueNDRangeKernel(%p, %p, %u, %p, %p, %p, %u, %p, %p)\n", + command_queue, + kernel, + work_dim, + global_work_offset, + global_work_size, + local_work_size, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueTask(cl_command_queue command_queue , + cl_kernel kernel , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueTask(%p, %p, %u, %p, %p)\n", + command_queue, + kernel, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueNativeKernel(cl_command_queue command_queue , + void (CL_CALLBACK *user_func)(void *), + void * args , + size_t cb_args , + cl_uint num_mem_objects , + const cl_mem * mem_list , + const void ** args_mem_loc , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueNativeKernel(%p, %p, %p, %u, %u, %p, %p, %u, %p, %p)\n", + command_queue, + user_func, + args, + cb_args, + num_mem_objects, + mem_list, + args_mem_loc, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY void * CL_API_CALL +clGetExtensionFunctionAddressForPlatform(cl_platform_id platform , + const char * func_name) CL_API_SUFFIX__VERSION_1_2 +{ + void *return_value = (void *) malloc(sizeof(void *)); + test_icd_stub_log("clGetExtensionFunctionAddressForPlatform(%p, %p)\n", + platform, + func_name); + + test_icd_stub_log("Value returned: %p\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueMarkerWithWaitList(cl_command_queue command_queue , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_2 + +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueMarkerWithWaitList(%p, %u, %p, %p)\n", + command_queue, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueBarrierWithWaitList(cl_command_queue command_queue , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_2 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueBarrierWithWaitList(%p, %u, %p, %p)\n", + command_queue, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +extern CL_API_ENTRY cl_int CL_API_CALL +clSetPrintfCallback(cl_context context , + void (CL_CALLBACK * pfn_notify)(cl_context program , + cl_uint printf_data_len , + char * printf_data_ptr , + void * user_data), + void * user_data) CL_API_SUFFIX__VERSION_1_2 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clSetPrintfCallback(%p, %p, %p)\n", + context, + pfn_notify, + user_data); + pfn_notify(context, 0, NULL, NULL); + test_icd_stub_log("setprintf_callback(%p, %u, %p, %p)\n", + context, + 0, + NULL, + NULL); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueMarker(cl_command_queue command_queue , + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueMarker(%p, %p)\n", command_queue, event); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueWaitForEvents(cl_command_queue command_queue , + cl_uint num_events , + const cl_event * event_list) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueWaitForEvents(%p, %u, %p)\n", + command_queue, + num_events, + event_list); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueBarrier(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueBarrier(%p)\n", command_queue); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +extern cl_int cliIcdDispatchTableCreate(CLIicdDispatchTable **outDispatchTable); + +CL_API_ENTRY cl_int CL_API_CALL +clIcdGetPlatformIDsKHR(cl_uint num_entries, + cl_platform_id * platforms, + cl_uint * num_platforms) +{ + cl_int result = CL_SUCCESS; + if (!initialized) { + result = cliIcdDispatchTableCreate(&dispatchTable); + platform = (cl_platform_id) malloc(sizeof(struct _cl_platform_id)); + memset(platform, 0, sizeof(struct _cl_platform_id)); + + platform->dispatch = dispatchTable; + platform->version = "OpenCL 1.2 Stub"; + platform->vendor = "stubvendorxxx"; + platform->profile = "stubprofilexxx"; + platform->name = "ICD_LOADER_TEST_OPENCL_STUB"; + platform->extensions = "cl_khr_icd cl_khr_gl cl_khr_d3d10"; + platform->suffix = "ilts"; + platform->dispatch = dispatchTable; + initialized = CL_TRUE; + } + + if ((platforms && num_entries >1) || + (platforms && num_entries <= 0) || + (!platforms && num_entries >= 1)) { + result = CL_INVALID_VALUE; + goto Done; + } + + if (platforms && num_entries == 1) { + platforms[0] = platform; + } + +Done: + if (num_platforms) { + *num_platforms = 1; + } + + return result; +} + diff --git a/khronos_icd/test/driver_stub/cl_ext.c b/khronos_icd/test/driver_stub/cl_ext.c new file mode 100644 index 000000000..ece0c591b --- /dev/null +++ b/khronos_icd/test/driver_stub/cl_ext.c @@ -0,0 +1,35 @@ +#include + +#define CL_USE_DEPRECATED_OPENCL_1_1_APIS +#include "CL/cl.h" +#include "CL/cl_ext.h" + +struct driverStubextFunc_st +{ + const char *name; + void *func; +}; + +#define EXT_FUNC(name) { #name, (void*)(name) } + +static struct driverStubextFunc_st clExtensions[] = +{ + EXT_FUNC(clIcdGetPlatformIDsKHR), +}; + +static const int clExtensionCount = sizeof(clExtensions) / sizeof(clExtensions[0]); + +CL_API_ENTRY void * CL_API_CALL +clGetExtensionFunctionAddress(const char *name) +{ + int ii; + + for (ii = 0; ii < clExtensionCount; ii++) { + if (!strcmp(name, clExtensions[ii].name)) { + return clExtensions[ii].func; + } + } + + return NULL; +} + diff --git a/khronos_icd/test/driver_stub/cl_gl.c b/khronos_icd/test/driver_stub/cl_gl.c new file mode 100644 index 000000000..3cc5cbb80 --- /dev/null +++ b/khronos_icd/test/driver_stub/cl_gl.c @@ -0,0 +1,221 @@ +#include +#include +#include + +// Need to rename all CL API functions to prevent ICD loader functions calling +// themselves via the dispatch table. Include this before cl headers. +#include "rename_api.h" + +#define SIZE_T_MAX (size_t) 0xFFFFFFFFFFFFFFFFULL + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromGLBuffer(cl_context context , + cl_mem_flags flags , + cl_GLuint bufret_mem , + int * errcode_ret ) CL_API_SUFFIX__VERSION_1_0 +{ + cl_mem ret_mem = (cl_mem)(SIZE_T_MAX); + test_icd_stub_log("clCreateFromGLBuffer(%p, %x, %u, %p)\n", + context, + flags, + bufret_mem, + errcode_ret); + test_icd_stub_log("Value returned: %p\n", + ret_mem); + return ret_mem; +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromGLTexture(cl_context context , + cl_mem_flags flags , + cl_GLenum target , + cl_GLint miplevel , + cl_GLuint texture , + cl_int * errcode_ret ) CL_API_SUFFIX__VERSION_1_2 +{ + cl_mem ret_mem = (cl_mem)(SIZE_T_MAX); + test_icd_stub_log("clCreateFromGLTexture(%p, %x, %d, %d, %u, %p)\n", + context , + flags , + target , + miplevel , + texture , + errcode_ret ); + test_icd_stub_log("Value returned: %p\n", + ret_mem); + return ret_mem; +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromGLTexture2D(cl_context context, + cl_mem_flags flags, + cl_GLenum target, + cl_GLint miplevel, + cl_GLuint texture, + cl_int * errcode_ret ) CL_API_SUFFIX__VERSION_1_0 +{ + cl_mem ret_mem = (cl_mem)(SIZE_T_MAX); + test_icd_stub_log("clCreateFromGLTexture2D(%p, %x, %d, %d, %u, %p)\n", + context, + flags, + target, + miplevel, + texture, + errcode_ret ); + test_icd_stub_log("Value returned: %p\n", + ret_mem); + return ret_mem; +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromGLTexture3D(cl_context context, + cl_mem_flags flags, + cl_GLenum target, + cl_GLint miplevel, + cl_GLuint texture, + cl_int * errcode_ret ) CL_API_SUFFIX__VERSION_1_0 + +{ + cl_mem ret_mem = (cl_mem)(SIZE_T_MAX); + test_icd_stub_log("clCreateFromGLTexture3D(%p, %x, %d, %d, %u, %p)\n", + context, + flags, + target, + miplevel, + texture, + errcode_ret ); + test_icd_stub_log("Value returned: %p\n", + ret_mem); + return ret_mem; +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromGLRenderbuffer(cl_context context, + cl_mem_flags flags, + cl_GLuint renderbuffer, + cl_int * errcode_ret ) CL_API_SUFFIX__VERSION_1_0 +{ + cl_mem ret_mem = (cl_mem)(SIZE_T_MAX); + test_icd_stub_log("clCreateFromGLRenderbuffer(%p, %x, %d, %p)\n", + context, + flags, + renderbuffer, + errcode_ret); + test_icd_stub_log("Value returned: %p\n", + ret_mem); + return ret_mem; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetGLObjectInfo(cl_mem memobj, + cl_gl_object_type * gl_object_type, + cl_GLuint * gl_object_name ) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int ret_val = -5; + test_icd_stub_log("clGetGLObjectInfo(%p, %p, %p)\n", + memobj, + gl_object_type, + gl_object_name); + test_icd_stub_log("Value returned: %p\n", + ret_val); + return ret_val; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetGLTextureInfo(cl_mem memobj, + cl_gl_texture_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret ) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int ret_val = -5; + test_icd_stub_log("clGetGLTextureInfo(%p, %u, %u, %p, %p)\n", + memobj, + param_name, + param_value_size, + param_value, + param_value_size_ret ); + test_icd_stub_log("Value returned: %p\n", + ret_val); + return ret_val; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueAcquireGLObjects(cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem * mem_objects, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event ) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int ret_val = -5; + test_icd_stub_log("clEnqueueAcquireGLObjects(%p, %u, %p, %u, %p, %p)\n", + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %p\n", + ret_val); + return ret_val; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReleaseGLObjects(cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem * mem_objects, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event ) CL_API_SUFFIX__VERSION_1_0 + +{ + cl_int ret_val = -5; + test_icd_stub_log("clEnqueueReleaseGLObjects(%p, %u, %p, %u, %p, %p)\n", + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); + test_icd_stub_log("Value returned: %p\n", + ret_val); + return ret_val; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetGLContextInfoKHR(const cl_context_properties * properties, + cl_gl_context_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret ) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int ret_val = -5; + test_icd_stub_log("clGetGLContextInfoKHR(%p, %u, %u, %p, %p)\n", + properties, + param_name, + param_value_size, + param_value, + param_value_size_ret); + + test_icd_stub_log("Value returned: %p\n", + ret_val); + return ret_val; +} + +CL_API_ENTRY cl_event CL_API_CALL +clCreateEventFromGLsyncKHR(cl_context context , + cl_GLsync cl_GLsync , + cl_int * errcode_ret ) CL_EXT_SUFFIX__VERSION_1_1 + +{ + cl_event ret_event = (cl_event)(SIZE_T_MAX); + test_icd_stub_log("clCreateEventFromGLsyncKHR(%p, %p, %p)\n", + context, + cl_GLsync, + errcode_ret); + test_icd_stub_log("Value returned: %p\n", + ret_event); + return ret_event; +} diff --git a/khronos_icd/test/driver_stub/driver_stub.def b/khronos_icd/test/driver_stub/driver_stub.def new file mode 100644 index 000000000..5b238e8e1 --- /dev/null +++ b/khronos_icd/test/driver_stub/driver_stub.def @@ -0,0 +1,3 @@ +EXPORTS +clGetExtensionFunctionAddress +clIcdGetPlatformIDsKHR diff --git a/khronos_icd/test/driver_stub/icd.c b/khronos_icd/test/driver_stub/icd.c new file mode 100644 index 000000000..e456e431a --- /dev/null +++ b/khronos_icd/test/driver_stub/icd.c @@ -0,0 +1,185 @@ +#include +#include +#include +#include +#include "icd_structs.h" + +#define CL_USE_DEPRECATED_OPENCL_1_1_APIS +#define CL_USE_DEPRECATED_OPENCL_1_0_APIS + +// Need to rename all CL API functions to prevent ICD loader functions calling +// themselves via the dispatch table. Include this before cl headers. +#include "rename_api.h" + +#include "CL/cl.h" +#include "CL/cl_gl.h" +#include "CL/cl_gl_ext.h" + +/* + * Prototypes for deprecated functions no longer present in cl.h + */ +extern CL_API_ENTRY cl_int CL_API_CALL +clSetCommandQueueProperty(cl_command_queue /* command_queue */, + cl_command_queue_properties /* properties */, + cl_bool /* enable */, + cl_command_queue_properties * /* old_properties */); + +#define ICD_DISPATCH_TABLE_ENTRY(fn) \ + assert(dispatchTable->entryCount < 256); \ + dispatchTable->entries[dispatchTable->entryCount++] = (void*)(fn) + +cl_int cliIcdDispatchTableCreate(CLIicdDispatchTable **outDispatchTable) +{ + CLIicdDispatchTable *dispatchTable = NULL; + cl_int result = CL_SUCCESS; + + // allocate the public handle + dispatchTable = (CLIicdDispatchTable *) malloc(sizeof(*dispatchTable)); + if (!dispatchTable) { + result = CL_OUT_OF_HOST_MEMORY; + goto Error; + } + memset(dispatchTable, 0, sizeof(*dispatchTable)); + + // OpenCL 1.0 + ICD_DISPATCH_TABLE_ENTRY ( clGetPlatformIDs ); + ICD_DISPATCH_TABLE_ENTRY ( clGetPlatformInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clGetDeviceIDs ); + ICD_DISPATCH_TABLE_ENTRY ( clGetDeviceInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateContext ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateContextFromType ); + ICD_DISPATCH_TABLE_ENTRY ( clRetainContext ); + ICD_DISPATCH_TABLE_ENTRY ( clReleaseContext ); + ICD_DISPATCH_TABLE_ENTRY ( clGetContextInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateCommandQueue ); + ICD_DISPATCH_TABLE_ENTRY ( clRetainCommandQueue ); + ICD_DISPATCH_TABLE_ENTRY ( clReleaseCommandQueue ); + ICD_DISPATCH_TABLE_ENTRY ( clGetCommandQueueInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clSetCommandQueueProperty ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateBuffer ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateImage2D ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateImage3D ); + ICD_DISPATCH_TABLE_ENTRY ( clRetainMemObject ); + ICD_DISPATCH_TABLE_ENTRY ( clReleaseMemObject ); + ICD_DISPATCH_TABLE_ENTRY ( clGetSupportedImageFormats ); + ICD_DISPATCH_TABLE_ENTRY ( clGetMemObjectInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clGetImageInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateSampler ); + ICD_DISPATCH_TABLE_ENTRY ( clRetainSampler ); + ICD_DISPATCH_TABLE_ENTRY ( clReleaseSampler ); + ICD_DISPATCH_TABLE_ENTRY ( clGetSamplerInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateProgramWithSource ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateProgramWithBinary ); + ICD_DISPATCH_TABLE_ENTRY ( clRetainProgram ); + ICD_DISPATCH_TABLE_ENTRY ( clReleaseProgram ); + ICD_DISPATCH_TABLE_ENTRY ( clBuildProgram ); + ICD_DISPATCH_TABLE_ENTRY ( clUnloadCompiler ); + ICD_DISPATCH_TABLE_ENTRY ( clGetProgramInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clGetProgramBuildInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateKernel ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateKernelsInProgram ); + ICD_DISPATCH_TABLE_ENTRY ( clRetainKernel ); + ICD_DISPATCH_TABLE_ENTRY ( clReleaseKernel ); + ICD_DISPATCH_TABLE_ENTRY ( clSetKernelArg ); + ICD_DISPATCH_TABLE_ENTRY ( clGetKernelInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clGetKernelWorkGroupInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clWaitForEvents ); + ICD_DISPATCH_TABLE_ENTRY ( clGetEventInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clRetainEvent ); + ICD_DISPATCH_TABLE_ENTRY ( clReleaseEvent ); + ICD_DISPATCH_TABLE_ENTRY ( clGetEventProfilingInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clFlush ); + ICD_DISPATCH_TABLE_ENTRY ( clFinish ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueReadBuffer ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueWriteBuffer ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueCopyBuffer ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueReadImage ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueWriteImage ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueCopyImage ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueCopyImageToBuffer ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueCopyBufferToImage ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueMapBuffer ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueMapImage ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueUnmapMemObject ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueNDRangeKernel ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueTask ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueNativeKernel ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueMarker ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueWaitForEvents ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueBarrier ); + ICD_DISPATCH_TABLE_ENTRY ( clGetExtensionFunctionAddress ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateFromGLBuffer ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateFromGLTexture2D ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateFromGLTexture3D ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateFromGLRenderbuffer ); + ICD_DISPATCH_TABLE_ENTRY ( clGetGLObjectInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clGetGLTextureInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueAcquireGLObjects ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueReleaseGLObjects ); + + // cl_khr_gl_sharing + ICD_DISPATCH_TABLE_ENTRY ( clGetGLContextInfoKHR ); + + // cl_khr_d3d10_sharing (windows-only) +#if 0 && defined(_WIN32) + ICD_DISPATCH_TABLE_ENTRY ( clGetDeviceIDsFromD3D10KHR ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateFromD3D10BufferKHR ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateFromD3D10Texture2DKHR ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateFromD3D10Texture3DKHR ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueAcquireD3D10ObjectsKHR ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueReleaseD3D10ObjectsKHR ); +#else + ICD_DISPATCH_TABLE_ENTRY( NULL ); + ICD_DISPATCH_TABLE_ENTRY( NULL ); + ICD_DISPATCH_TABLE_ENTRY( NULL ); + ICD_DISPATCH_TABLE_ENTRY( NULL ); + ICD_DISPATCH_TABLE_ENTRY( NULL ); + ICD_DISPATCH_TABLE_ENTRY( NULL ); +#endif + + // OpenCL 1.1 + ICD_DISPATCH_TABLE_ENTRY ( clSetEventCallback); + ICD_DISPATCH_TABLE_ENTRY ( clCreateSubBuffer); + ICD_DISPATCH_TABLE_ENTRY ( clSetMemObjectDestructorCallback); + ICD_DISPATCH_TABLE_ENTRY ( clCreateUserEvent); + ICD_DISPATCH_TABLE_ENTRY ( clSetUserEventStatus); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueReadBufferRect); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueWriteBufferRect); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueCopyBufferRect); + + ICD_DISPATCH_TABLE_ENTRY ( /*clCreateSubDevicesEXT*/NULL); + ICD_DISPATCH_TABLE_ENTRY ( /*clRetainDeviceEXT*/ NULL); + ICD_DISPATCH_TABLE_ENTRY ( /*clReleaseDevice*/NULL); + + ICD_DISPATCH_TABLE_ENTRY ( clCreateEventFromGLsyncKHR); + + ICD_DISPATCH_TABLE_ENTRY ( clCreateSubDevices); + ICD_DISPATCH_TABLE_ENTRY ( clRetainDevice); + ICD_DISPATCH_TABLE_ENTRY ( clReleaseDevice); + ICD_DISPATCH_TABLE_ENTRY ( clCreateImage); + ICD_DISPATCH_TABLE_ENTRY ( clCreateProgramWithBuiltInKernels); + ICD_DISPATCH_TABLE_ENTRY ( clCompileProgram); + ICD_DISPATCH_TABLE_ENTRY ( clLinkProgram); + ICD_DISPATCH_TABLE_ENTRY ( clUnloadPlatformCompiler); + ICD_DISPATCH_TABLE_ENTRY ( clGetKernelArgInfo); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueFillBuffer); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueFillImage); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueMigrateMemObjects); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueMarkerWithWaitList); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueBarrierWithWaitList); + ICD_DISPATCH_TABLE_ENTRY ( clGetExtensionFunctionAddressForPlatform); + ICD_DISPATCH_TABLE_ENTRY ( clCreateFromGLTexture); + + // return success + *outDispatchTable = dispatchTable; + return CL_SUCCESS; + +Error: + return result; +} + +void +cliIcdDispatchTableDestroy(CLIicdDispatchTable *dispatchTable) +{ + free(dispatchTable); +} diff --git a/khronos_icd/test/driver_stub/icd_driver_exports.map b/khronos_icd/test/driver_stub/icd_driver_exports.map new file mode 100644 index 000000000..c6386a26e --- /dev/null +++ b/khronos_icd/test/driver_stub/icd_driver_exports.map @@ -0,0 +1,8 @@ +{ + global: +clGetExtensionFunctionAddress; +clGetPlatformInfo; + + local: + *; +}; diff --git a/khronos_icd/test/driver_stub/icd_structs.h b/khronos_icd/test/driver_stub/icd_structs.h new file mode 100644 index 000000000..4b7e68b11 --- /dev/null +++ b/khronos_icd/test/driver_stub/icd_structs.h @@ -0,0 +1,18 @@ +#ifndef _ICD_STRUCTS_H_ +#define _ICD_STRUCTS_H_ + +typedef struct CLIicdDispatchTable_st CLIicdDispatchTable; +typedef struct CLIplatform_st CLIplatform; + +struct CLIicdDispatchTable_st +{ + void *entries[256]; + int entryCount; +}; + +struct CLIplatform_st +{ + CLIicdDispatchTable* dispatch; +}; + +#endif /* _ICD_STRUCTS_H_ */ diff --git a/khronos_icd/test/driver_stub/rename_api.h b/khronos_icd/test/driver_stub/rename_api.h new file mode 100644 index 000000000..7d5130cec --- /dev/null +++ b/khronos_icd/test/driver_stub/rename_api.h @@ -0,0 +1,106 @@ +#ifndef _RENAME_API_H_ +#define _RENAME_API_H_ + +#define clGetPlatformIDs ___clGetPlatformIDs +#define clGetPlatformInfo ___clGetPlatformInfo +#define clGetDeviceIDs ___clGetDeviceIDs +#define clGetDeviceInfo ___clGetDeviceInfo +#define clCreateSubDevices ___clCreateSubDevices +#define clRetainDevice ___clRetainDevice +#define clReleaseDevice ___clReleaseDevice +#define clCreateContext ___clCreateContext +#define clCreateContextFromType ___clCreateContextFromType +#define clRetainContext ___clRetainContext +#define clReleaseContext ___clReleaseContext +#define clGetContextInfo ___clGetContextInfo +#define clCreateCommandQueue ___clCreateCommandQueue +#define clSetCommandQueueProperty ___clSetCommandQueueProperty +#define clRetainCommandQueue ___clRetainCommandQueue +#define clReleaseCommandQueue ___clReleaseCommandQueue +#define clGetCommandQueueInfo ___clGetCommandQueueInfo +#define clCreateBuffer ___clCreateBuffer +#define clCreateSubBuffer ___clCreateSubBuffer +#define clCreateImage ___clCreateImage +#define clCreateImage2D ___clCreateImage2D +#define clCreateImage3D ___clCreateImage3D +#define clRetainMemObject ___clRetainMemObject +#define clReleaseMemObject ___clReleaseMemObject +#define clGetSupportedImageFormats ___clGetSupportedImageFormats +#define clGetMemObjectInfo ___clGetMemObjectInfo +#define clGetImageInfo ___clGetImageInfo +#define clSetMemObjectDestructorCallback ___clSetMemObjectDestructorCallback +#define clCreateSampler ___clCreateSampler +#define clRetainSampler ___clRetainSampler +#define clReleaseSampler ___clReleaseSampler +#define clGetSamplerInfo ___clGetSamplerInfo +#define clCreateProgramWithSource ___clCreateProgramWithSource +#define clCreateProgramWithBinary ___clCreateProgramWithBinary +#define clCreateProgramWithBuiltInKernels ___clCreateProgramWithBuiltInKernels +#define clRetainProgram ___clRetainProgram +#define clReleaseProgram ___clReleaseProgram +#define clBuildProgram ___clBuildProgram +#define clUnloadCompiler ___clUnloadCompiler +#define clCompileProgram ___clCompileProgram +#define clLinkProgram ___clLinkProgram +#define clUnloadPlatformCompiler ___clUnloadPlatformCompiler +#define clGetProgramInfo ___clGetProgramInfo +#define clGetProgramBuildInfo ___clGetProgramBuildInfo +#define clCreateKernel ___clCreateKernel +#define clCreateKernelsInProgram ___clCreateKernelsInProgram +#define clRetainKernel ___clRetainKernel +#define clReleaseKernel ___clReleaseKernel +#define clSetKernelArg ___clSetKernelArg +#define clGetKernelInfo ___clGetKernelInfo +#define clGetKernelArgInfo ___clGetKernelArgInfo +#define clGetKernelWorkGroupInfo ___clGetKernelWorkGroupInfo +#define clWaitForEvents ___clWaitForEvents +#define clGetEventInfo ___clGetEventInfo +#define clCreateUserEvent ___clCreateUserEvent +#define clRetainEvent ___clRetainEvent +#define clReleaseEvent ___clReleaseEvent +#define clSetUserEventStatus ___clSetUserEventStatus +#define clSetEventCallback ___clSetEventCallback +#define clGetEventProfilingInfo ___clGetEventProfilingInfo +#define clFlush ___clFlush +#define clFinish ___clFinish +#define clEnqueueReadBuffer ___clEnqueueReadBuffer +#define clEnqueueReadBufferRect ___clEnqueueReadBufferRect +#define clEnqueueWriteBuffer ___clEnqueueWriteBuffer +#define clEnqueueWriteBufferRect ___clEnqueueWriteBufferRect +#define clEnqueueCopyBuffer ___clEnqueueCopyBuffer +#define clEnqueueCopyBufferRect ___clEnqueueCopyBufferRect +#define clEnqueueFillBuffer ___clEnqueueFillBuffer +#define clEnqueueFillImage ___clEnqueueFillImage +#define clEnqueueReadImage ___clEnqueueReadImage +#define clEnqueueWriteImage ___clEnqueueWriteImage +#define clEnqueueCopyImage ___clEnqueueCopyImage +#define clEnqueueCopyImageToBuffer ___clEnqueueCopyImageToBuffer +#define clEnqueueCopyBufferToImage ___clEnqueueCopyBufferToImage +#define clEnqueueMapBuffer ___clEnqueueMapBuffer +#define clEnqueueMapImage ___clEnqueueMapImage +#define clEnqueueUnmapMemObject ___clEnqueueUnmapMemObject +#define clEnqueueMigrateMemObjects ___clEnqueueMigrateMemObjects +#define clEnqueueNDRangeKernel ___clEnqueueNDRangeKernel +#define clEnqueueTask ___clEnqueueTask +#define clEnqueueNativeKernel ___clEnqueueNativeKernel +#define clGetExtensionFunctionAddressForPlatform ___clGetExtensionFunctionAddressForPlatform +#define clEnqueueMarkerWithWaitList ___clEnqueueMarkerWithWaitList +#define clEnqueueBarrierWithWaitList ___clEnqueueBarrierWithWaitList +#define clSetPrintfCallback ___clSetPrintfCallback +#define clEnqueueMarker ___clEnqueueMarker +#define clEnqueueWaitForEvents ___clEnqueueWaitForEvents +#define clEnqueueBarrier ___clEnqueueBarrier + +#define clCreateFromGLBuffer ___clCreateFromGLBuffer +#define clCreateFromGLTexture ___clCreateFromGLTexture +#define clCreateFromGLTexture2D ___clCreateFromGLTexture2D +#define clCreateFromGLTexture3D ___clCreateFromGLTexture3D +#define clCreateFromGLRenderbuffer ___clCreateFromGLRenderbuffer +#define clGetGLObjectInfo ___clGetGLObjectInfo +#define clGetGLTextureInfo ___clGetGLTextureInfo +#define clEnqueueAcquireGLObjects ___clEnqueueAcquireGLObjects +#define clEnqueueReleaseGLObjects ___clEnqueueReleaseGLObjects +#define clGetGLContextInfoKHR ___clGetGLContextInfoKHR +#define clCreateEventFromGLsyncKHR ___clCreateEventFromGLsyncKHR + +#endif /* __RENAME_API_H__ */ diff --git a/khronos_icd/test/inc/platform/icd_test_log.h b/khronos_icd/test/inc/platform/icd_test_log.h new file mode 100644 index 000000000..6db0bfe6a --- /dev/null +++ b/khronos_icd/test/inc/platform/icd_test_log.h @@ -0,0 +1,20 @@ +#ifndef _ICD_TEST_LOG_H_ +#define _ICD_TEST_LOG_H_ + +#if defined (_WIN32) +#define DllExport __declspec( dllexport ) +#else +#define DllExport +#endif + +DllExport int test_icd_initialize_app_log(void); +DllExport void test_icd_app_log(const char *format, ...); +DllExport void test_icd_close_app_log(void); +DllExport char *test_icd_get_stub_log(void); + +DllExport int test_icd_initialize_stub_log(void); +DllExport void test_icd_stub_log(const char *format, ...); +DllExport void test_icd_close_stub_log(void); +DllExport char *test_icd_get_app_log(void); + +#endif /* _ICD_TEST_LOG_H_ */ diff --git a/khronos_icd/test/loader_test/CMakeLists.txt b/khronos_icd/test/loader_test/CMakeLists.txt new file mode 100644 index 000000000..ddc675b42 --- /dev/null +++ b/khronos_icd/test/loader_test/CMakeLists.txt @@ -0,0 +1,15 @@ +add_executable (icd_loader_test + test_kernel.c + main.c + test_platforms.c + icd_test_match.c + test_program_objects.c + test_sampler_objects.c + test_buffer_object.c + test_cl_runtime.c + callbacks.c + test_create_calls.c + test_clgl.c + test_image_objects.c ) + +target_link_libraries (icd_loader_test OpenCL IcdLog) diff --git a/khronos_icd/test/loader_test/Makefile b/khronos_icd/test/loader_test/Makefile new file mode 100644 index 000000000..4b0dfe33d --- /dev/null +++ b/khronos_icd/test/loader_test/Makefile @@ -0,0 +1,16 @@ +CC := gcc +CFLAGS := -I ../inc -I ../../ -g -O0 + +OUTDIR := ../../bin + +${OUTDIR}/icd_loader_test: main.c callbacks.c icd_test_match.c + +${OUTDIR}/icd_loader_test: test_buffer_object.c test_clgl.c test_cl_runtime.c test_create_calls.c test_image_objects.c + +${OUTDIR}/icd_loader_test: test_kernel.c test_platforms.c test_program_objects.c test_sampler_objects.c + ${CC} ${CFLAGS} ${OUTDIR}/libOpenCL.so -o $@ $^ ${OUTDIR}/libIcdLog.so + +.PHONY: clean + +clean: + rm -f ${OUTDIR}/icd_loader_test diff --git a/khronos_icd/test/loader_test/callbacks.c b/khronos_icd/test/loader_test/callbacks.c new file mode 100644 index 000000000..8e0b4934b --- /dev/null +++ b/khronos_icd/test/loader_test/callbacks.c @@ -0,0 +1,43 @@ +#include +#include +#include + +void CL_CALLBACK createcontext_callback(const char* _a, const void* _b, size_t _c, void* _d) +{ + test_icd_app_log("createcontext_callback(%p, %p, %u, %p)\n", + _a, + _b, + _c, + _d); +} + +void CL_CALLBACK setmemobjectdestructor_callback(cl_mem _a, void* _b) +{ + test_icd_app_log("setmemobjectdestructor_callback(%p, %p)\n", + _a, + _b); +} + +void CL_CALLBACK program_callback(cl_program _a, void* _b) +{ + test_icd_app_log("program_callback(%p, %p)\n", + _a, + _b); +} + +void CL_CALLBACK setevent_callback(cl_event _a, cl_int _b, void* _c) +{ + test_icd_app_log("setevent_callback(%p, %d, %p)\n", + _a, + _b, + _c); +} + +void CL_CALLBACK setprintf_callback(cl_context _a, cl_uint _b, char* _c, void* _d ) +{ + test_icd_app_log("setprintf_callback(%p, %u, %p, %p)\n", + _a, + _b, + _c, + _d); +} diff --git a/khronos_icd/test/loader_test/icd_test_match.c b/khronos_icd/test/loader_test/icd_test_match.c new file mode 100644 index 000000000..a58bb5fcc --- /dev/null +++ b/khronos_icd/test/loader_test/icd_test_match.c @@ -0,0 +1,36 @@ +#include +#include +#include +#include + +int test_icd_match() +{ + int error = 0; + char *app_log = NULL, *stub_log = NULL; + + app_log = test_icd_get_app_log(); + if (!app_log) { + printf("ERROR: Could not retrieve app log\n"); + error = 1; + goto End; + } + + stub_log = test_icd_get_stub_log(); + if (!stub_log) { + printf("ERROR: Could not retrieve stub log\n"); + error = 1; + goto End; + } + + if (strcmp(app_log, stub_log)) { + printf("ERROR: App log and stub log differ.\n"); + error = 1; + goto End; + } + +End: + free(app_log); + free(stub_log); + return error; +} + diff --git a/khronos_icd/test/loader_test/main.c b/khronos_icd/test/loader_test/main.c new file mode 100644 index 000000000..a933946fa --- /dev/null +++ b/khronos_icd/test/loader_test/main.c @@ -0,0 +1,47 @@ +#include +#include +#include +#include "param_struct.h" + +extern int test_create_calls(); +extern int test_platforms(); +extern int test_cl_runtime(); +extern int test_kernel(); +extern int test_buffer_object(); +extern int test_program_objects(); +extern int test_image_objects(); +extern int test_sampler_objects(); +extern int initialize_log(); +extern int test_icd_match(); + +extern int test_OpenGL_share(); +extern int test_Direct3D10_share(); + +int main(int argc, char **argv) +{ + test_icd_initialize_app_log(); + test_icd_initialize_stub_log(); + + test_create_calls(); + test_platforms(); + test_cl_runtime(); + test_kernel(); + test_buffer_object(); + test_program_objects(); + test_image_objects(); + test_sampler_objects(); + test_OpenGL_share(); + +// test_Direct3D10_share(); + test_release_calls(); + test_icd_close_app_log(); + test_icd_close_stub_log(); + + if (test_icd_match()) { + printf("ICD Loader Test FAILED\n"); + return 1; + } else { + printf("ICD Loader Test PASSED\n"); + return 0; + } +} diff --git a/khronos_icd/test/loader_test/param_struct.h b/khronos_icd/test/loader_test/param_struct.h new file mode 100644 index 000000000..1e1aab619 --- /dev/null +++ b/khronos_icd/test/loader_test/param_struct.h @@ -0,0 +1,1115 @@ +#ifndef _PARAM_STRUCT_H_ +#define _PARAM_STRUCT_H_ + +#include +#include +#include + +#ifdef _WIN32 +#include /* Needed for gl.h */ +#endif +#include + +struct clCreateCommandQueue_st +{ + cl_context context; + cl_device_id device; + cl_command_queue_properties properties; + cl_int *errcode_ret; +}; + +struct clSetCommandQueueProperty_st +{ + cl_command_queue command_queue; + cl_command_queue_properties properties; + cl_bool enable; + cl_command_queue_properties *old_properties; +}; + +struct clGetCommandQueueInfo_st +{ + cl_command_queue command_queue; + cl_command_queue_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +struct clCreateContext_st +{ + const cl_context_properties *properties; + cl_uint num_devices; + const cl_device_id *devices; + void (CL_CALLBACK*pfn_notify)(const char *errinfo, const void *private_info, size_t cb, void *user_data); + void *user_data; + cl_int *errcode_ret; +}; + +struct clCreateContextFromType_st +{ + const cl_context_properties *properties; + cl_device_type device_type; + void (CL_CALLBACK *pfn_notify)(const char *errinfo, const void *private_info, size_t cb,void *user_data); + void *user_data; + cl_int *errcode_ret; +}; + +struct clRetainContext_st +{ + cl_context context; +}; + +struct clReleaseContext_st +{ + cl_context context; +}; + +struct clGetContextInfo_st +{ + cl_context context; + cl_context_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +struct clGetPlatformIDs_st +{ + cl_uint num_entries; + cl_platform_id *platforms; + cl_uint *num_platforms; +}; + +struct clGetPlatformInfo_st +{ + cl_platform_id platform; + cl_platform_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +struct clGetDeviceIDs_st +{ + cl_platform_id platform; + cl_device_type device_type; + cl_uint num_entries; + cl_device_id *devices; + cl_uint *num_devices; +}; + +struct clRetainCommandQueue_st +{ + cl_command_queue command_queue; +}; + +struct clReleaseCommandQueue_st +{ + cl_command_queue command_queue; +}; + +#define NUM_ITEMS_clCreateCommandQueue 1 +#define NUM_ITEMS_clRetainCommandQueue 1 +#define NUM_ITEMS_clReleaseCommandQueue 1 +#define NUM_ITEMS_clGetCommandQueueInfo 1 +#define NUM_ITEMS_clSetCommandQueueProperty 1 +#define NUM_ITEMS_clCreateContext 1 +#define NUM_ITEMS_clCreateContextFromType 1 +#define NUM_ITEMS_clRetainContext 1 +#define NUM_ITEMS_clReleaseContext 1 +#define NUM_ITEMS_clGetContextInfo 1 +#define NUM_ITEMS_clGetPlatformIDs 1 +#define NUM_ITEMS_clGetPlatformInfo 1 +#define NUM_ITEMS_clGetDeviceIDs 1 +#define NUM_ITEMS_clGetDeviceInfo 1 +#define NUM_ITEMS_clCreateSubDevices 1 +#define NUM_ITEMS_clRetainDevice 1 +#define NUM_ITEMS_clReleaseDevice 1 + +struct clGetDeviceInfo_st +{ + cl_device_id device; + cl_device_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +struct clCreateSubDevices_st +{ + cl_device_id in_device; + cl_device_partition_property *properties; + cl_uint num_entries; + cl_device_id *out_devices; + cl_uint *num_devices; +}; + +struct clRetainDevice_st +{ + cl_device_id device; +}; + +struct clReleaseDevice_st +{ + cl_device_id device; +}; + + +#define NUM_ITEMS_clCreateBuffer 1 +#define NUM_ITEMS_clCreateSubBuffer 1 +#define NUM_ITEMS_clEnqueueReadBuffer 1 +#define NUM_ITEMS_clEnqueueWriteBuffer 1 +#define NUM_ITEMS_clEnqueueReadBufferRect 1 +#define NUM_ITEMS_clEnqueueWriteBufferRect 1 +#define NUM_ITEMS_clEnqueueFillBuffer 1 +#define NUM_ITEMS_clEnqueueCopyBuffer 1 +#define NUM_ITEMS_clEnqueueCopyBufferRect 1 +#define NUM_ITEMS_clEnqueueMapBuffer 1 +#define NUM_ITEMS_clRetainMemObject 1 +#define NUM_ITEMS_clReleaseMemObject 1 +#define NUM_ITEMS_clSetMemObjectDestructorCallback 1 +#define NUM_ITEMS_clEnqueueUnmapMemObject 1 +#define NUM_ITEMS_clGetMemObjectInfo 1 + +struct clCreateBuffer_st +{ + cl_context context; + cl_mem_flags flags; + size_t size; + void *host_ptr; + cl_int *errcode_ret; +}; +struct clCreateSubBuffer_st +{ + cl_mem buffer; + cl_mem_flags flags; + cl_buffer_create_type buffer_create_type; + const void *buffer_create_info; + cl_int *errcode_ret; +}; + +struct clEnqueueReadBuffer_st +{ + cl_command_queue command_queue; + cl_mem buffer; + cl_bool blocking_read; + size_t offset; + size_t cb; + void *ptr; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueWriteBuffer_st +{ + cl_command_queue command_queue; + cl_mem buffer; + cl_bool blocking_write; + size_t offset; + size_t cb; + const void *ptr; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueReadBufferRect_st +{ + cl_command_queue command_queue; + cl_mem buffer; + cl_bool blocking_read; + const size_t * buffer_offset; + const size_t * host_offset; + const size_t * region; + size_t buffer_row_pitch; + size_t buffer_slice_pitch; + size_t host_row_pitch; + size_t host_slice_pitch; + void *ptr; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueWriteBufferRect_st +{ + cl_command_queue command_queue; + cl_mem buffer; + cl_bool blocking_write; + const size_t *buffer_offset; + const size_t *host_offset; + const size_t *region; + size_t buffer_row_pitch; + size_t buffer_slice_pitch; + size_t host_row_pitch; + size_t host_slice_pitch; + void *ptr; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueFillBuffer_st +{ + cl_command_queue command_queue; + cl_mem buffer; + const void *pattern; + size_t pattern_size; + size_t offset; + size_t cb; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueCopyBuffer_st +{ + cl_command_queue command_queue; + cl_mem src_buffer; + cl_mem dst_buffer; + size_t src_offset; + size_t dst_offset; + size_t cb; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueCopyBufferRect_st +{ + cl_command_queue command_queue; + cl_mem src_buffer; + cl_mem dst_buffer; + const size_t *src_origin; + const size_t *dst_origin; + const size_t *region; + size_t src_row_pitch; + size_t src_slice_pitch; + size_t dst_row_pitch; + size_t dst_slice_pitch; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueMapBuffer_st +{ + cl_command_queue command_queue; + cl_mem buffer; + cl_bool blocking_map; + cl_map_flags map_flags; + size_t offset; + size_t cb; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; + cl_int *errcode_ret; +}; + +struct clRetainMemObject_st +{ + cl_mem memobj; +}; + +struct clReleaseMemObject_st +{ + cl_mem memobj; +}; + +struct clSetMemObjectDestructorCallback_st +{ + cl_mem memobj; + void (CL_CALLBACK *pfn_notify)(cl_mem memobj, void *user_data); + void *user_data; +}; + +struct clEnqueueUnmapMemObject_st +{ + cl_command_queue command_queue; + cl_mem memobj; + void *mapped_ptr; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clGetMemObjectInfo_st +{ + cl_mem memobj; + cl_mem_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +#define NUM_ITEMS_clCreateProgramWithSource 1 +#define NUM_ITEMS_clCreateProgramWithBinary 1 +#define NUM_ITEMS_clCreateProgramWithBuiltInKernels 1 +#define NUM_ITEMS_clRetainProgram 1 +#define NUM_ITEMS_clReleaseProgram 1 +#define NUM_ITEMS_clBuildProgram 1 +#define NUM_ITEMS_clCompileProgram 1 +#define NUM_ITEMS_clLinkProgram 1 +#define NUM_ITEMS_clUnloadPlatformCompiler 1 +#define NUM_ITEMS_clGetProgramInfo 1 +#define NUM_ITEMS_clGetProgramBuildInfo 1 +#define NUM_ITEMS_clUnloadCompiler 1 +#define NUM_ITEMS_clGetExtensionFunctionAddress 1 +#define NUM_ITEMS_clGetExtensionFunctionAddressForPlatform 1 + +struct clCreateProgramWithSource_st +{ + cl_context context; + cl_uint count; + const char **strings; + const size_t *lengths; + cl_int *errcode_ret; +}; + +struct clCreateProgramWithBinary_st +{ + cl_context context; + cl_uint num_devices; + const cl_device_id *device_list; + const size_t *lengths; + const unsigned char **binaries; + cl_int *binary_status; + cl_int *errcode_ret; +}; + +struct clCreateProgramWithBuiltInKernels_st +{ + cl_context context; + cl_uint num_devices; + const cl_device_id *device_list; + const char *kernel_names; + cl_int *errcode_ret; +}; + +struct clRetainProgram_st +{ + cl_program program; +}; + +struct clReleaseProgram_st +{ + cl_program program; +}; + +struct clBuildProgram_st +{ + cl_program program; + cl_uint num_devices; + const cl_device_id *device_list; + const char *options; + void (CL_CALLBACK*pfn_notify)(cl_program program, void *user_data); + void *user_data; +}; + +struct clCompileProgram_st +{ + cl_program program; + cl_uint num_devices; + const cl_device_id *device_list; + const char *options; + cl_uint num_input_headers; + const cl_program *headers; + const char **header_include_names; + void (CL_CALLBACK *pfn_notify)(cl_program program, void * user_data); + void *user_data; +}; + +struct clLinkProgram_st +{ + cl_context context; + cl_uint num_devices; + const cl_device_id *device_list; + const char *options; + cl_uint num_input_programs; + const cl_program *input_programs; + void (CL_CALLBACK *pfn_notify)(cl_program program, void *user_data); + void *user_data; + cl_int *errcode_ret; +}; + +struct clUnloadPlatformCompiler_st +{ + cl_platform_id platform; +}; + +#if 0 +struct clUnloadCompiler_st +{ + void ; +}; +#endif + +struct clGetExtensionFunctionAddress_st +{ + const char *func_name; +}; + +struct clGetExtensionFunctionAddressForPlatform_st +{ + cl_platform_id platform; + const char *func_name; +}; + +struct clGetProgramInfo_st +{ + cl_program program; + cl_program_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +struct clGetProgramBuildInfo_st +{ + cl_program program; + cl_device_id device; + cl_program_build_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +#define NUM_ITEMS_clCreateImage2D 1 +#define NUM_ITEMS_clCreateImage3D 1 +#define NUM_ITEMS_clCreateImage 1 +#define NUM_ITEMS_clGetSupportedImageFormats 1 +#define NUM_ITEMS_clEnqueueCopyImageToBuffer 1 +#define NUM_ITEMS_clEnqueueCopyBufferToImage 1 +#define NUM_ITEMS_clEnqueueMapImage 1 +#define NUM_ITEMS_clEnqueueReadImage 1 +#define NUM_ITEMS_clEnqueueWriteImage 1 +#define NUM_ITEMS_clEnqueueFillImage 1 +#define NUM_ITEMS_clEnqueueCopyImage 1 +#define NUM_ITEMS_clGetMemObjectInfo 1 +#define NUM_ITEMS_clGetImageInfo 1 + +struct clCreateImage_st +{ + cl_context context; + cl_mem_flags flags; + const cl_image_format *image_format; + const cl_image_desc *image_desc; + void *host_ptr; + cl_int *errcode_ret; +}; + +struct clCreateImage2D_st +{ + cl_context context; + cl_mem_flags flags; + const cl_image_format *image_format; + size_t image_width; + size_t image_height; + size_t image_row_pitch; + void *host_ptr; + cl_int *errcode_ret; +}; + +struct clCreateImage3D_st +{ + cl_context context; + cl_mem_flags flags; + const cl_image_format *image_format; + size_t image_width; + size_t image_height; + size_t image_depth; + size_t image_row_pitch; + size_t image_slice_pitch; + void *host_ptr; + cl_int *errcode_ret; +}; + +struct clGetSupportedImageFormats_st +{ + cl_context context; + cl_mem_flags flags; + cl_mem_object_type image_type; + cl_uint num_entries; + cl_image_format *image_formats; + cl_uint *num_image_formats; +}; + +struct clEnqueueCopyImageToBuffer_st +{ + cl_command_queue command_queue; + cl_mem src_image; + cl_mem dst_buffer; + const size_t *src_origin; + const size_t *region; + size_t dst_offset; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueCopyBufferToImage_st +{ + cl_command_queue command_queue; + cl_mem src_buffer; + cl_mem dst_image; + size_t src_offset; + const size_t *dst_origin; + const size_t *region; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueMapImage_st +{ + cl_command_queue command_queue; + cl_mem image; + cl_bool blocking_map; + cl_map_flags map_flags; + const size_t *origin; + const size_t *region; + size_t *image_row_pitch; + size_t *image_slice_pitch; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; + cl_int *errcode_ret; +}; + +struct clEnqueueReadImage_st +{ + cl_command_queue command_queue; + cl_mem image; + cl_bool blocking_read; + const size_t *origin; + const size_t *region; + size_t row_pitch; + size_t slice_pitch; + void *ptr; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueWriteImage_st +{ + cl_command_queue command_queue; + cl_mem image; + cl_bool blocking_write; + const size_t *origin; + const size_t *region; + size_t input_row_pitch; + size_t input_slice_pitch; + const void *ptr; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueFillImage_st +{ + cl_command_queue command_queue; + cl_mem image; + const void *fill_color; + const size_t *origin; + const size_t *region; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueCopyImage_st +{ + cl_command_queue command_queue; + cl_mem src_image; + cl_mem dst_image; + const size_t *src_origin; + const size_t *dst_origin; + const size_t *region; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +#if 0 +struct clGetMemObjectInfo_st +{ + cl_mem memobj; + cl_mem_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; +#endif + +struct clGetImageInfo_st +{ + cl_mem image; + cl_image_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +#define NUM_ITEMS_clCreateSampler 1 +#define NUM_ITEMS_clRetainSampler 1 +#define NUM_ITEMS_clReleaseSampler 1 +#define NUM_ITEMS_clGetSamplerInfo 1 + +struct clCreateSampler_st +{ + cl_context context; + cl_bool normalized_coords; + cl_addressing_mode addressing_mode; + cl_filter_mode filter_mode; + cl_int *errcode_ret; +}; + +struct clRetainSampler_st +{ + cl_sampler sampler; +}; + +struct clReleaseSampler_st +{ + cl_sampler sampler; +}; + +struct clGetSamplerInfo_st +{ + cl_sampler sampler; + cl_sampler_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +#define NUM_ITEMS_clCreateKernel 1 +#define NUM_ITEMS_clCreateKernelsInProgram 1 +#define NUM_ITEMS_clRetainKernel 1 +#define NUM_ITEMS_clReleaseKernel 1 + +struct clCreateKernel_st +{ + cl_program program; + const char *kernel_name; + cl_int *errcode_ret; +}; + +struct clCreateKernelsInProgram_st +{ + cl_program program; + cl_uint num_kernels; + cl_kernel *kernels; + cl_uint *num_kernels_ret; +}; + +struct clRetainKernel_st +{ + cl_kernel kernel; +}; + +struct clReleaseKernel_st +{ + cl_kernel kernel; +}; + +#define NUM_ITEMS_clSetKernelArg 1 +#define NUM_ITEMS_clGetKernelInfo 1 +#define NUM_ITEMS_clGetKernelArgInfo 1 +#define NUM_ITEMS_clGetKernelWorkGroupInfo 1 + +struct clSetKernelArg_st +{ + cl_kernel kernel; + cl_uint arg_index; + size_t arg_size; + const void *arg_value; +}; + +struct clGetKernelInfo_st +{ + cl_kernel kernel; + cl_kernel_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +struct clGetKernelArgInfo_st +{ + cl_kernel kernel; + cl_uint arg_indx; + cl_kernel_arg_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +struct clGetKernelWorkGroupInfo_st +{ + cl_kernel kernel; + cl_device_id device; + cl_kernel_work_group_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +#define NUM_ITEMS_clEnqueueMigrateMemObjects 1 +#define NUM_ITEMS_clEnqueueNDRangeKernel 1 +#define NUM_ITEMS_clEnqueueTask 1 +#define NUM_ITEMS_clEnqueueNativeKernel 1 + +struct clEnqueueMigrateMemObjects_st +{ + cl_command_queue command_queue; + size_t num_mem_objects; + const cl_mem *mem_objects; + cl_mem_migration_flags flags; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueNDRangeKernel_st +{ + cl_command_queue command_queue; + cl_kernel kernel; cl_uint work_dim; + const size_t *global_work_offset; + const size_t *global_work_size; + const size_t *local_work_size; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueTask_st +{ + cl_command_queue command_queue; + cl_kernel kernel; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueNativeKernel_st +{ + cl_command_queue command_queue; + void (CL_CALLBACK *user_func)(void *); + void *args; + size_t cb_args; + cl_uint num_mem_objects; + const cl_mem *mem_list; + const void **args_mem_loc; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +#define NUM_ITEMS_clCreateUserEvent 1 +#define NUM_ITEMS_clSetUserEventStatus 1 +#define NUM_ITEMS_clWaitForEvents 1 +#define NUM_ITEMS_clGetEventInfo 1 +#define NUM_ITEMS_clSetEventCallback 1 +#define NUM_ITEMS_clRetainEvent 1 +#define NUM_ITEMS_clReleaseEvent 1 + +struct clCreateUserEvent_st +{ + cl_context context; + cl_int *errcode_ret; +}; + +struct clSetUserEventStatus_st +{ + cl_event event; + cl_int execution_status; +}; + +struct clWaitForEvents_st +{ + cl_uint num_events; + const cl_event *event_list; +}; + +struct clGetEventInfo_st +{ + cl_event event; + cl_event_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +struct clSetEventCallback_st +{ + cl_event event; + cl_int command_exec_callback_type; + void (CL_CALLBACK *pfn_event_notify)(cl_event event, cl_int event_command_exec_status,void *user_data); + void *user_data; +}; + +struct clRetainEvent_st +{ + cl_event event; +}; + +struct clReleaseEvent_st +{ + cl_event event; +}; + +#define NUM_ITEMS_clEnqueueMarker 1 +#define NUM_ITEMS_clEnqueueWaitForEvents 1 +#define NUM_ITEMS_clEnqueueBarrier 1 +#define NUM_ITEMS_clEnqueueMarkerWithWaitList 1 +#define NUM_ITEMS_clEnqueueBarrierWithWaitList 1 + +struct clEnqueueMarker_st +{ + cl_command_queue command_queue; + cl_event *event; +}; + +struct clEnqueueWaitForEvents_st +{ + cl_command_queue command_queue; + cl_uint num_events; + const cl_event *event_list; +}; + +struct clEnqueueBarrier_st +{ + cl_command_queue command_queue; +}; + +struct clEnqueueMarkerWithWaitList_st +{ + cl_command_queue command_queue; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueBarrierWithWaitList_st +{ + cl_command_queue command_queue; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +#define NUM_ITEMS_clGetEventProfilingInfo 1 + +struct clGetEventProfilingInfo_st +{ + cl_event event; + cl_profiling_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +#define NUM_ITEMS_clFlush 1 +#define NUM_ITEMS_clFinish 1 + +struct clFlush_st +{ + cl_command_queue command_queue; +}; + +struct clFinish_st +{ + cl_command_queue command_queue; +}; + +#define NUM_ITEMS_clCreateFromGLBuffer 1 +struct clCreateFromGLBuffer_st +{ + cl_context context; + cl_mem_flags flags; + GLuint bufobj; + int *errcode_ret; +}; + +#define NUM_ITEMS_clCreateFromGLTexture 1 +#define NUM_ITEMS_clCreateFromGLTexture2D 1 +#define NUM_ITEMS_clCreateFromGLTexture3D 1 + +struct clCreateFromGLTexture_st +{ + cl_context context; + cl_mem_flags flags; + GLenum texture_target; + GLint miplevel; + GLuint texture; + cl_int *errcode_ret; +}; + +struct clCreateFromGLTexture2D_st +{ + cl_context context; + cl_mem_flags flags; + GLenum texture_target; + GLint miplevel; + GLuint texture; + cl_int *errcode_ret; +}; + +struct clCreateFromGLTexture3D_st +{ + cl_context context; + cl_mem_flags flags; + GLenum texture_target; + GLint miplevel; + GLuint texture; + cl_int *errcode_ret; +}; + +#define NUM_ITEMS_clCreateFromGLRenderbuffer 1 + +struct clCreateFromGLRenderbuffer_st +{ + cl_context context; + cl_mem_flags flags; + GLuint renderbuffer; + cl_int *errcode_ret; +}; + + + // Query Information [9.8.5] +#define NUM_ITEMS_clGetGLObjectInfo 1 +#define NUM_ITEMS_clGetGLTextureInfo 1 + +struct clGetGLObjectInfo_st +{ + cl_mem memobj; + cl_gl_object_type *gl_object_type; + GLuint *gl_object_name; +}; + +struct clGetGLTextureInfo_st +{ + cl_mem memobj; + cl_gl_texture_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +// Share Objects [9.8.6] + +#define NUM_ITEMS_clEnqueueAcquireGLObjects 1 +#define NUM_ITEMS_clEnqueueReleaseGLObjects 1 + +struct clEnqueueAcquireGLObjects_st +{ + cl_command_queue command_queue; + cl_uint num_objects; + const cl_mem *mem_objects; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueReleaseGLObjects_st +{ + cl_command_queue command_queue; + cl_uint num_objects; + const cl_mem *mem_objects; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +// CL Event Objects > GL Sync Objects [9.9] +#define NUM_ITEMS_clCreateEventFromGLsyncKHR 1 + +struct clCreateEventFromGLsyncKHR_st +{ + cl_context context; + cl_GLsync sync; + cl_int *errcode_ret; +}; + +// CL Context > GL Context; Sharegroup [9.7] +#define NUM_ITEMS_clGetGLContextInfoKHR 1 + +struct clGetGLContextInfoKHR_st +{ + const cl_context_properties *properties; + cl_gl_context_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +#if 0 +// OpenCL/Direct3D 10 Sharing APIs [9.10] + +#define NUM_ITEMS_clGetDeviceIDsFromD3D10KHR 1 +#define NUM_ITEMS_clCreateFromD3D10BufferKHR 1 +#define NUM_ITEMS_clCreateFromD3D10Texture2DKHR 1 +#define NUM_ITEMS_clCreateFromD3D10Texture3DKHR 1 +#define NUM_ITEMS_clEnqueueAcquireD3D10ObjectsKHR 1 +#define NUM_ITEMS_clEnqueueReleaseD3D10ObjectsKHR 1 + +struct clGetDeviceIDsFromD3D10KHR_st +{ + cl_platform_id platform; + cl_d3d10_device_source_khr d3d_device_source; + void *d3d_object; + cl_d3d10_device_set_khr d3d_device_set; + cl_uint num_entries; + cl_device_id *devices; cl_uint *num_devices; +}; + +struct clCreateFromD3D10BufferKHR_st +{ + cl_context context; + cl_mem_flags flags; + ID3D10Buffer *resource; + cl_int *errcode_ret; +}; + +struct clCreateFromD3D10Texture2DKHR_st +{ + cl_context context; + cl_mem_flags flags; + ID3D10Texture2D *resource; + UINT subresource; + cl_int *errcode_ret; +}; + +struct clCreateFromD3D10Texture3DKHR_st +{ + cl_context context; + cl_mem_flags flags; + ID3D10Texture3D *resource; + UINT subresource; + cl_int *errcode_ret; +}; + +struct clEnqueueAcquireD3D10ObjectsKHR_st +{ + cl_command_queue command_queue; + cl_uint num_objects; + const cl_mem *mem_objects; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event;}; + +struct clEnqueueReleaseD3D10ObjectsKHR_st +{ + cl_command_queue command_queue; + cl_uint num_objects; + const cl_mem *mem_objects; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; +#endif + +#endif /* _PARAM_STRUCT_H_ */ diff --git a/khronos_icd/test/loader_test/test_buffer_object.c b/khronos_icd/test/loader_test/test_buffer_object.c new file mode 100644 index 000000000..85a2178c6 --- /dev/null +++ b/khronos_icd/test/loader_test/test_buffer_object.c @@ -0,0 +1,461 @@ +#include +#include "param_struct.h" +#include + +extern cl_mem buffer; +extern cl_command_queue command_queue; +extern cl_event event; + +static int ret_val; + +extern void CL_CALLBACK setmemobjectdestructor_callback(cl_mem _a, void* _b); + +const struct clEnqueueReadBuffer_st clEnqueueReadBufferData[NUM_ITEMS_clEnqueueReadBuffer] = +{ + {NULL, NULL, 0, 0, 0, NULL, 0, NULL, NULL} +}; + +const struct clEnqueueWriteBuffer_st clEnqueueWriteBufferData[NUM_ITEMS_clEnqueueWriteBuffer] = +{ + {NULL, NULL, 0, 0, 0, NULL, 0, NULL, NULL} +}; + +const struct clEnqueueReadBufferRect_st clEnqueueReadBufferRectData[NUM_ITEMS_clEnqueueReadBufferRect] = +{ + {NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0, NULL, NULL} +}; + +const struct clEnqueueWriteBufferRect_st clEnqueueWriteBufferRectData[NUM_ITEMS_clEnqueueWriteBufferRect] = +{ + {NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0, NULL, NULL} +}; + +const struct clEnqueueFillBuffer_st clEnqueueFillBufferData[NUM_ITEMS_clEnqueueFillBuffer] = +{ + {NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL} +}; + +const struct clEnqueueCopyBuffer_st clEnqueueCopyBufferData[NUM_ITEMS_clEnqueueCopyBuffer] = +{ + {NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL} +}; + +const struct clEnqueueCopyBufferRect_st clEnqueueCopyBufferRectData[NUM_ITEMS_clEnqueueCopyBufferRect] = +{ + {NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL} +}; + +const struct clEnqueueMapBuffer_st clEnqueueMapBufferData[NUM_ITEMS_clEnqueueMapBuffer] = +{ + {NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL} +}; + +const struct clRetainMemObject_st clRetainMemObjectData[NUM_ITEMS_clRetainMemObject] = +{ + {NULL} +}; + +const struct clSetMemObjectDestructorCallback_st clSetMemObjectDestructorCallbackData[NUM_ITEMS_clSetMemObjectDestructorCallback] = +{ + {NULL, setmemobjectdestructor_callback, NULL} +}; + +const struct clEnqueueUnmapMemObject_st clEnqueueUnmapMemObjectData[NUM_ITEMS_clEnqueueUnmapMemObject] = +{ + {NULL, NULL, NULL, 0, NULL, NULL} +}; + +const struct clGetMemObjectInfo_st clGetMemObjectInfoData[NUM_ITEMS_clGetMemObjectInfo] = +{ + {NULL, 0, 0, NULL, NULL} +}; + +int test_clEnqueueReadBuffer(const struct clEnqueueReadBuffer_st *data) +{ + test_icd_app_log("clEnqueueReadBuffer(%p, %p, %u, %u, %u, %p, %u, %p, %p)\n", + command_queue, + buffer, + data->blocking_read, + data->offset, + data->cb, + data->ptr, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val=clEnqueueReadBuffer(command_queue, + buffer, + data->blocking_read, + data->offset, + data->cb, + data->ptr, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +int test_clEnqueueWriteBuffer(const struct clEnqueueWriteBuffer_st *data) +{ + test_icd_app_log("clEnqueueWriteBuffer(%p, %p, %u, %u, %u, %p, %u, %p, %p)\n", + command_queue, + buffer, + data->blocking_write, + data->offset, + data->cb, + data->ptr, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val=clEnqueueWriteBuffer(command_queue, + buffer, + data->blocking_write, + data->offset, + data->cb, + data->ptr, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +int test_clEnqueueReadBufferRect(const struct clEnqueueReadBufferRect_st *data) +{ + test_icd_app_log("clEnqueueReadBufferRect(%p, %p, %u, %p, %p, %p, %u, %u, %u, %u, %p, %u, %p, %p)\n", + command_queue, + buffer, + data->blocking_read, + data->buffer_offset, + data->host_offset, + data->region, + data->buffer_row_pitch, + data->buffer_slice_pitch, + data->host_row_pitch, + data->host_slice_pitch, + data->ptr, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val=clEnqueueReadBufferRect(command_queue, + buffer, + data->blocking_read, + data->buffer_offset, + data->host_offset, + data->region, + data->buffer_row_pitch, + data->buffer_slice_pitch, + data->host_row_pitch, + data->host_slice_pitch, + data->ptr, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clEnqueueWriteBufferRect(const struct clEnqueueWriteBufferRect_st *data) +{ + test_icd_app_log("clEnqueueWriteBufferRect(%p, %p, %u, %p, %p, %p, %u, %u, %u, %u, %p, %u, %p, %p)\n", + command_queue, + buffer, + data->blocking_write, + data->buffer_offset, + data->host_offset, + data->region, + data->buffer_row_pitch, + data->buffer_slice_pitch, + data->host_row_pitch, + data->host_slice_pitch, + data->ptr, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val=clEnqueueWriteBufferRect(command_queue, + buffer, + data->blocking_write, + data->buffer_offset, + data->host_offset, + data->region, + data->buffer_row_pitch, + data->buffer_slice_pitch, + data->host_row_pitch, + data->host_slice_pitch, + data->ptr, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +int test_clEnqueueFillBuffer(const struct clEnqueueFillBuffer_st *data) +{ + test_icd_app_log("clEnqueueFillBuffer(%p, %p, %p, %u, %u, %u, %u, %p, %p)\n", + command_queue, + buffer, + data->pattern, + data->pattern_size, + data->offset, + data->cb, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val=clEnqueueFillBuffer(command_queue, + buffer, + data->pattern, + data->pattern_size, + data->offset, + data->cb, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clEnqueueCopyBuffer(const struct clEnqueueCopyBuffer_st *data) +{ + test_icd_app_log("clEnqueueCopyBuffer(%p, %p, %p, %u, %u, %u, %u, %p, %p)\n", + command_queue, + data->src_buffer, + buffer, + data->src_offset, + data->dst_offset, + data->cb, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val=clEnqueueCopyBuffer(command_queue, + data->src_buffer, + buffer, + data->src_offset, + data->dst_offset, + data->cb, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clEnqueueCopyBufferRect(const struct clEnqueueCopyBufferRect_st *data) +{ + test_icd_app_log("clEnqueueCopyBufferRect(%p, %p, %p, %p, %p, %p, %u, %u, %u, %u, %u, %p, %p)\n", + command_queue, + buffer, + buffer, + data->src_origin, + data->dst_origin, + data->region, + data->src_row_pitch, + data->src_slice_pitch, + data->dst_row_pitch, + data->dst_slice_pitch, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val=clEnqueueCopyBufferRect(command_queue, + buffer, + buffer, + data->src_origin, + data->dst_origin, + data->region, + data->src_row_pitch, + data->src_slice_pitch, + data->dst_row_pitch, + data->dst_slice_pitch, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clEnqueueMapBuffer(const struct clEnqueueMapBuffer_st *data) +{ + void * return_value; + test_icd_app_log("clEnqueueMapBuffer(%p, %p, %u, %x, %u, %u, %u, %p, %p, %p)\n", + command_queue, + buffer, + data->blocking_map, + data->map_flags, + data->offset, + data->cb, + data->num_events_in_wait_list, + data->event_wait_list, + &event, + data->errcode_ret); + + return_value=clEnqueueMapBuffer(command_queue, + buffer, + data->blocking_map, + data->map_flags, + data->offset, + data->cb, + data->num_events_in_wait_list, + data->event_wait_list, + &event, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", return_value); + + free(return_value); + + return 0; + +} + +int test_clRetainMemObject(const struct clRetainMemObject_st *data) +{ + test_icd_app_log("clRetainMemObject(%p)\n", buffer); + + ret_val=clRetainMemObject(buffer); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clSetMemObjectDestructorCallback(const struct clSetMemObjectDestructorCallback_st *data) +{ + test_icd_app_log("clSetMemObjectDestructorCallback(%p, %p, %p)\n", + buffer, + data->pfn_notify, + data->user_data); + + ret_val=clSetMemObjectDestructorCallback(buffer, + data->pfn_notify, + data->user_data); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clEnqueueUnmapMemObject(const struct clEnqueueUnmapMemObject_st *data) +{ + test_icd_app_log("clEnqueueUnmapMemObject(%p, %p, %p, %u, %p, %p)\n", + command_queue, + buffer, + data->mapped_ptr, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val=clEnqueueUnmapMemObject(command_queue, + buffer, + data->mapped_ptr, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + + +int test_clGetMemObjectInfo (const struct clGetMemObjectInfo_st *data) +{ + test_icd_app_log("clGetMemObjectInfo(%p, %u, %u, %p, %p)\n", + buffer, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + ret_val=clGetMemObjectInfo(buffer, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %d\n",ret_val); + + return 0; +} + +int test_buffer_object() +{ + int i; + for (i=0; i +#include "param_struct.h" +#include + +extern cl_command_queue command_queue; + +cl_int ret_val; + +const struct clRetainCommandQueue_st clRetainCommandQueueData[NUM_ITEMS_clRetainCommandQueue] = { + {NULL} +}; + +const struct clGetCommandQueueInfo_st clGetCommandQueueInfoData[NUM_ITEMS_clGetCommandQueueInfo] = { + {NULL, 0, 0, NULL, NULL} +}; + +int test_clRetainCommandQueue(const struct clRetainCommandQueue_st *data) +{ + test_icd_app_log("clRetainCommandQueue(%p)\n", command_queue); + + ret_val = clRetainCommandQueue(command_queue); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clGetCommandQueueInfo(const struct clGetCommandQueueInfo_st *data) +{ + test_icd_app_log("clGetCommandQueueInfo(%p, %u, %u, %p, %p)\n", + command_queue, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + ret_val = clGetCommandQueueInfo(command_queue, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_cl_runtime() +{ + int i; + + for (i=0; i +#include +#include +#include "param_struct.h" +#include + +extern cl_context context; +extern cl_mem buffer; +extern cl_command_queue command_queue; +extern cl_event event; +extern cl_context_properties context_properties[3]; +cl_int ret_val; +cl_mem ret_mem; + +struct clCreateFromGLBuffer_st clCreateFromGLBufferData[NUM_ITEMS_clCreateFromGLBuffer] = { + {NULL, 0x0, 0, NULL} +}; + +int test_clCreateFromGLBuffer(const struct clCreateFromGLBuffer_st* data) +{ + + test_icd_app_log("clCreateFromGLBuffer(%p, %x, %u, %p)\n", + context, + data->flags, + data->bufobj, + data->errcode_ret); + + ret_mem = clCreateFromGLBuffer(context, + data->flags, + data->bufobj, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", ret_mem); + + return 0; +} + +struct clCreateFromGLTexture_st clCreateFromGLTextureData[NUM_ITEMS_clCreateFromGLTexture] = { + {NULL, 0x0, 0, 0, 0, NULL} +}; + +int test_clCreateFromGLTexture(const struct clCreateFromGLTexture_st* data) +{ + test_icd_app_log("clCreateFromGLTexture(%p, %x, %d, %d, %u, %p)\n", + context, + data->flags, + data->texture_target, + data->miplevel, + data->texture, + data->errcode_ret); + + ret_mem = clCreateFromGLTexture(context, + data->flags, + data->texture_target, + data->miplevel, + data->texture, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", ret_mem); + + return 0; +} + +struct clCreateFromGLTexture2D_st clCreateFromGLTexture2DData[NUM_ITEMS_clCreateFromGLTexture2D] = { + {NULL, 0x0, 0, 0, 0, NULL} +}; + +int test_clCreateFromGLTexture2D(const struct clCreateFromGLTexture2D_st* data) +{ + test_icd_app_log("clCreateFromGLTexture2D(%p, %x, %d, %d, %u, %p)\n", + context, + data->flags, + data->texture_target, + data->miplevel, + data->texture, + data->errcode_ret); + + ret_mem = clCreateFromGLTexture2D(context, + data->flags, + data->texture_target, + data->miplevel, + data->texture, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", ret_mem); + + return 0; +} + +struct clCreateFromGLTexture3D_st clCreateFromGLTexture3DData[NUM_ITEMS_clCreateFromGLTexture3D] = { + {NULL, 0, 0, 0, 0, NULL} +}; + +int test_clCreateFromGLTexture3D(const struct clCreateFromGLTexture3D_st* data) +{ + test_icd_app_log("clCreateFromGLTexture3D(%p, %x, %d, %d, %u, %p)\n", + context, + data->flags, + data->texture_target, + data->miplevel, + data->texture, + data->errcode_ret); + + ret_mem = clCreateFromGLTexture3D(context, + data->flags, + data->texture_target, + data->miplevel, + data->texture, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", ret_mem); + + return 0; +} + +struct clCreateFromGLRenderbuffer_st clCreateFromGLRenderbufferData[NUM_ITEMS_clCreateFromGLRenderbuffer] = { + {NULL, 0x0, 0, NULL} +}; + +int test_clCreateFromGLRenderbuffer(const struct clCreateFromGLRenderbuffer_st* data) +{ + test_icd_app_log("clCreateFromGLRenderbuffer(%p, %x, %d, %p)\n", + context, + data->flags, + data->renderbuffer, + data->errcode_ret); + + ret_mem = clCreateFromGLRenderbuffer(context, + data->flags, + data->renderbuffer, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", ret_mem); + + return 0; +} + +struct clGetGLObjectInfo_st clGetGLObjectInfoData[NUM_ITEMS_clGetGLObjectInfo] = { + {NULL, NULL, NULL} +}; + +int test_clGetGLObjectInfo(const struct clGetGLObjectInfo_st* data) +{ + test_icd_app_log("clGetGLObjectInfo(%p, %p, %p)\n", + buffer, + data->gl_object_type, + data->gl_object_name); + + ret_val = clGetGLObjectInfo(buffer, + data->gl_object_type, + data->gl_object_name); + + test_icd_app_log("Value returned: %p\n", ret_val); + +} + +struct clGetGLTextureInfo_st clGetGLTextureInfoData[NUM_ITEMS_clGetGLTextureInfo] = { + {NULL, 0, 0, NULL, NULL} +}; + +int test_clGetGLTextureInfo(const struct clGetGLTextureInfo_st* data) +{ + test_icd_app_log("clGetGLTextureInfo(%p, %u, %u, %p, %p)\n", + buffer, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + ret_val = clGetGLTextureInfo (buffer, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %p\n", ret_val); + + return 0; +} + +struct clEnqueueAcquireGLObjects_st clEnqueueAcquireGLObjectsData[NUM_ITEMS_clEnqueueAcquireGLObjects] = { + {NULL, 0, NULL, 0, NULL, NULL} +}; + +int test_clEnqueueAcquireGLObjects(const struct clEnqueueAcquireGLObjects_st* data) +{ + test_icd_app_log("clEnqueueAcquireGLObjects(%p, %u, %p, %u, %p, %p)\n", + command_queue, + data->num_objects, + data->mem_objects, + data->num_events_in_wait_list, + &event, + &event); + + ret_val = clEnqueueAcquireGLObjects (command_queue, + data->num_objects, + data->mem_objects, + data->num_events_in_wait_list, + &event, + &event); + + test_icd_app_log("Value returned: %p\n", ret_val); + + return 0; +} + +struct clEnqueueReleaseGLObjects_st clEnqueueReleaseGLObjectsData[NUM_ITEMS_clEnqueueReleaseGLObjects] = { + {NULL, 0, NULL, 0, NULL, NULL} +}; + +int test_clEnqueueReleaseGLObjects(const struct clEnqueueReleaseGLObjects_st* data) +{ + test_icd_app_log("clEnqueueReleaseGLObjects(%p, %u, %p, %u, %p, %p)\n", + command_queue, + data->num_objects, + data->mem_objects, + data->num_events_in_wait_list, + &event, + &event); + + ret_val = clEnqueueReleaseGLObjects (command_queue, + data->num_objects, + data->mem_objects, + data->num_events_in_wait_list, + &event, + &event); + + + test_icd_app_log("Value returned: %p\n", ret_val); + + return 0; +} + +struct clCreateEventFromGLsyncKHR_st clCreateEventFromGLsyncKHRData[NUM_ITEMS_clCreateEventFromGLsyncKHR] = { + {NULL, NULL, NULL} +}; + +typedef CL_API_ENTRY cl_event +(CL_API_CALL *PFN_clCreateEventFromGLsyncKHR)(cl_context /* context */, + cl_GLsync /* cl_GLsync */, + cl_int * /* errcode_ret */); + +int test_clCreateEventFromGLsyncKHR(const struct clCreateEventFromGLsyncKHR_st* data) +{ cl_event ret_event; + PFN_clCreateEventFromGLsyncKHR pfn_clCreateEventFromGLsyncKHR = NULL; + + test_icd_app_log("clCreateEventFromGLsyncKHR(%p, %p, %p)\n", + context, + data->sync, + data->errcode_ret); + + pfn_clCreateEventFromGLsyncKHR = clGetExtensionFunctionAddress("clCreateEventFromGLsyncKHR"); + if (!pfn_clCreateEventFromGLsyncKHR) { + test_icd_app_log("clGetExtensionFunctionAddress failed!\n"); + return 1; + } + + ret_event = pfn_clCreateEventFromGLsyncKHR (context, + data->sync, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", ret_event); + return 0; +} + +struct clGetGLContextInfoKHR_st clGetGLContextInfoKHRData[NUM_ITEMS_clGetGLContextInfoKHR] = { + {NULL, 0, 0, NULL, NULL} +}; + +typedef CL_API_ENTRY cl_int +(CL_API_CALL *PFN_clGetGLContextInfoKHR)(const cl_context_properties * /* properties */, + cl_gl_context_info /* param_name */, + size_t /* param_value_size */, + void * /* param_value */, + size_t * /* param_value_size_ret */); + +int test_clGetGLContextInfoKHR(const struct clGetGLContextInfoKHR_st* data) +{ + PFN_clGetGLContextInfoKHR pfn_clGetGLContextInfoKHR = NULL; + test_icd_app_log("clGetGLContextInfoKHR(%p, %u, %u, %p, %p)\n", + context_properties, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + pfn_clGetGLContextInfoKHR = clGetExtensionFunctionAddress("clGetGLContextInfoKHR"); + if (!pfn_clGetGLContextInfoKHR) { + test_icd_app_log("clGetExtensionFunctionAddress failed!\n"); + return 1; + } + + ret_val = pfn_clGetGLContextInfoKHR(context_properties, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %p\n", ret_val); + return 0; + +} + +int test_OpenGL_share() +{ + int i; + + for(i=0;i + +#define CL_USE_DEPRECATED_OPENCL_1_0_APIS +#define CL_USE_DEPRECATED_OPENCL_1_1_APIS + +#include +#include "param_struct.h" +#include + +extern void CL_CALLBACK createcontext_callback(const char* a, const void* b, size_t c, void* d); + +cl_platform_id* all_platforms; +cl_platform_id platform; +cl_uint num_platforms; +cl_context context; +cl_command_queue command_queue; +cl_mem buffer; +cl_mem subBuffer; +cl_mem image; +cl_sampler sampler; +cl_program program; +cl_kernel kernel; +cl_event event; +cl_device_id devices; +cl_context_properties context_properties[3] = { + (cl_context_properties)CL_CONTEXT_PLATFORM, + 0, + 0, +}; + +const struct clGetDeviceIDs_st clGetDeviceIDsData[NUM_ITEMS_clGetDeviceIDs] = +{ + {NULL, 0, 1, NULL, NULL} +}; + +const struct clCreateSampler_st clCreateSamplerData[NUM_ITEMS_clCreateSampler] = +{ + {NULL, 0x0, 0, 0, NULL}, +}; + +const struct clCreateCommandQueue_st clCreateCommandQueueData[NUM_ITEMS_clCreateCommandQueue] = +{ + {NULL, NULL, 0, NULL} +}; + +const struct clCreateContext_st clCreateContextData[NUM_ITEMS_clCreateContext] = +{ + {NULL, 1, NULL, NULL, NULL, NULL} +}; + +const struct clCreateContextFromType_st clCreateContextFromTypeData[NUM_ITEMS_clCreateContextFromType] = +{ + {NULL, 0, createcontext_callback, NULL, NULL} +}; + +const struct clCreateBuffer_st clCreateBufferData[NUM_ITEMS_clCreateBuffer] = +{ + {NULL, 0, 0, NULL, NULL} +}; + +const struct clCreateSubBuffer_st clCreateSubBufferData[NUM_ITEMS_clCreateSubBuffer] = +{ + {NULL, 0, 0, NULL, NULL} +}; + +const struct clCreateImage_st clCreateImageData[NUM_ITEMS_clCreateImage] = +{ + { NULL, 0x0, NULL, NULL, NULL, NULL} +}; + +const struct clCreateImage2D_st clCreateImage2DData[NUM_ITEMS_clCreateImage2D] = +{ + { NULL, 0x0, NULL, 0, 0, 0, NULL, NULL} +}; + +const struct clCreateImage3D_st clCreateImage3DData[NUM_ITEMS_clCreateImage3D] = +{ + { NULL, 0x0, NULL, 0, 0, 0, 0, 0, NULL, NULL } +}; + + +struct clReleaseMemObject_st clReleaseMemObjectData[NUM_ITEMS_clReleaseMemObject] = +{ + {NULL} +}; + +struct clReleaseMemObject_st clReleaseMemObjectDataImage[NUM_ITEMS_clReleaseMemObject] = +{ + {NULL} +};const struct clCreateProgramWithSource_st clCreateProgramWithSourceData[NUM_ITEMS_clCreateProgramWithSource] = +{ + {NULL, 0, NULL, NULL, NULL} +}; + +const struct clCreateProgramWithBinary_st clCreateProgramWithBinaryData[NUM_ITEMS_clCreateProgramWithBinary] = +{ + {NULL, 0, NULL, NULL, NULL, NULL, NULL} +}; + +const struct clCreateProgramWithBuiltInKernels_st clCreateProgramWithBuiltInKernelsData[NUM_ITEMS_clCreateProgramWithBuiltInKernels] = +{ + {NULL, 0, NULL, NULL, NULL} +}; + +const struct clCreateKernel_st clCreateKernelData[NUM_ITEMS_clCreateKernel] = +{ + {NULL, NULL, NULL} +}; + +const struct clCreateKernelsInProgram_st clCreateKernelsInProgramData[NUM_ITEMS_clCreateKernelsInProgram] = +{ + {NULL, 0, NULL, NULL} +}; + +const struct clCreateUserEvent_st clCreateUserEventData[NUM_ITEMS_clCreateUserEvent] = +{ + {NULL, NULL} +}; + +const struct clGetPlatformIDs_st clGetPlatformIDsData[NUM_ITEMS_clGetPlatformIDs] = +{ + {0, NULL, 0} +}; + +/* + * Some log messages cause log mismatches when ICD loader calls a driver + * function while initializing platforms. The functions clGetPlatform* are most + * likely to be called at that time. But nothing stops an ICD loader from + * calling a ICD driver function anytime. + * + * FIXME: Figure out a good way to handle this. + */ +#define ENABLE_MISMATCHING_PRINTS 0 + +int test_clGetPlatformIDs(const struct clGetPlatformIDs_st* data) +{ + cl_int ret_val; + size_t param_val_ret_size; + #define PLATFORM_NAME_SIZE 40 + char platform_name[PLATFORM_NAME_SIZE]; + cl_uint i; + +#if ENABLE_MISMATCHING_PRINTS + test_icd_app_log("clGetPlatformIDs(%u, %p, %p)\n", + data->num_entries, + &platforms, + &num_platforms); +#endif + + ret_val = clGetPlatformIDs(0, + NULL, + &num_platforms); + + if (ret_val != CL_SUCCESS){ + return -1; + } + + all_platforms = (cl_platform_id *) malloc (num_platforms * sizeof(cl_platform_id)); + + ret_val = clGetPlatformIDs(num_platforms, + all_platforms, + NULL); + + if (ret_val != CL_SUCCESS){ + return -1; + } + + for (i = 0; i < num_platforms; i++) { + ret_val = clGetPlatformInfo(all_platforms[i], + CL_PLATFORM_NAME, + PLATFORM_NAME_SIZE, + (void*)platform_name, + ¶m_val_ret_size ); + + if (ret_val == CL_SUCCESS ){ + if(!strcmp(platform_name, "ICD_LOADER_TEST_OPENCL_STUB")) { + platform = all_platforms[i]; + } + } + } + +#if ENABLE_MISMATCHING_PRINTS + test_icd_app_log("Value returned: %d\n", ret_val); +#endif + + return 0; + +} + +int test_clGetDeviceIDs(const struct clGetDeviceIDs_st* data) +{ + int ret_val; + + test_icd_app_log("clGetDeviceIDs(%p, %x, %u, %p, %p)\n", + platform, + data->device_type, + data->num_entries, + &devices, + data->num_devices); + + ret_val = clGetDeviceIDs(platform, + data->device_type, + data->num_entries, + &devices, + data->num_devices); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clCreateContext(const struct clCreateContext_st* data) +{ + test_icd_app_log("clCreateContext(%p, %u, %p, %p, %p, %p)\n", + data->properties, + data->num_devices, + &devices, + &createcontext_callback, + data->user_data, + data->errcode_ret); + + context = clCreateContext(data->properties, + data->num_devices, + &devices, + &createcontext_callback, + data->user_data, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", context); + + return 0; + +} + +int test_clCreateContextFromType(const struct clCreateContextFromType_st* data) +{ + test_icd_app_log("clCreateContextFromType(%p, %x, %p, %p, %p)\n", + context_properties, + data->device_type, + data->pfn_notify, + data->user_data, + data->errcode_ret); + + + context = clCreateContextFromType(context_properties, + data->device_type, + data->pfn_notify, + data->user_data, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", context); + + return 0; + +} + +int test_clCreateCommandQueue(const struct clCreateCommandQueue_st *data) +{ + test_icd_app_log("clCreateCommandQueue(%p, %p, %x, %p)\n", + context, + devices, + data->properties, + data->errcode_ret); + + command_queue = clCreateCommandQueue(context, + devices, + data->properties, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", command_queue); + + return 0; + +} + +int test_clCreateBuffer(const struct clCreateBuffer_st *data) +{ + test_icd_app_log("clCreateBuffer(%p, %x, %u, %p, %p)\n", + context, + data->flags, + data->size, + data->host_ptr, + data->errcode_ret); + + buffer = clCreateBuffer(context, + data->flags, + data->size, + data->host_ptr, + data->errcode_ret); + + clReleaseMemObjectData->memobj = buffer; + + test_icd_app_log("Value returned: %p\n", buffer); + + return 0; + +} + +int test_clCreateSubBuffer(const struct clCreateSubBuffer_st *data) +{ + test_icd_app_log("clCreateSubBuffer(%p, %x, %u, %p, %p)\n", + buffer, + data->flags, + data->buffer_create_type, + data->buffer_create_info, + data->errcode_ret); + + subBuffer = clCreateSubBuffer(buffer, + data->flags, + data->buffer_create_type, + data->buffer_create_info, + data->errcode_ret); + + clReleaseMemObjectData->memobj = buffer; + + test_icd_app_log("Value returned: %p\n", subBuffer); + + return 0; + +} + +int test_clCreateImage(const struct clCreateImage_st *data) +{ + test_icd_app_log("clCreateImage(%p, %x, %p, %p, %p, %p)\n", + context, + data->flags, + data->image_format, + data->image_desc, + data->host_ptr, + data->errcode_ret); + + image = clCreateImage(context, + data->flags, + data->image_format, + data->image_desc, + data->host_ptr, + data->errcode_ret); + + clReleaseMemObjectDataImage[0].memobj = image; + test_icd_app_log("Value returned: %p\n", image); + + return 0; + +} + +int test_clCreateImage2D(const struct clCreateImage2D_st *data) +{ + test_icd_app_log("clCreateImage2D(%p, %x, %p, %u, %u, %u, %p, %p)\n", + context, + data->flags, + data->image_format, + data->image_width, + data->image_height, + data->image_row_pitch, + data->host_ptr, + data->errcode_ret); + + image = clCreateImage2D(context, + data->flags, + data->image_format, + data->image_width, + data->image_height, + data->image_row_pitch, + data->host_ptr, + data->errcode_ret); + + clReleaseMemObjectDataImage[0].memobj = image; + test_icd_app_log("Value returned: %p\n", image); + + return 0; + +} + +int test_clCreateImage3D(const struct clCreateImage3D_st *data) +{ + test_icd_app_log("clCreateImage3D(%p, %x, %p, %u, %u, %u, %u, %u, %p, %p)\n", + context, + data->flags, + data->image_format, + data->image_width, + data->image_height, + data->image_depth, + data->image_row_pitch, + data->image_slice_pitch, + data->host_ptr, + data->errcode_ret); + + image = clCreateImage3D(context, + data->flags, + data->image_format, + data->image_width, + data->image_height, + data->image_depth, + data->image_row_pitch, + data->image_slice_pitch, + data->host_ptr, + data->errcode_ret); + + clReleaseMemObjectDataImage[0].memobj = image; + test_icd_app_log("Value returned: %p\n", image); + + return 0; + +} + +int test_clCreateSampler(const struct clCreateSampler_st *data) +{ + test_icd_app_log("clCreateSampler(%p, %u, %u, %u, %p)\n", + context, + data->normalized_coords, + data->addressing_mode, + data->filter_mode, + data->errcode_ret); + + sampler = clCreateSampler(context, + data->normalized_coords, + data->addressing_mode, + data->filter_mode, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", sampler); + + return 0; + +} + +int test_clCreateProgramWithSource(const struct clCreateProgramWithSource_st *data) +{ + test_icd_app_log("clCreateProgramWithSource(%p, %u, %p, %p, %p)\n", + context, + data->count, + data->strings, + data->lengths, + data->errcode_ret); + + program = clCreateProgramWithSource(context, + data->count, + data->strings, + data->lengths, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", program); + + return 0; + +} + +int test_clCreateProgramWithBinary(const struct clCreateProgramWithBinary_st *data) +{ + test_icd_app_log("clCreateProgramWithBinary(%p, %u, %p, %p, %p, %p, %p)\n", + context, + data->num_devices, + &devices, + data->lengths, + data->binaries, + data->binary_status, + data->errcode_ret); + + program = clCreateProgramWithBinary(context, + data->num_devices, + &devices, + data->lengths, + data->binaries, + data->binary_status, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", program); + + return 0; + +} + +int test_clCreateProgramWithBuiltInKernels(const struct clCreateProgramWithBuiltInKernels_st *data) +{ + test_icd_app_log("clCreateProgramWithBuiltInKernels(%p, %u, %p, %p, %p)\n", + context, + data->num_devices, + &devices, + data->kernel_names, + data->errcode_ret); + + program = clCreateProgramWithBuiltInKernels(context, + data->num_devices, + &devices, + data->kernel_names, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", program); + + return 0; + +} + +int test_clCreateKernel(const struct clCreateKernel_st* data) +{ + test_icd_app_log("clCreateKernel(%p, %p, %p)\n", + program, + data->kernel_name, + data->errcode_ret); + + kernel = clCreateKernel(program, + data->kernel_name, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", kernel); + + return 0; + +} + +int test_clCreateKernelsInProgram(const struct clCreateKernelsInProgram_st* data) +{ + int ret_val; + test_icd_app_log("clCreateKernelsInProgram(%p, %u, %p, %p)\n", + program, + data->num_kernels, + &kernel, + data->num_kernels_ret); + + ret_val = clCreateKernelsInProgram(program, + data->num_kernels, + &kernel, + data->num_kernels_ret); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clCreateUserEvent(const struct clCreateUserEvent_st* data) +{ + test_icd_app_log("clCreateUserEvent(%p, %p)\n", + context, + data->errcode_ret); + + event = clCreateUserEvent(context, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", event); + + return 0; + +} + +const struct clReleaseSampler_st clReleaseSamplerData[NUM_ITEMS_clReleaseSampler] = +{ + { NULL } +}; + +int test_clReleaseSampler(const struct clReleaseSampler_st *data) +{ + int ret_val = CL_OUT_OF_RESOURCES; + + test_icd_app_log("clReleaseSampler(%p)\n", sampler); + + ret_val = clReleaseSampler(sampler); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + + +int test_clReleaseMemObject(const struct clReleaseMemObject_st *data) +{ + int ret_val = -15; + test_icd_app_log("clReleaseMemObject(%p)\n", data->memobj); + + ret_val = clReleaseMemObject(data->memobj); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +const struct clReleaseEvent_st clReleaseEventData[NUM_ITEMS_clReleaseEvent] = +{ + {NULL} +}; + +int test_clReleaseEvent(const struct clReleaseEvent_st* data) +{ + int ret_val = CL_OUT_OF_RESOURCES; + + test_icd_app_log("clReleaseEvent(%p)\n", event); + + ret_val = clReleaseEvent(event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +const struct clReleaseKernel_st clReleaseKernelData[NUM_ITEMS_clReleaseKernel] = +{ + {NULL} +}; + +int test_clReleaseKernel(const struct clReleaseKernel_st* data) +{ + int ret_val = CL_OUT_OF_RESOURCES; + + test_icd_app_log("clReleaseKernel(%p)\n", kernel); + + ret_val = clReleaseKernel(kernel); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +const struct clReleaseProgram_st clReleaseProgramData[NUM_ITEMS_clReleaseProgram] = +{ + {NULL} +}; + +int test_clReleaseProgram(const struct clReleaseProgram_st *data) +{ + int ret_val = CL_OUT_OF_RESOURCES; + + test_icd_app_log("clReleaseProgram(%p)\n", program); + + ret_val = clReleaseProgram(program); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +const struct clReleaseCommandQueue_st clReleaseCommandQueueData[NUM_ITEMS_clReleaseCommandQueue] = +{ + {NULL} +}; + +int test_clReleaseCommandQueue(const struct clReleaseCommandQueue_st *data) +{ + int ret_val = CL_OUT_OF_RESOURCES; + + test_icd_app_log("clReleaseCommandQueue(%p)\n", command_queue); + + ret_val = clReleaseCommandQueue(command_queue); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +const struct clReleaseContext_st clReleaseContextData[NUM_ITEMS_clReleaseContext] = +{ + {NULL} +}; + +int test_clReleaseContext(const struct clReleaseContext_st* data) +{ + int ret_val = CL_OUT_OF_RESOURCES; + + test_icd_app_log("clReleaseContext(%p)\n", context); + + ret_val = clReleaseContext(context); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +const struct clReleaseDevice_st clReleaseDeviceData[NUM_ITEMS_clReleaseDevice] = +{ + {NULL} +}; + +int test_clReleaseDevice(const struct clReleaseDevice_st* data) +{ + int ret_val = CL_OUT_OF_RESOURCES; + + test_icd_app_log("clReleaseDevice(%p)\n", devices); + + ret_val = clReleaseDevice(devices); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_create_calls() +{ + test_clGetPlatformIDs(clGetPlatformIDsData); + + context_properties[1] = (cl_context_properties) platform; + + test_clGetDeviceIDs(clGetDeviceIDsData); + + test_clCreateContext(clCreateContextData); + + test_clReleaseContext(clReleaseContextData); + + test_clCreateContextFromType(clCreateContextFromTypeData); + + test_clCreateCommandQueue(clCreateCommandQueueData); + + test_clCreateBuffer(clCreateBufferData); + + test_clCreateSubBuffer(clCreateSubBufferData); + + test_clCreateImage(clCreateImageData); + + test_clReleaseMemObject(clReleaseMemObjectDataImage); + + test_clCreateImage2D(clCreateImage2DData); + + test_clReleaseMemObject(clReleaseMemObjectDataImage); + + test_clCreateImage3D(clCreateImage3DData); + + test_clCreateSampler(clCreateSamplerData); + + test_clCreateProgramWithSource(clCreateProgramWithSourceData); + + test_clReleaseProgram(clReleaseProgramData); + + test_clCreateProgramWithBinary(clCreateProgramWithBinaryData); + + test_clReleaseProgram(clReleaseProgramData); + + test_clCreateProgramWithBuiltInKernels(clCreateProgramWithBuiltInKernelsData); + + test_clCreateKernel(clCreateKernelData); + + test_clCreateKernelsInProgram(clCreateKernelsInProgramData); + + test_clCreateUserEvent(clCreateUserEventData); + + return 0; + +} + +int test_release_calls() +{ + test_clReleaseSampler(clReleaseSamplerData); + + test_clReleaseMemObject(clReleaseMemObjectData); + + test_clReleaseMemObject(clReleaseMemObjectDataImage); + + test_clReleaseEvent(clReleaseEventData); + + test_clReleaseKernel(clReleaseKernelData); + + test_clReleaseProgram(clReleaseProgramData); + + test_clReleaseCommandQueue(clReleaseCommandQueueData); + + test_clReleaseContext(clReleaseContextData); + + test_clReleaseDevice(clReleaseDeviceData); + + return 0; +} + diff --git a/khronos_icd/test/loader_test/test_image_objects.c b/khronos_icd/test/loader_test/test_image_objects.c new file mode 100644 index 000000000..0c47d1300 --- /dev/null +++ b/khronos_icd/test/loader_test/test_image_objects.c @@ -0,0 +1,362 @@ +#include +#include "param_struct.h" +#include + +extern cl_mem image; +extern cl_context context; +extern cl_command_queue command_queue; +extern cl_event event; +extern cl_mem buffer; + +int ret_val; + +const struct clGetSupportedImageFormats_st clGetSupportedImageFormatsData[NUM_ITEMS_clGetSupportedImageFormats] = +{ + { NULL, 0x0, 0, 0, NULL, NULL } +}; + +const struct clEnqueueCopyImageToBuffer_st clEnqueueCopyImageToBufferData[NUM_ITEMS_clEnqueueCopyImageToBuffer] = +{ + { NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, NULL } +}; + +const struct clEnqueueCopyBufferToImage_st clEnqueueCopyBufferToImageData[NUM_ITEMS_clEnqueueCopyBufferToImage] = +{ + { NULL, NULL, NULL, 0, NULL, NULL, 0, NULL, NULL } +}; + +const struct clEnqueueMapImage_st clEnqueueMapImageData[NUM_ITEMS_clEnqueueMapImage] = +{ + { NULL, NULL, 0, 0x0, NULL, NULL, NULL, NULL,0, NULL, NULL} +}; + +const struct clEnqueueReadImage_st clEnqueueReadImageData[NUM_ITEMS_clEnqueueReadImage] = +{ + { NULL, NULL, 0, NULL, NULL, 0, 0, NULL, 0, NULL, NULL } +}; + +const struct clEnqueueWriteImage_st clEnqueueWriteImageData[NUM_ITEMS_clEnqueueWriteImage] = +{ + { NULL, NULL, 0, NULL, NULL, 0, 0, NULL, 0, NULL, NULL } +}; + +const struct clEnqueueFillImage_st clEnqueueFillImageData[NUM_ITEMS_clEnqueueFillImage] = +{ + { NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL } +}; + +const struct clEnqueueCopyImage_st clEnqueueCopyImageData[NUM_ITEMS_clEnqueueCopyImage] = +{ + { NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL } +}; + +const struct clGetImageInfo_st clGetImageInfoData[NUM_ITEMS_clGetImageInfo] = +{ + { NULL, 0, 0, NULL, NULL} +}; + +int test_clGetSupportedImageFormats(const struct clGetSupportedImageFormats_st *data) +{ + test_icd_app_log("clGetSupportedImageFormats(%p, %x, %u, %u, %p, %p)\n", + context, + data->flags, + data->image_type, + data->num_entries, + data->image_formats, + data->num_image_formats); + + ret_val = clGetSupportedImageFormats(context, + data->flags, + data->image_type, + data->num_entries, + data->image_formats, + data->num_image_formats); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clEnqueueCopyImageToBuffer(const struct clEnqueueCopyImageToBuffer_st *data) +{ + test_icd_app_log("clEnqueueCopyImageToBuffer(%p, %p, %p, %p, %p, %u, %u, %p, %p)\n", + command_queue, + image, + buffer, + data->src_origin, + data->region, + data->dst_offset, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val = clEnqueueCopyImageToBuffer(command_queue, + image, + buffer, + data->src_origin, + data->region, + data->dst_offset, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clEnqueueCopyBufferToImage(const struct clEnqueueCopyBufferToImage_st *data) +{ + test_icd_app_log("clEnqueueCopyBufferToImage(%p, %p, %p, %u, %p, %p, %u, %p, %p)\n", + command_queue, + buffer, + image, + data->src_offset, + data->dst_origin, + data->region, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val = clEnqueueCopyBufferToImage(command_queue, + buffer, + image, + data->src_offset, + data->dst_origin, + data->region, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clEnqueueMapImage(const struct clEnqueueMapImage_st *data) +{ + void *return_value; + test_icd_app_log("clEnqueueMapImage(%p, %p, %u, %x, %p, %p, %p, %p, %u, %p, %p, %p)\n", + command_queue, + image, + data->blocking_map, + data->map_flags, + data->origin, + data->region, + data->image_row_pitch, + data->image_slice_pitch, + data->num_events_in_wait_list, + data->event_wait_list, + &event, + data->errcode_ret); + + return_value = clEnqueueMapImage(command_queue, + image, + data->blocking_map, + data->map_flags, + data->origin, + data->region, + data->image_row_pitch, + data->image_slice_pitch, + data->num_events_in_wait_list, + data->event_wait_list, + &event, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", return_value); + + free(return_value); + + return 0; + +} + +int test_clEnqueueReadImage(const struct clEnqueueReadImage_st *data) +{ + test_icd_app_log("clEnqueueReadImage(%p, %p, %u, %p, %p, %u, %u, %p, %u, %p, %p)\n", + command_queue, + image, + data->blocking_read, + data->origin, + data->region, + data->row_pitch, + data->slice_pitch, + data->ptr, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val = clEnqueueReadImage(command_queue, + image, + data->blocking_read, + data->origin, + data->region, + data->row_pitch, + data->slice_pitch, + data->ptr, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clEnqueueWriteImage(const struct clEnqueueWriteImage_st *data) +{ + test_icd_app_log("clEnqueueWriteImage(%p, %p, %u, %p, %p, %u, %u, %p, %u, %p, %p)\n", + command_queue, + image, + data->blocking_write, + data->origin, + data->region, + data->input_row_pitch, + data->input_slice_pitch, + data->ptr, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val = clEnqueueWriteImage(command_queue, + image, + data->blocking_write, + data->origin, + data->region, + data->input_row_pitch, + data->input_slice_pitch, + data->ptr, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clEnqueueFillImage(const struct clEnqueueFillImage_st *data) +{ + test_icd_app_log("clEnqueueFillImage(%p, %p, %p, %p, %p, %u, %p, %p)\n", + command_queue, + image, + data->fill_color, + data->origin, + data->region, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val = clEnqueueFillImage(command_queue, + image, + data->fill_color, + data->origin, + data->region, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} +int test_clEnqueueCopyImage(const struct clEnqueueCopyImage_st *data) +{ + test_icd_app_log("clEnqueueCopyImage(%p, %p, %p, %p, %p, %p, %u, %p, %p)\n", + command_queue, + image, + image, + data->src_origin, + data->dst_origin, + data->region, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val = clEnqueueCopyImage(command_queue, + image, + image, + data->src_origin, + data->dst_origin, + data->region, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + + +int test_clGetImageInfo(const struct clGetImageInfo_st *data) +{ + test_icd_app_log("clGetImageInfo(%p, %u, %u, %p, %p)\n", + image, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + ret_val = clGetImageInfo(image, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_image_objects() +{ + int i; + + for (i = 0; i +#include "param_struct.h" +#include + +extern cl_kernel kernel; +extern cl_event event; +extern cl_context context; +extern cl_command_queue command_queue; +extern cl_device_id devices; +int ret_val; +extern void CL_CALLBACK setevent_callback(cl_event _a, cl_int _b, void* _c); +extern void CL_CALLBACK setprintf_callback(cl_context _a, cl_uint _b, char* _c, void* _d ); + +struct clRetainKernel_st clRetainKernelData[NUM_ITEMS_clRetainKernel] = +{ + {NULL} +}; + +int test_clRetainKernel(const struct clRetainKernel_st* data) +{ + test_icd_app_log("clRetainKernel(%p)\n", kernel); + + ret_val=clRetainKernel(kernel); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clSetKernelArg_st clSetKernelArgData[NUM_ITEMS_clSetKernelArg] = +{ + {NULL, 0, 0, NULL} +}; + +int test_clSetKernelArg(const struct clSetKernelArg_st* data) +{ + test_icd_app_log("clSetKernelArg(%p, %u, %u, %p)\n", + kernel, + data->arg_index, + data->arg_size, + data->arg_value); + + ret_val=clSetKernelArg(kernel, + data->arg_index, + data->arg_size, + data->arg_value); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clGetKernelInfo_st clGetKernelInfoData[NUM_ITEMS_clGetKernelInfo] = +{ + {NULL, 0, 0, NULL, NULL} +}; + +int test_clGetKernelInfo(const struct clGetKernelInfo_st* data) +{ + test_icd_app_log("clGetKernelInfo(%p, %u, %u, %p, %p)\n", + kernel, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + ret_val=clGetKernelInfo(kernel, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clGetKernelArgInfo_st clGetKernelArgInfoData[NUM_ITEMS_clGetKernelArgInfo] = +{ + {NULL, 0, 0, 0, NULL, NULL} +}; + +int test_clGetKernelArgInfo(const struct clGetKernelArgInfo_st* data) +{ + test_icd_app_log("clGetKernelArgInfo(%p, %u, %u, %u, %p, %p)\n", + kernel, + data->arg_indx, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + ret_val=clGetKernelArgInfo(kernel, + data->arg_indx, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clGetKernelWorkGroupInfo_st clGetKernelWorkGroupInfoData[NUM_ITEMS_clGetKernelWorkGroupInfo] = +{ + {NULL, NULL, 0, 0, NULL, NULL} +}; + +int test_clGetKernelWorkGroupInfo(const struct clGetKernelWorkGroupInfo_st* data) +{ + test_icd_app_log("clGetKernelWorkGroupInfo(%p, %p, %u, %u, %p, %p)\n", + kernel, + devices, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + ret_val=clGetKernelWorkGroupInfo(kernel, + devices, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clEnqueueMigrateMemObjects_st clEnqueueMigrateMemObjectsData[NUM_ITEMS_clEnqueueMigrateMemObjects] = +{ + {NULL, 0, NULL, 0x0, 0, NULL, NULL} +}; + +int test_clEnqueueMigrateMemObjects(const struct clEnqueueMigrateMemObjects_st* data) +{ + test_icd_app_log("clEnqueueMigrateMemObjects(%p, %u, %p, %x, %u, %p, %p)\n", + command_queue, + data->num_mem_objects, + data->mem_objects, + data->flags, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val=clEnqueueMigrateMemObjects(command_queue, + data->num_mem_objects, + data->mem_objects, + data->flags, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clEnqueueNDRangeKernel_st clEnqueueNDRangeKernelData[NUM_ITEMS_clEnqueueNDRangeKernel] = +{ + {NULL, NULL, 0, NULL, NULL, NULL, 0, NULL} +}; + +int test_clEnqueueNDRangeKernel(const struct clEnqueueNDRangeKernel_st* data) +{ + test_icd_app_log("clEnqueueNDRangeKernel(%p, %p, %u, %p, %p, %p, %u, %p, %p)\n", + command_queue, + kernel, + data->work_dim, + data->global_work_offset, + data->global_work_size, + data->local_work_size, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val=clEnqueueNDRangeKernel(command_queue, + kernel, + data->work_dim, + data->global_work_offset, + data->global_work_size, + data->local_work_size, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clEnqueueTask_st clEnqueueTaskData[NUM_ITEMS_clEnqueueTask] = +{ + {NULL, NULL, 0, NULL, NULL} +}; + +int test_clEnqueueTask(const struct clEnqueueTask_st* data) +{ + test_icd_app_log("clEnqueueTask(%p, %p, %u, %p, %p)\n", + command_queue, + kernel, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val=clEnqueueTask(command_queue, + kernel, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} +struct clEnqueueNativeKernel_st clEnqueueNativeKernelData[NUM_ITEMS_clEnqueueNativeKernel] = +{ + {NULL, NULL, NULL, 0, 0, NULL, NULL, 0, NULL, NULL} +}; + +int test_clEnqueueNativeKernel(const struct clEnqueueNativeKernel_st* data) { + test_icd_app_log("clEnqueueNativeKernel(%p, %p, %p, %u, %u, %p, %p, %u, %p, %p)\n", + command_queue, + data->user_func, + data->args, + data->cb_args, + data->num_mem_objects, + data->mem_list, + data->args_mem_loc, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val=clEnqueueNativeKernel(command_queue, + data->user_func, + data->args, + data->cb_args, + data->num_mem_objects, + data->mem_list, + data->args_mem_loc, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + return 0; +} + +struct clSetUserEventStatus_st clSetUserEventStatusData[NUM_ITEMS_clSetUserEventStatus] = +{ + {NULL, 0} +}; + +int test_clSetUserEventStatus(const struct clSetUserEventStatus_st* data) +{ + test_icd_app_log("clSetUserEventStatus(%p, %d)\n", + event, + data->execution_status); + + ret_val=clSetUserEventStatus(event, + data->execution_status); + + test_icd_app_log("Value returned: %d\n", ret_val); + return 0; +} + +struct clWaitForEvents_st clWaitForEventsData[NUM_ITEMS_clWaitForEvents] = +{ + {1, NULL} +}; + +int test_clWaitForEvents(const struct clWaitForEvents_st* data) +{ + test_icd_app_log("clWaitForEvents(%u, %p)\n", + data->num_events, + &event); + + ret_val=clWaitForEvents(data->num_events, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + return 0; +} + +struct clGetEventInfo_st clGetEventInfoData[NUM_ITEMS_clGetEventInfo] = +{ + {NULL, 0, 0, NULL, NULL} +}; + +int test_clGetEventInfo(const struct clGetEventInfo_st* data){ + test_icd_app_log("clGetEventInfo(%p, %u, %u, %p, %p)\n", + event, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + ret_val=clGetEventInfo(event, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clSetEventCallback_st clSetEventCallbackData[NUM_ITEMS_clSetEventCallback] = +{ + {NULL, 0, setevent_callback, NULL} +}; + +int test_clSetEventCallback(const struct clSetEventCallback_st* data) +{ + test_icd_app_log("clSetEventCallback(%p, %d, %p, %p)\n", + event, + data->command_exec_callback_type, + data->pfn_event_notify, + data->user_data); + + ret_val=clSetEventCallback(event, + data->command_exec_callback_type, + data->pfn_event_notify, + data->user_data); + + test_icd_app_log("Value returned: %d\n", ret_val); + return 0; +} + +struct clRetainEvent_st clRetainEventData[NUM_ITEMS_clRetainEvent] = +{ + {NULL} +}; + +int test_clRetainEvent(const struct clRetainEvent_st* data) +{ + test_icd_app_log("clRetainEvent(%p)\n", event); + + ret_val=clRetainEvent(event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clEnqueueMarker_st clEnqueueMarkerData[NUM_ITEMS_clEnqueueMarker] = +{ + {NULL, NULL} +}; + +int test_clEnqueueMarker(const struct clEnqueueMarker_st* data) +{ + test_icd_app_log("clEnqueueMarker(%p, %p)\n", command_queue, &event); + + ret_val = clEnqueueMarker(command_queue, &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clEnqueueMarkerWithWaitList_st clEnqueueMarkerWithWaitListData[NUM_ITEMS_clEnqueueMarkerWithWaitList] = +{ + {NULL, 0, NULL, NULL} +}; + +int test_clEnqueueMarkerWithWaitList(const struct clEnqueueMarkerWithWaitList_st* data) +{ + test_icd_app_log("clEnqueueMarkerWithWaitList(%p, %u, %p, %p)\n", + command_queue, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val=clEnqueueMarkerWithWaitList(command_queue, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clEnqueueBarrierWithWaitList_st clEnqueueBarrierWithWaitListData[NUM_ITEMS_clEnqueueBarrierWithWaitList] = +{ + {NULL, 0, NULL, NULL} +}; +int test_clEnqueueBarrierWithWaitList(const struct clEnqueueBarrierWithWaitList_st* data) +{ + test_icd_app_log("clEnqueueBarrierWithWaitList(%p, %u, %p, %p)\n", + command_queue, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val=clEnqueueBarrierWithWaitList(command_queue, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clEnqueueWaitForEvents_st clEnqueueWaitForEventsData[NUM_ITEMS_clEnqueueWaitForEvents] = +{ + {NULL, 0, NULL} +}; + +int test_clEnqueueWaitForEvents(const struct clEnqueueWaitForEvents_st* data) +{ + test_icd_app_log("clEnqueueWaitForEvents(%p, %u, %p)\n", + command_queue, + data->num_events, + data->event_list); + + ret_val = clEnqueueWaitForEvents(command_queue, + data->num_events, + data->event_list); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clEnqueueBarrier_st clEnqueueBarrierData[NUM_ITEMS_clEnqueueBarrier] = +{ + {NULL} +}; + +int test_clEnqueueBarrier(const struct clEnqueueBarrier_st* data) +{ + test_icd_app_log("clEnqueueBarrier(%p)\n", command_queue); + + ret_val = clEnqueueBarrier(command_queue); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} +struct clGetEventProfilingInfo_st clGetEventProfilingInfoData[NUM_ITEMS_clGetEventProfilingInfo] = +{ + {NULL, 0, 0, NULL, NULL} +}; + +int test_clGetEventProfilingInfo(const struct clGetEventProfilingInfo_st* data) +{ + test_icd_app_log("clGetEventProfilingInfo(%p, %u, %u, %p, %p)\n", + event, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + ret_val=clGetEventProfilingInfo(event, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clFlush_st clFlushData[NUM_ITEMS_clFlush] = +{ + {NULL} +}; + +int test_clFlush(const struct clFlush_st* data) +{ + test_icd_app_log("clFlush(%p)\n", command_queue); + + ret_val=clFlush(command_queue); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clFinish_st clFinishData[NUM_ITEMS_clFinish] = +{ + {NULL} +}; + +int test_clFinish(const struct clFinish_st* data) +{ + test_icd_app_log("clFinish(%p)\n", command_queue); + + ret_val=clFinish(command_queue); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +int test_kernel() +{ + int i; + + for (i=0; i +#include "param_struct.h" +#include + +extern cl_context context; + +extern cl_platform_id platform; + +extern cl_device_id devices; + +int ret_val; + +struct clRetainContext_st clRetainContextData[NUM_ITEMS_clRetainContext] = +{ + {NULL} +}; + +struct clGetContextInfo_st clGetContextInfoData[NUM_ITEMS_clGetContextInfo] = +{ + {NULL, 0, 0, NULL, NULL} +}; + + +struct clGetPlatformInfo_st clGetPlatformInfoData[NUM_ITEMS_clGetPlatformInfo] = +{ + {NULL, 0, 0, NULL, NULL} +}; + +struct clGetDeviceInfo_st clGetDeviceInfoData[NUM_ITEMS_clGetDeviceInfo] = +{ + {NULL, 0, 0, NULL, NULL} +}; + +struct clCreateSubDevices_st clCreateSubDevicesData[NUM_ITEMS_clCreateSubDevices] = +{ + {NULL, NULL, 0, NULL, NULL} +}; + + +struct clRetainDevice_st clRetainDeviceData[NUM_ITEMS_clRetainDevice] = +{ + {NULL} +}; + + +int test_clRetainContext(const struct clRetainContext_st* data) +{ + test_icd_app_log("clRetainContext(%p)\n", context); + + ret_val = clRetainContext(context); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + + + +int test_clGetContextInfo(const struct clGetContextInfo_st* data) +{ + test_icd_app_log("clGetContextInfo(%p, %u, %u, %p, %p)\n", + context, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + + ret_val = clGetContextInfo(context, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +int test_clGetPlatformInfo(const struct clGetPlatformInfo_st* data) +{ + test_icd_app_log("clGetPlatformInfo(%p, %u, %u, %p, %p)\n", + platform, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + ret_val = clGetPlatformInfo(platform, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clGetDeviceInfo(const struct clGetDeviceInfo_st* data) +{ + test_icd_app_log("clGetDeviceInfo(%p, %u, %u, %p, %p)\n", + devices, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + ret_val = clGetDeviceInfo(devices, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +int test_clCreateSubDevices(const struct clCreateSubDevices_st* data) +{ + test_icd_app_log("clCreateSubDevices(%p, %p, %u, %p, %p)\n", + devices, + data->properties, + data->num_entries, + &devices, + data->num_devices); + + ret_val = clCreateSubDevices(devices, + data->properties, + data->num_entries, + &devices, + data->num_devices); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +int test_clRetainDevice(const struct clRetainDevice_st* data) +{ + test_icd_app_log("clRetainDevice(%p)\n", devices); + + ret_val = clRetainDevice(devices); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +int test_platforms() +{ + int i; + + for (i = 0;i +#include "param_struct.h" +#include + +extern cl_context context; +extern cl_program program; +extern cl_platform_id platform; +extern cl_device_id devices; + +int ret_val; + +extern void CL_CALLBACK program_callback(cl_program _a, void* _b); + +const struct clRetainProgram_st clRetainProgramData[NUM_ITEMS_clRetainProgram]= +{ + {NULL} +}; + +const struct clBuildProgram_st clBuildProgramData[NUM_ITEMS_clBuildProgram]= +{ + {NULL,0,NULL,NULL,program_callback,NULL} +}; + +const struct clCompileProgram_st clCompileProgramData[NUM_ITEMS_clCompileProgram]= +{ + {NULL,0,NULL,NULL,0,NULL,NULL,program_callback,NULL} +}; + +const struct clLinkProgram_st clLinkProgramData[NUM_ITEMS_clLinkProgram]= +{ + {NULL,0,NULL,NULL,0,NULL,program_callback,NULL,NULL} +}; + +const struct clUnloadPlatformCompiler_st clUnloadPlatformCompilerData[NUM_ITEMS_clUnloadPlatformCompiler]= +{ + {NULL} +}; + +const struct clGetExtensionFunctionAddressForPlatform_st clGetExtensionFunctionAddressForPlatformData[NUM_ITEMS_clGetExtensionFunctionAddressForPlatform]= +{ + {NULL, ""} +}; + +const struct clGetProgramInfo_st clGetProgramInfoData[NUM_ITEMS_clGetProgramInfo]= +{ + {NULL,0,0,NULL,NULL} +}; + +const struct clGetProgramBuildInfo_st clGetProgramBuildInfoData[NUM_ITEMS_clGetProgramBuildInfo]= +{ + {NULL,NULL,0,0,NULL,NULL} +}; + +int test_clRetainProgram(const struct clRetainProgram_st *data) +{ + test_icd_app_log("clRetainProgram(%p)\n", + program); + + ret_val=clRetainProgram(program); + + test_icd_app_log("Value returned: %d\n", + ret_val); + + return 0; + +} + +int test_clBuildProgram(const struct clBuildProgram_st *data) +{ + test_icd_app_log("clBuildProgram(%p, %u, %p, %p, %p, %p)\n", + program, + data->num_devices, + &devices, + data->options, + data->pfn_notify, + data->user_data); + + ret_val=clBuildProgram(program, + data->num_devices, + &devices, + data->options, + data->pfn_notify, + data->user_data); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clCompileProgram(const struct clCompileProgram_st *data) +{ + test_icd_app_log("clCompileProgram(%p, %u, %p, %p, %u, %p, %p, %p)\n", + program, + data->num_devices, + &devices, + data->options, + data->num_input_headers, + data->header_include_names, + data->pfn_notify, + data->user_data); + + ret_val=clCompileProgram(program, + data->num_devices, + &devices, + data->options, + data->num_input_headers, + data->headers, + data->header_include_names, + data->pfn_notify, + data->user_data); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clLinkProgram(const struct clLinkProgram_st *data) +{ + cl_program program; + test_icd_app_log("clLinkProgram(%p, %u, %p, %p, %u, %p, %p, %p, %p)\n", + context, + data->num_devices, + data->device_list, + data->options, + data->num_input_programs, + data->input_programs, + data->pfn_notify, + data->user_data, + data->errcode_ret); + + program=clLinkProgram(context, + data->num_devices, + data->device_list, + data->options, + data->num_input_programs, + data->input_programs, + data->pfn_notify, + data->user_data, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", program); + + return 0; + +} + +int test_clUnloadPlatformCompiler(const struct clUnloadPlatformCompiler_st *data) +{ + test_icd_app_log("clUnloadPlatformCompiler(%p)\n", platform); + + ret_val=clUnloadPlatformCompiler(platform); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clGetExtensionFunctionAddressForPlatform(const struct clGetExtensionFunctionAddressForPlatform_st *data) +{ + void *return_value; + test_icd_app_log("clGetExtensionFunctionAddressForPlatform(%p, %p)\n", + platform, + data->func_name); + + return_value=clGetExtensionFunctionAddressForPlatform(platform, + data->func_name); + + test_icd_app_log("Value returned: %p\n", return_value); + + return 0; + +} + +int test_clGetProgramInfo(const struct clGetProgramInfo_st *data) +{ + test_icd_app_log("clGetProgramInfo(%p, %u, %u, %p, %p)\n", + program, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + ret_val=clGetProgramInfo(program, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clGetProgramBuildInfo(const struct clGetProgramBuildInfo_st *data) +{ + test_icd_app_log("clGetProgramBuildInfo(%p, %p, %u, %u, %p, %p)\n", + program, + data->device, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + ret_val=clGetProgramBuildInfo(program, + data->device, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_program_objects() +{ + int i; + + for (i=0;i +#include "param_struct.h" +#include + +extern cl_sampler sampler; +int ret_val; + +const struct clRetainSampler_st clRetainSamplerData[NUM_ITEMS_clRetainSampler]= +{ + { NULL } +}; + +const struct clGetSamplerInfo_st clGetSamplerInfoData[NUM_ITEMS_clGetSamplerInfo]= +{ + { NULL, 0, 0, NULL, NULL } +}; + + +int test_clRetainSampler(const struct clRetainSampler_st *data) +{ + test_icd_app_log("clRetainSampler(%p)\n", sampler); + + ret_val=clRetainSampler(sampler); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +int test_clGetSamplerInfo(const struct clGetSamplerInfo_st *data) +{ + test_icd_app_log("clGetSamplerInfo(%p, %u, %u, %p, %p)\n", + sampler, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + ret_val=clGetSamplerInfo(sampler, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +int test_sampler_objects() +{ + int i; + + for (i=0;i +#include +#include +#include +#include +#include + +#define APP_LOG_FILE "icd_test_app_log.txt" +#define STUB_LOG_FILE "icd_test_stub_log.txt" + +static FILE *app_log_file; +static FILE *stub_log_file; + +int test_icd_initialize_app_log(void) +{ + app_log_file = fopen(APP_LOG_FILE, "w"); + if (!app_log_file) { + printf("Unable to open file %s\n", APP_LOG_FILE); + return -1; + } +} + +void test_icd_close_app_log(void) +{ + fclose(app_log_file); +} + +void test_icd_app_log(const char *format, ...) +{ + va_list args; + va_start(args, format); + vfprintf(app_log_file, format, args); + va_end(args); +} + +int test_icd_initialize_stub_log(void) +{ + stub_log_file = fopen(STUB_LOG_FILE, "w"); + if (!stub_log_file) { + printf("Unable to open file %s\n", STUB_LOG_FILE); + return -1; + } +} + +void test_icd_close_stub_log(void) +{ + fclose(stub_log_file); +} + +void test_icd_stub_log(const char *format, ...) +{ + va_list args; + va_start(args, format); + vfprintf(stub_log_file, format, args); + va_end(args); +} + +static char *test_icd_get_log(const char *filename) +{ + struct stat statbuf; + FILE *fp; + char *source = NULL; + + fp = fopen(filename, "rb"); + + if (fp) { + size_t fsize = 0; + stat(filename, &statbuf); + fsize = statbuf.st_size; + source = (char *)malloc(fsize+1); // +1 for NULL terminator + if (source) { + if (fsize) { + if (fread(source, fsize, 1, fp) != 1) { + free(source); + source = NULL; + } else { + source[fsize] = '\0'; + } + } else { + // Don't fail when fsize = 0, just return empty string + source[fsize] = '\0'; + } + } + fclose(fp); + } + + return source; +} + +char *test_icd_get_app_log(void) +{ + return test_icd_get_log(APP_LOG_FILE); +} + +char *test_icd_get_stub_log(void) +{ + return test_icd_get_log(STUB_LOG_FILE); +} From c50f58e0a9174659b10ed5e769d5d9bcbbcc4899 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Tue, 14 Jul 2015 17:35:32 +0200 Subject: [PATCH 06/62] Make ICD compile with our out of source build --- khronos_icd/CMakeLists.txt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/khronos_icd/CMakeLists.txt b/khronos_icd/CMakeLists.txt index b0cbe58a3..f746d0759 100644 --- a/khronos_icd/CMakeLists.txt +++ b/khronos_icd/CMakeLists.txt @@ -1,9 +1,12 @@ cmake_minimum_required (VERSION 2.6) +cmake_policy(SET CMP0015 NEW) +set(CMAKE_AUTOMOC OFF) -project (OPENCL_ICD_LOADER) +aux_source_directory(. SRC_LIST) + +include_directories(BEFORE ..) -set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/bin) -set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/bin) +project (OPENCL_ICD_LOADER) set (OPENCL_ICD_LOADER_SOURCES icd.c icd_dispatch.c) @@ -22,7 +25,7 @@ add_library (OpenCL SHARED ${OPENCL_ICD_LOADER_SOURCES}) set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1") if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") - set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,../icd_exports.map") + set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,../../khronos_icd/icd_exports.map") endif () target_link_libraries (OpenCL ${CMAKE_DL_LIBS}) From 6eb214666edd527ad6aeacc8d2732422a2ecb994 Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Mon, 13 Jul 2015 17:37:16 +0200 Subject: [PATCH 07/62] message serialization --- libwhisper/WhisperDB.cpp | 51 +++++++++++++++++++++++++++++ libwhisper/WhisperDB.h | 3 ++ libwhisper/WhisperHost.cpp | 66 +++++++++++++++++++++++++++++++++++++- libwhisper/WhisperHost.h | 2 ++ 4 files changed, 121 insertions(+), 1 deletion(-) diff --git a/libwhisper/WhisperDB.cpp b/libwhisper/WhisperDB.cpp index fd2eef060..58b43ad4a 100644 --- a/libwhisper/WhisperDB.cpp +++ b/libwhisper/WhisperDB.cpp @@ -60,6 +60,15 @@ void WhisperDB::insert(dev::h256 const& _key, string const& _value) BOOST_THROW_EXCEPTION(FailedInsertInLevelDB(status.ToString())); } +void WhisperDB::insert(dev::h256 const& _key, bytes const& _value) +{ + leveldb::Slice k((char const*)_key.data(), _key.size); + leveldb::Slice v((char const*)_value.data(), _value.size()); + leveldb::Status status = m_db->Put(m_writeOptions, k, v); + if (!status.ok()) + BOOST_THROW_EXCEPTION(FailedInsertInLevelDB(status.ToString())); +} + void WhisperDB::kill(dev::h256 const& _key) { leveldb::Slice slice((char const*)_key.data(), _key.size); @@ -67,3 +76,45 @@ void WhisperDB::kill(dev::h256 const& _key) if (!status.ok()) BOOST_THROW_EXCEPTION(FailedDeleteInLevelDB(status.ToString())); } + +void WhisperDB::loadAll(std::map& o_dst) +{ + leveldb::ReadOptions op; + op.fill_cache = false; + op.verify_checksums = true; + vector wasted; + unsigned now = (unsigned)time(0); + leveldb::Iterator* it = m_db->NewIterator(op); + + for (it->SeekToFirst(); it->Valid(); it->Next()) + { + leveldb::Slice const k = it->key(); + leveldb::Slice const v = it->value(); + + bool useless = false; + RLP rlp((byte const*)v.data(), v.size()); + Envelope e(rlp); + h256 h2 = e.sha3(); + h256 h1; + + if (k.size() == h256::size) + h1 = h256((byte const*)k.data(), h256::ConstructFromPointer); + + if (h1 != h2) + { + useless = true; + cwarn << "Corrupted data in Level DB:" << h1.hex() << "versus" << h2.hex(); + } + else if (e.expiry() <= now) + useless = true; + + if (useless) + wasted.push_back(k); + else + o_dst[h1] = e; + } + + leveldb::WriteOptions woptions; + for (auto k: wasted) + m_db->Delete(woptions, k); +} diff --git a/libwhisper/WhisperDB.h b/libwhisper/WhisperDB.h index 0cb97e244..5079dfeb4 100644 --- a/libwhisper/WhisperDB.h +++ b/libwhisper/WhisperDB.h @@ -24,6 +24,7 @@ #include #include #include "Common.h" +#include "Message.h" namespace dev { @@ -43,7 +44,9 @@ class WhisperDB std::string lookup(dev::h256 const& _key) const; void insert(dev::h256 const& _key, std::string const& _value); + void insert(dev::h256 const& _key, bytes const& _value); void kill(dev::h256 const& _key); + void loadAll(std::map& o_dst); private: leveldb::ReadOptions m_readOptions; diff --git a/libwhisper/WhisperHost.cpp b/libwhisper/WhisperHost.cpp index 5d83dd399..0202fcc24 100644 --- a/libwhisper/WhisperHost.cpp +++ b/libwhisper/WhisperHost.cpp @@ -20,10 +20,11 @@ */ #include "WhisperHost.h" - #include #include #include +#include "WhisperDB.h" + using namespace std; using namespace dev; using namespace dev::p2p; @@ -31,10 +32,12 @@ using namespace dev::shh; WhisperHost::WhisperHost(): Worker("shh") { + loadMessagesFromBD(); } WhisperHost::~WhisperHost() { + saveMessagesToBD(); } void WhisperHost::streamMessage(h256 _m, RLPStream& _s) const @@ -200,3 +203,64 @@ void WhisperHost::noteAdvertiseTopicsOfInterest() for (auto i: peerSessions()) i.first->cap().get()->noteAdvertiseTopicsOfInterest(); } + +void WhisperHost::saveMessagesToBD() +{ + try + { + WhisperDB db; + ReadGuard g(x_messages); + for (auto const& m: m_messages) + { + RLPStream rlp; + m.second.streamRLP(rlp); + bytes b; + rlp.swapOut(b); + db.insert(m.first, b); + } + } + catch(FailedToOpenLevelDB const& ex) + { + cwarn << "Exception in WhisperHost::saveMessagesToBD() - failed to open DB:" << ex.what(); + } + catch(FailedInsertInLevelDB const& ex) + { + cwarn << "Exception in WhisperHost::saveMessagesToBD() - failed to insert:" << ex.what(); + } + catch(FailedLookupInLevelDB const& ex) + { + cwarn << "Exception in WhisperHost::saveMessagesToBD() - failed lookup:" << ex.what(); + } + catch(FailedDeleteInLevelDB const& ex) + { + cwarn << "Exception in WhisperHost::saveMessagesToBD() - failed to delete:" << ex.what(); + } + catch(Exception const& ex) + { + cwarn << "Exception in WhisperHost::saveMessagesToBD():" << ex.what(); + } + catch(...) + { + cwarn << "Unknown Exception in WhisperHost::saveMessagesToBD()"; + } +} + +void WhisperHost::loadMessagesFromBD() +{ + try + { + map m; + WhisperDB db; + db.loadAll(m); + WriteGuard g(x_messages); + m_messages.swap(m); + } + catch(Exception const& ex) + { + cwarn << "Exception in WhisperHost::loadMessagesFromBD():" << ex.what(); + } + catch(...) + { + cwarn << "Unknown Exception in WhisperHost::loadMessagesFromBD()"; + } +} diff --git a/libwhisper/WhisperHost.h b/libwhisper/WhisperHost.h index fc1bcb557..a2ca28deb 100644 --- a/libwhisper/WhisperHost.h +++ b/libwhisper/WhisperHost.h @@ -74,6 +74,8 @@ private: virtual void onStarting() override { startWorking(); } virtual void onStopping() override { stopWorking(); } void streamMessage(h256 _m, RLPStream& _s) const; + void saveMessagesToBD(); + void loadMessagesFromBD(); mutable dev::SharedMutex x_messages; std::map m_messages; From 182ebe5658c1b5e4d312a7bbd76b44f86c1032e5 Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Tue, 14 Jul 2015 00:11:37 +0200 Subject: [PATCH 08/62] test added --- libwhisper/WhisperDB.cpp | 2 ++ test/libwhisper/whisperDB.cpp | 54 +++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/libwhisper/WhisperDB.cpp b/libwhisper/WhisperDB.cpp index 58b43ad4a..43d775a96 100644 --- a/libwhisper/WhisperDB.cpp +++ b/libwhisper/WhisperDB.cpp @@ -114,6 +114,8 @@ void WhisperDB::loadAll(std::map& o_dst) o_dst[h1] = e; } + delete it; + leveldb::WriteOptions woptions; for (auto k: wasted) m_db->Delete(woptions, k); diff --git a/test/libwhisper/whisperDB.cpp b/test/libwhisper/whisperDB.cpp index 552820621..410420c24 100644 --- a/test/libwhisper/whisperDB.cpp +++ b/test/libwhisper/whisperDB.cpp @@ -21,7 +21,9 @@ along with cpp-ethereum. If not, see . #include #include +#include #include +#include using namespace std; using namespace dev; @@ -119,4 +121,56 @@ BOOST_AUTO_TEST_CASE(persistence) } } +BOOST_AUTO_TEST_CASE(messages) +{ + cnote << "Testing load/save Whisper messages..."; + const unsigned TestSize = 3; + map m1; + map preexisting; + KeyPair us = KeyPair::create(); + + { + p2p::Host h("Test"); + auto wh = h.registerCapability(new WhisperHost()); + preexisting = wh->all(); + cnote << preexisting.size() << "preexisting messages in DB"; + + for (int i = 0; i < TestSize; ++i) + wh->post(us.sec(), RLPStream().append(i).out(), BuildTopic("test"), 0xFFFFF); + + m1 = wh->all(); + } + + { + p2p::Host h("Test"); + auto wh = h.registerCapability(new WhisperHost()); + map m2 = wh->all(); + BOOST_REQUIRE_EQUAL(m1.size(), m2.size()); + BOOST_REQUIRE_EQUAL(m1.size() - preexisting.size(), TestSize); + + for (auto i: m1) + { + RLPStream rlp1; + RLPStream rlp2; + i.second.streamRLP(rlp1); + m2[i.first].streamRLP(rlp2); + BOOST_REQUIRE_EQUAL(rlp1.out().size(), rlp2.out().size()); + for (unsigned j = 0; j < rlp1.out().size(); ++j) + BOOST_REQUIRE_EQUAL(rlp1.out()[j], rlp2.out()[j]); + } + } + + WhisperDB db; + unsigned x = 0; + + for (auto i: m1) + if (preexisting.find(i.first) == preexisting.end()) + { + db.kill(i.first); + ++x; + } + + BOOST_REQUIRE_EQUAL(x, TestSize); +} + BOOST_AUTO_TEST_SUITE_END() From 89dfa35f9e948da9de2db20dd480469c1e80e9d9 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Wed, 15 Jul 2015 10:43:14 +0200 Subject: [PATCH 09/62] Link to Khronos ICD instead of OpenCL --- exp/CMakeLists.txt | 2 +- khronos_icd/CMakeLists.txt | 8 ++++---- libethash-cl/CMakeLists.txt | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/exp/CMakeLists.txt b/exp/CMakeLists.txt index e6360317f..be7cec3d9 100644 --- a/exp/CMakeLists.txt +++ b/exp/CMakeLists.txt @@ -30,6 +30,6 @@ target_link_libraries(${EXECUTABLE} p2p) if (ETHASHCL) target_link_libraries(${EXECUTABLE} ethash-cl) target_link_libraries(${EXECUTABLE} ethash) - target_link_libraries(${EXECUTABLE} ${OpenCL_LIBRARIES}) + target_link_libraries(${EXECUTABLE} OpenCL_ICD) endif() install( TARGETS ${EXECUTABLE} DESTINATION bin) diff --git a/khronos_icd/CMakeLists.txt b/khronos_icd/CMakeLists.txt index f746d0759..9fc7ad2cd 100644 --- a/khronos_icd/CMakeLists.txt +++ b/khronos_icd/CMakeLists.txt @@ -21,14 +21,14 @@ endif () # OR copy OpenCL headers to ./inc/CL/ include_directories (./inc) -add_library (OpenCL SHARED ${OPENCL_ICD_LOADER_SOURCES}) -set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1") +add_library (OpenCL_ICD SHARED ${OPENCL_ICD_LOADER_SOURCES}) +set_target_properties (OpenCL_ICD PROPERTIES VERSION "1.2" SOVERSION "1") if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") - set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,../../khronos_icd/icd_exports.map") + set_target_properties (OpenCL_ICD PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,../../khronos_icd/icd_exports.map") endif () -target_link_libraries (OpenCL ${CMAKE_DL_LIBS}) +target_link_libraries (OpenCL_ICD ${CMAKE_DL_LIBS}) enable_testing() add_subdirectory (test) diff --git a/libethash-cl/CMakeLists.txt b/libethash-cl/CMakeLists.txt index 9dc45fcf5..8fa7c97f3 100644 --- a/libethash-cl/CMakeLists.txt +++ b/libethash-cl/CMakeLists.txt @@ -24,7 +24,7 @@ include_directories(${Boost_INCLUDE_DIRS}) include_directories(${OpenCL_INCLUDE_DIRS}) include_directories(..) add_library(${EXECUTABLE} ${SRC_LIST} ${HEADERS}) -TARGET_LINK_LIBRARIES(${EXECUTABLE} ${OpenCL_LIBRARIES} ethash) +TARGET_LINK_LIBRARIES(${EXECUTABLE} OpenCL_ICD ethash) install( TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib ) install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} ) From abe869600b7653afb5346ea49ca2bf8620d5411b Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Wed, 15 Jul 2015 10:49:38 +0200 Subject: [PATCH 10/62] Query Platforms checks for special not found value This value is provided by the Khronos ICD --- libethash-cl/ethash_cl_miner.cpp | 62 +++++++++++++++----------------- 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/libethash-cl/ethash_cl_miner.cpp b/libethash-cl/ethash_cl_miner.cpp index 942819ba8..dc806be1b 100644 --- a/libethash-cl/ethash_cl_miner.cpp +++ b/libethash-cl/ethash_cl_miner.cpp @@ -78,16 +78,30 @@ ethash_cl_miner::~ethash_cl_miner() finish(); } +// Quite ugly. Saves us a lot of typing on these static functions +// since we can't keep the platforms vector in the class (static class/functions) +// +// LTODO: With a bit of general refactoring this could go away and platforms +// be queried only once and kept in the class. +#define ETHASHCL_GET_PLATFORMS(platforms_, failStmt_) \ + do { \ + try \ + { \ + cl::Platform::get(&platforms_); \ + } \ + catch (cl::Error const& err) \ + { \ + int errCode = err.err(); \ + if (errCode == CL_PLATFORM_NOT_FOUND_KHR) \ + ETHCL_LOG("No OpenCL platforms found"); \ + failStmt_; \ + } \ + } while(0) + string ethash_cl_miner::platform_info(unsigned _platformId, unsigned _deviceId) { vector platforms; - cl::Platform::get(&platforms); - if (platforms.empty()) - { - ETHCL_LOG("No OpenCL platforms found."); - return string(); - } - + ETHASHCL_GET_PLATFORMS(platforms, return string()); // get GPU device of the selected platform unsigned platform_num = min(_platformId, platforms.size() - 1); vector devices = getDevices(platforms, _platformId); @@ -119,19 +133,14 @@ std::vector ethash_cl_miner::getDevices(std::vector co unsigned ethash_cl_miner::getNumPlatforms() { vector platforms; - cl::Platform::get(&platforms); + ETHASHCL_GET_PLATFORMS(platforms, return 0); return platforms.size(); } unsigned ethash_cl_miner::getNumDevices(unsigned _platformId) { vector platforms; - cl::Platform::get(&platforms); - if (platforms.empty()) - { - ETHCL_LOG("No OpenCL platforms found."); - return 0; - } + ETHASHCL_GET_PLATFORMS(platforms, return 0); vector devices = getDevices(platforms, _platformId); if (devices.empty()) @@ -192,12 +201,7 @@ unsigned ethash_cl_miner::s_initialGlobalWorkSize = ethash_cl_miner::c_defaultGl bool ethash_cl_miner::searchForAllDevices(function _callback) { vector platforms; - cl::Platform::get(&platforms); - if (platforms.empty()) - { - ETHCL_LOG("No OpenCL platforms found."); - return false; - } + ETHASHCL_GET_PLATFORMS(platforms, return false); for (unsigned i = 0; i < platforms.size(); ++i) if (searchForAllDevices(i, _callback)) return true; @@ -208,7 +212,7 @@ bool ethash_cl_miner::searchForAllDevices(function _cal bool ethash_cl_miner::searchForAllDevices(unsigned _platformId, function _callback) { vector platforms; - cl::Platform::get(&platforms); + ETHASHCL_GET_PLATFORMS(platforms, return false); if (_platformId >= platforms.size()) return false; @@ -223,12 +227,7 @@ bool ethash_cl_miner::searchForAllDevices(unsigned _platformId, function _callback) { vector platforms; - cl::Platform::get(&platforms); - if (platforms.empty()) - { - ETHCL_LOG("No OpenCL platforms found."); - return; - } + ETHASHCL_GET_PLATFORMS(platforms, return); for (unsigned i = 0; i < platforms.size(); ++i) doForAllDevices(i, _callback); } @@ -236,7 +235,7 @@ void ethash_cl_miner::doForAllDevices(function _callbac void ethash_cl_miner::doForAllDevices(unsigned _platformId, function _callback) { vector platforms; - cl::Platform::get(&platforms); + ETHASHCL_GET_PLATFORMS(platforms, return); if (_platformId >= platforms.size()) return; @@ -275,12 +274,7 @@ bool ethash_cl_miner::init( try { vector platforms; - cl::Platform::get(&platforms); - if (platforms.empty()) - { - ETHCL_LOG("No OpenCL platforms found."); - return false; - } + ETHASHCL_GET_PLATFORMS(platforms, return false); // use selected platform _platformId = min(_platformId, platforms.size() - 1); From 297dca32b5862af0c068d81f3990cd185f75037f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Wed, 15 Jul 2015 12:43:19 +0200 Subject: [PATCH 11/62] cmake install changes --- cmake/EthExecutableHelper.cmake | 6 ++++++ cmake/scripts/copydlls.cmake | 6 +++--- eth/CMakeLists.txt | 6 +++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/cmake/EthExecutableHelper.cmake b/cmake/EthExecutableHelper.cmake index 1d1cb887b..ed18623c0 100644 --- a/cmake/EthExecutableHelper.cmake +++ b/cmake/EthExecutableHelper.cmake @@ -139,6 +139,12 @@ macro(eth_install_executable EXECUTABLE) COMPONENT ${EXECUTABLE} ) + install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo/" + DESTINATION bin + CONFIGURATIONS RelWithDebInfo + COMPONENT ${EXECUTABLE} + ) + else() install( TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin) endif () diff --git a/cmake/scripts/copydlls.cmake b/cmake/scripts/copydlls.cmake index 6d86b8e4e..3bc1242f3 100644 --- a/cmake/scripts/copydlls.cmake +++ b/cmake/scripts/copydlls.cmake @@ -8,10 +8,10 @@ # this script is created cause we do not know configuration in multiconfiguration generators at cmake configure phase ;) -if ("${CONF}" STREQUAL "Release") - set(DLL ${DLL_RELEASE}) -else () # Debug +if ("${CONF}" STREQUAL "Debug") set(DLL ${DLL_DEBUG}) +else () + set(DLL ${DLL_RELEASE}) endif() execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${DLL}" "${DESTINATION}") diff --git a/eth/CMakeLists.txt b/eth/CMakeLists.txt index d317be28a..56c0ad710 100644 --- a/eth/CMakeLists.txt +++ b/eth/CMakeLists.txt @@ -41,9 +41,9 @@ if (JSCONSOLE) target_link_libraries(${EXECUTABLE} jsconsole) endif() -if (DEFINED WIN32 AND NOT DEFINED CMAKE_COMPILER_IS_MINGW) - eth_copy_dlls("${EXECUTABLE}" MHD_DLLS) -endif() +#if (DEFINED WIN32 AND NOT DEFINED CMAKE_COMPILER_IS_MINGW) +# eth_copy_dlls("${EXECUTABLE}" MHD_DLLS) +#endif() if (APPLE) install(TARGETS ${EXECUTABLE} DESTINATION bin) From 04a58ea06c0f6321dd798f94db24f37ef5f70f50 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Wed, 15 Jul 2015 14:56:24 +0200 Subject: [PATCH 12/62] Add OpenCL include directories to ICD - Also make it PUBLIC in cmake so that all who link to it will also get the OpenCL headers --- ethminer/CMakeLists.txt | 3 --- exp/CMakeLists.txt | 3 --- khronos_icd/CMakeLists.txt | 1 + khronos_icd/test/platform/CMakeLists.txt | 1 + libethash-cl/CMakeLists.txt | 1 - libethcore/CMakeLists.txt | 4 ---- 6 files changed, 2 insertions(+), 11 deletions(-) diff --git a/ethminer/CMakeLists.txt b/ethminer/CMakeLists.txt index 90889ae12..c321f0e5d 100644 --- a/ethminer/CMakeLists.txt +++ b/ethminer/CMakeLists.txt @@ -9,9 +9,6 @@ if (JSONRPC) include_directories(BEFORE ${JSONCPP_INCLUDE_DIRS}) include_directories(${JSON_RPC_CPP_INCLUDE_DIRS}) endif() -if (ETHASHCL) - include_directories(${OpenCL_INCLUDE_DIRS}) -endif () set(EXECUTABLE ethminer) diff --git a/exp/CMakeLists.txt b/exp/CMakeLists.txt index be7cec3d9..41940beef 100644 --- a/exp/CMakeLists.txt +++ b/exp/CMakeLists.txt @@ -6,9 +6,6 @@ aux_source_directory(. SRC_LIST) include_directories(BEFORE ${JSONCPP_INCLUDE_DIRS}) include_directories(BEFORE ..) include_directories(${DB_INCLUDE_DIRS}) -if (ETHASHCL) - include_directories(${OpenCL_INCLUDE_DIRS}) -endif () set(EXECUTABLE exp) diff --git a/khronos_icd/CMakeLists.txt b/khronos_icd/CMakeLists.txt index 9fc7ad2cd..b71a7c433 100644 --- a/khronos_icd/CMakeLists.txt +++ b/khronos_icd/CMakeLists.txt @@ -29,6 +29,7 @@ if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") endif () target_link_libraries (OpenCL_ICD ${CMAKE_DL_LIBS}) +target_include_directories(OpenCL_ICD PUBLIC ${OpenCL_INCLUDE_DIR}) enable_testing() add_subdirectory (test) diff --git a/khronos_icd/test/platform/CMakeLists.txt b/khronos_icd/test/platform/CMakeLists.txt index b35ca9336..c8af58a76 100644 --- a/khronos_icd/test/platform/CMakeLists.txt +++ b/khronos_icd/test/platform/CMakeLists.txt @@ -1 +1,2 @@ add_library (IcdLog SHARED icd_test_log.c) +target_include_directories(IcdLog PUBLIC ${OpenCL_INCLUDE_DIR}) \ No newline at end of file diff --git a/libethash-cl/CMakeLists.txt b/libethash-cl/CMakeLists.txt index 8fa7c97f3..70f711a76 100644 --- a/libethash-cl/CMakeLists.txt +++ b/libethash-cl/CMakeLists.txt @@ -21,7 +21,6 @@ set(HEADERS ${OUR_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/ethash_cl_miner_kernel.h) include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${Boost_INCLUDE_DIRS}) -include_directories(${OpenCL_INCLUDE_DIRS}) include_directories(..) add_library(${EXECUTABLE} ${SRC_LIST} ${HEADERS}) TARGET_LINK_LIBRARIES(${EXECUTABLE} OpenCL_ICD ethash) diff --git a/libethcore/CMakeLists.txt b/libethcore/CMakeLists.txt index 4dd626642..73ea75c8c 100644 --- a/libethcore/CMakeLists.txt +++ b/libethcore/CMakeLists.txt @@ -12,10 +12,6 @@ aux_source_directory(. SRC_LIST) include_directories(BEFORE ..) include_directories(${Boost_INCLUDE_DIRS}) -if (ETHASHCL) - include_directories(${OpenCL_INCLUDE_DIRS}) -endif () - if (CPUID_FOUND) include_directories(${Cpuid_INCLUDE_DIRS}) endif () From 14f6f49cdcf7ad5722960a7c944e3c44181fbca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Wed, 15 Jul 2015 15:30:27 +0200 Subject: [PATCH 13/62] Fix NSIS installer. --- CMakeLists.txt | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 271f3ed65..5bd4adf72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -506,26 +506,26 @@ endif () if (WIN32) # packaging stuff include(InstallRequiredSystemLibraries) - set(CPACK_PACKAGE_NAME "Ethereum") - set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Ethereum") + set(CPACK_PACKAGE_NAME "Ethereum (++)") + set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The Ethereum (++) Toolset") set(CPACK_PACKAGE_VENDOR "ethereum.org") set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md") set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") - set(CPACK_PACKAGE_VERSION "0.9") + set(CPACK_PACKAGE_VERSION "0.9.29") set(CPACK_GENERATOR "NSIS") # seems to be not working # set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/alethzero/alethzero.bmp") # our stuff - set(CPACK_COMPONENT_ALETHZERO_GROUP "Applications") - set(CPACK_COMPONENT_MIX_GROUP "Applications") - set(CPACK_COMPONENT_SOLC_GROUP "CLI") - set(CPACK_COMPONENT_ETH_GROUP "CLI") - set(CPACK_COMPONENT_ETHMINER_GROUP "CLI") - set(CPACK_COMPONENT_RLP_GROUP "CLI") - set(CPACK_COMPONENT_ABI_GROUP "CLI") + #set(CPACK_COMPONENT_ALETHZERO_GROUP "Applications") + #set(CPACK_COMPONENT_MIX_GROUP "Applications") + #set(CPACK_COMPONENT_SOLC_GROUP "CLI") + #set(CPACK_COMPONENT_ETH_GROUP "CLI") + #set(CPACK_COMPONENT_ETHMINER_GROUP "CLI") + #set(CPACK_COMPONENT_RLP_GROUP "CLI") + #set(CPACK_COMPONENT_ABI_GROUP "CLI") - set(CPACK_COMPONENTS_ALL alethzero mix solc eth ethminer rlp abi) + #set(CPACK_COMPONENTS_ALL alethzero mix solc eth ethminer rlp abi) # nsis specific stuff if (CMAKE_CL_64) @@ -536,7 +536,7 @@ if (WIN32) set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}") endif() - set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} Ethereum") + set(CPACK_NSIS_DISPLAY_NAME "Ethereum (++)") set(CPACK_NSIS_HELP_LINK "https://github.com/ethereum/cpp-ethereum") set(CPACK_NSIS_URL_INFO_ABOUT "https://github.com/ethereum/cpp-ethereum") set(CPACK_NSIS_CONTACT "ethereum.org") From 8dd3ccb88a5ef27fa488c74f85bd9b118aec6b86 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Wed, 15 Jul 2015 16:58:42 +0200 Subject: [PATCH 14/62] Handle no devices and no platforms better - Properly catch the exception thrown by getDevices() and if it's a no devices found error just return an empty vector. - Replace C macro for getPlatforms() with a proper function --- libethash-cl/ethash_cl_miner.cpp | 92 ++++++++++++++++++-------------- libethash-cl/ethash_cl_miner.h | 1 + 2 files changed, 54 insertions(+), 39 deletions(-) diff --git a/libethash-cl/ethash_cl_miner.cpp b/libethash-cl/ethash_cl_miner.cpp index dc806be1b..35700767c 100644 --- a/libethash-cl/ethash_cl_miner.cpp +++ b/libethash-cl/ethash_cl_miner.cpp @@ -78,30 +78,28 @@ ethash_cl_miner::~ethash_cl_miner() finish(); } -// Quite ugly. Saves us a lot of typing on these static functions -// since we can't keep the platforms vector in the class (static class/functions) -// -// LTODO: With a bit of general refactoring this could go away and platforms -// be queried only once and kept in the class. -#define ETHASHCL_GET_PLATFORMS(platforms_, failStmt_) \ - do { \ - try \ - { \ - cl::Platform::get(&platforms_); \ - } \ - catch (cl::Error const& err) \ - { \ - int errCode = err.err(); \ - if (errCode == CL_PLATFORM_NOT_FOUND_KHR) \ - ETHCL_LOG("No OpenCL platforms found"); \ - failStmt_; \ - } \ - } while(0) +std::vector ethash_cl_miner::getPlatforms() +{ + vector platforms; + try + { + cl::Platform::get(&platforms); + } + catch(cl::Error const& err) + { + if (err.err() == CL_PLATFORM_NOT_FOUND_KHR) + ETHCL_LOG("No OpenCL platforms found"); + else + throw err; + } + return platforms; +} string ethash_cl_miner::platform_info(unsigned _platformId, unsigned _deviceId) { - vector platforms; - ETHASHCL_GET_PLATFORMS(platforms, return string()); + vector platforms = getPlatforms(); + if (platforms.empty()) + return string(); // get GPU device of the selected platform unsigned platform_num = min(_platformId, platforms.size() - 1); vector devices = getDevices(platforms, _platformId); @@ -123,24 +121,35 @@ std::vector ethash_cl_miner::getDevices(std::vector co { vector devices; unsigned platform_num = min(_platformId, _platforms.size() - 1); - _platforms[platform_num].getDevices( - s_allowCPU ? CL_DEVICE_TYPE_ALL : ETHCL_QUERIED_DEVICE_TYPES, - &devices - ); + try + { + _platforms[platform_num].getDevices( + s_allowCPU ? CL_DEVICE_TYPE_ALL : ETHCL_QUERIED_DEVICE_TYPES, + &devices + ); + } + catch (cl::Error const& err) + { + // if simply no devices found return empty vector + if (err.err() != CL_DEVICE_NOT_FOUND) + throw err; + } return devices; } unsigned ethash_cl_miner::getNumPlatforms() { - vector platforms; - ETHASHCL_GET_PLATFORMS(platforms, return 0); + vector platforms = getPlatforms(); + if (platforms.empty()) + return 0; return platforms.size(); } unsigned ethash_cl_miner::getNumDevices(unsigned _platformId) { - vector platforms; - ETHASHCL_GET_PLATFORMS(platforms, return 0); + vector platforms = getPlatforms(); + if (platforms.empty()) + return 0; vector devices = getDevices(platforms, _platformId); if (devices.empty()) @@ -200,8 +209,9 @@ unsigned ethash_cl_miner::s_initialGlobalWorkSize = ethash_cl_miner::c_defaultGl bool ethash_cl_miner::searchForAllDevices(function _callback) { - vector platforms; - ETHASHCL_GET_PLATFORMS(platforms, return false); + vector platforms = getPlatforms(); + if (platforms.empty()) + return false; for (unsigned i = 0; i < platforms.size(); ++i) if (searchForAllDevices(i, _callback)) return true; @@ -211,8 +221,9 @@ bool ethash_cl_miner::searchForAllDevices(function _cal bool ethash_cl_miner::searchForAllDevices(unsigned _platformId, function _callback) { - vector platforms; - ETHASHCL_GET_PLATFORMS(platforms, return false); + vector platforms = getPlatforms(); + if (platforms.empty()) + return false; if (_platformId >= platforms.size()) return false; @@ -226,16 +237,18 @@ bool ethash_cl_miner::searchForAllDevices(unsigned _platformId, function _callback) { - vector platforms; - ETHASHCL_GET_PLATFORMS(platforms, return); + vector platforms = getPlatforms(); + if (platforms.empty()) + return; for (unsigned i = 0; i < platforms.size(); ++i) doForAllDevices(i, _callback); } void ethash_cl_miner::doForAllDevices(unsigned _platformId, function _callback) { - vector platforms; - ETHASHCL_GET_PLATFORMS(platforms, return); + vector platforms = getPlatforms(); + if (platforms.empty()) + return; if (_platformId >= platforms.size()) return; @@ -273,8 +286,9 @@ bool ethash_cl_miner::init( // get all platforms try { - vector platforms; - ETHASHCL_GET_PLATFORMS(platforms, return false); + vector platforms = getPlatforms(); + if (platforms.empty()) + return false; // use selected platform _platformId = min(_platformId, platforms.size() - 1); diff --git a/libethash-cl/ethash_cl_miner.h b/libethash-cl/ethash_cl_miner.h index fb28dc04b..3ea2fba4a 100644 --- a/libethash-cl/ethash_cl_miner.h +++ b/libethash-cl/ethash_cl_miner.h @@ -75,6 +75,7 @@ public: private: static std::vector getDevices(std::vector const& _platforms, unsigned _platformId); + static std::vector getPlatforms(); cl::Context m_context; cl::CommandQueue m_queue; From 0a1306a817f6ae2a0475d62a968c1f52c892b885 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Wed, 15 Jul 2015 17:15:14 +0200 Subject: [PATCH 15/62] Fix windows.h being included before winsock.h --- ethminer/main.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ethminer/main.cpp b/ethminer/main.cpp index 4deba38d1..3022cfc76 100644 --- a/ethminer/main.cpp +++ b/ethminer/main.cpp @@ -20,6 +20,14 @@ * Ethereum client. */ +// Solves the problem of including windows.h before including winsock.h +// as detailed here: +// http://stackoverflow.com/questions/1372480/c-redefinition-header-files-winsock2-h +#if defined(_WIN32) +#define _WINSOCKAPI_ +#include +#endif + #include #include #include From 5d32f8182092284a0ad9a24a2127a9ee9bdae045 Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Wed, 15 Jul 2015 17:39:56 +0200 Subject: [PATCH 16/62] Level DB support for WHisper completed --- libwhisper/WhisperDB.cpp | 58 ++++++++++++++++++++------------ libwhisper/WhisperHost.cpp | 8 ++++- libwhisper/WhisperHost.h | 10 +++--- test/libwhisper/whisperDB.cpp | 27 +++++++++++++++ test/libwhisper/whisperTopic.cpp | 30 +++++++---------- 5 files changed, 87 insertions(+), 46 deletions(-) diff --git a/libwhisper/WhisperDB.cpp b/libwhisper/WhisperDB.cpp index 43d775a96..dbafc9365 100644 --- a/libwhisper/WhisperDB.cpp +++ b/libwhisper/WhisperDB.cpp @@ -29,6 +29,7 @@ using namespace dev::shh; WhisperDB::WhisperDB() { + m_readOptions.verify_checksums = true; string path = dev::getDataDir("shh"); boost::filesystem::create_directories(path); leveldb::Options op; @@ -82,41 +83,54 @@ void WhisperDB::loadAll(std::map& o_dst) leveldb::ReadOptions op; op.fill_cache = false; op.verify_checksums = true; - vector wasted; + vector wasted; unsigned now = (unsigned)time(0); - leveldb::Iterator* it = m_db->NewIterator(op); + unique_ptr it(m_db->NewIterator(op)); for (it->SeekToFirst(); it->Valid(); it->Next()) { leveldb::Slice const k = it->key(); leveldb::Slice const v = it->value(); + bool useless = true; - bool useless = false; - RLP rlp((byte const*)v.data(), v.size()); - Envelope e(rlp); - h256 h2 = e.sha3(); - h256 h1; - - if (k.size() == h256::size) - h1 = h256((byte const*)k.data(), h256::ConstructFromPointer); - - if (h1 != h2) + try { - useless = true; - cwarn << "Corrupted data in Level DB:" << h1.hex() << "versus" << h2.hex(); + RLP rlp((byte const*)v.data(), v.size()); + Envelope e(rlp); + h256 h2 = e.sha3(); + h256 h1; + + if (k.size() == h256::size) + h1 = h256((byte const*)k.data(), h256::ConstructFromPointer); + + if (h1 != h2) + cwarn << "Corrupted data in Level DB:" << h1.hex() << "versus" << h2.hex(); + else if (e.expiry() > now) + { + o_dst[h1] = e; + useless = false; + } + } + catch(RLPException const& ex) + { + cwarn << "RLPException in WhisperDB::loadAll():" << ex.what(); + } + catch(Exception const& ex) + { + cwarn << "Exception in WhisperDB::loadAll():" << ex.what(); } - else if (e.expiry() <= now) - useless = true; if (useless) - wasted.push_back(k); - else - o_dst[h1] = e; + wasted.push_back(k.ToString()); } - delete it; + cdebug << "WhisperDB::loadAll(): loaded " << o_dst.size() << ", deleted " << wasted.size() << "messages"; - leveldb::WriteOptions woptions; for (auto k: wasted) - m_db->Delete(woptions, k); + { + leveldb::Status status = m_db->Delete(m_writeOptions, k); + if (!status.ok()) + cwarn << "Failed to delete an entry from Level DB:" << k; + } } + diff --git a/libwhisper/WhisperHost.cpp b/libwhisper/WhisperHost.cpp index 0202fcc24..82c173378 100644 --- a/libwhisper/WhisperHost.cpp +++ b/libwhisper/WhisperHost.cpp @@ -30,7 +30,7 @@ using namespace dev; using namespace dev::p2p; using namespace dev::shh; -WhisperHost::WhisperHost(): Worker("shh") +WhisperHost::WhisperHost(bool _useDB): Worker("shh"), m_useDB(_useDB) { loadMessagesFromBD(); } @@ -206,6 +206,9 @@ void WhisperHost::noteAdvertiseTopicsOfInterest() void WhisperHost::saveMessagesToBD() { + if (!m_useDB) + return; + try { WhisperDB db; @@ -247,6 +250,9 @@ void WhisperHost::saveMessagesToBD() void WhisperHost::loadMessagesFromBD() { + if (!m_useDB) + return; + try { map m; diff --git a/libwhisper/WhisperHost.h b/libwhisper/WhisperHost.h index a2ca28deb..2470ad68a 100644 --- a/libwhisper/WhisperHost.h +++ b/libwhisper/WhisperHost.h @@ -48,11 +48,10 @@ class WhisperHost: public HostCapability, public Interface, public friend class WhisperPeer; public: - WhisperHost(); + WhisperHost(bool _useDB = true); virtual ~WhisperHost(); unsigned protocolVersion() const { return WhisperProtocolVersion; } - /// remove old messages - void cleanup(); + void cleanup(); ///< remove old messages std::map all() const { dev::ReadGuard l(x_messages); return m_messages; } TopicBloomFilterHash bloom() const { dev::Guard l(m_filterLock); return m_bloom; } @@ -62,8 +61,7 @@ public: virtual void uninstallWatch(unsigned _watchId) override; virtual h256s peekWatch(unsigned _watchId) const override { dev::Guard l(m_filterLock); try { return m_watches.at(_watchId).changes; } catch (...) { return h256s(); } } virtual h256s checkWatch(unsigned _watchId) override { cleanup(); dev::Guard l(m_filterLock); h256s ret; try { ret = m_watches.at(_watchId).changes; m_watches.at(_watchId).changes.clear(); } catch (...) {} return ret; } - /// returns IDs of messages, which match specific watch criteria - virtual h256s watchMessages(unsigned _watchId) override; + virtual h256s watchMessages(unsigned _watchId) override; ///< returns IDs of messages, which match specific watch criteria virtual Envelope envelope(h256 _m) const override { try { dev::ReadGuard l(x_messages); return m_messages.at(_m); } catch (...) { return Envelope(); } } protected: @@ -85,6 +83,8 @@ private: std::map m_filters; std::map m_watches; TopicBloomFilter m_bloom; + + bool m_useDB; ///< needed for tests and other special cases }; } diff --git a/test/libwhisper/whisperDB.cpp b/test/libwhisper/whisperDB.cpp index 410420c24..1616dd427 100644 --- a/test/libwhisper/whisperDB.cpp +++ b/test/libwhisper/whisperDB.cpp @@ -124,6 +124,7 @@ BOOST_AUTO_TEST_CASE(persistence) BOOST_AUTO_TEST_CASE(messages) { cnote << "Testing load/save Whisper messages..."; + VerbosityHolder setTemporaryLevel(2); const unsigned TestSize = 3; map m1; map preexisting; @@ -173,4 +174,30 @@ BOOST_AUTO_TEST_CASE(messages) BOOST_REQUIRE_EQUAL(x, TestSize); } +BOOST_AUTO_TEST_CASE(corruptedData) +{ + cnote << "Testing corrupted data..."; + VerbosityHolder setTemporaryLevel(2); + map m; + h256 x = h256::random(); + + { + WhisperDB db; + db.insert(x, "this is a test input, representing corrupt data"); + } + + { + p2p::Host h("Test"); + auto wh = h.registerCapability(new WhisperHost()); + m = wh->all(); + BOOST_REQUIRE(m.end() == m.find(x)); + } + + { + WhisperDB db; + string s = db.lookup(x); + BOOST_REQUIRE(s.empty()); + } +} + BOOST_AUTO_TEST_SUITE_END() diff --git a/test/libwhisper/whisperTopic.cpp b/test/libwhisper/whisperTopic.cpp index 8d0f603bb..ad438f3ba 100644 --- a/test/libwhisper/whisperTopic.cpp +++ b/test/libwhisper/whisperTopic.cpp @@ -216,30 +216,25 @@ BOOST_AUTO_TEST_CASE(asyncforwarding) cnote << "Testing Whisper async forwarding..."; VerbosityHolder setTemporaryLevel(2); - + unsigned const TestValue = 8456; unsigned result = 0; bool done = false; // Host must be configured not to share peers. Host host1("Forwarder", NetworkPreferences("127.0.0.1", 30305, false)); host1.setIdealPeerCount(1); - auto whost1 = host1.registerCapability(new WhisperHost()); + auto whost1 = host1.registerCapability(new WhisperHost(false)); host1.start(); while (!host1.haveNetwork()) this_thread::sleep_for(chrono::milliseconds(2)); + auto w = whost1->installWatch(BuildTopicMask("test")); // only interested in odd packets bool startedForwarder = false; std::thread forwarder([&]() { setThreadName("forwarder"); - - this_thread::sleep_for(chrono::milliseconds(500)); - + this_thread::sleep_for(chrono::milliseconds(50)); startedForwarder = true; - - /// Only interested in odd packets - auto w = whost1->installWatch(BuildTopicMask("test")); - while (!done) { for (auto i: whost1->checkWatch(w)) @@ -257,31 +252,30 @@ BOOST_AUTO_TEST_CASE(asyncforwarding) { Host host2("Sender", NetworkPreferences("127.0.0.1", 30300, false)); host2.setIdealPeerCount(1); - shared_ptr whost2 = host2.registerCapability(new WhisperHost()); + shared_ptr whost2 = host2.registerCapability(new WhisperHost(false)); host2.start(); while (!host2.haveNetwork()) this_thread::sleep_for(chrono::milliseconds(2)); - host2.addNode(host1.id(), NodeIPEndpoint(bi::address::from_string("127.0.0.1"), 30305, 30305)); - while (!host2.peerCount()) + host2.requirePeer(host1.id(), NodeIPEndpoint(bi::address::from_string("127.0.0.1"), 30305, 30305)); + while (!host2.peerCount() || !host1.peerCount()) this_thread::sleep_for(chrono::milliseconds(5)); KeyPair us = KeyPair::create(); - whost2->post(us.sec(), RLPStream().append(1).out(), BuildTopic("test")); + whost2->post(us.sec(), RLPStream().append(TestValue).out(), BuildTopic("test"), 777000); this_thread::sleep_for(chrono::milliseconds(250)); } { Host ph("Listener", NetworkPreferences("127.0.0.1", 30300, false)); ph.setIdealPeerCount(1); - shared_ptr wh = ph.registerCapability(new WhisperHost()); + shared_ptr wh = ph.registerCapability(new WhisperHost(false)); ph.start(); while (!ph.haveNetwork()) this_thread::sleep_for(chrono::milliseconds(2)); - ph.addNode(host1.id(), NodeIPEndpoint(bi::address::from_string("127.0.0.1"), 30305, 30305)); - /// Only interested in odd packets - auto w = wh->installWatch(BuildTopicMask("test")); + auto w = wh->installWatch(BuildTopicMask("test")); // only interested in odd packets + ph.requirePeer(host1.id(), NodeIPEndpoint(bi::address::from_string("127.0.0.1"), 30305, 30305)); for (int i = 0; i < 200 && !result; ++i) { @@ -298,7 +292,7 @@ BOOST_AUTO_TEST_CASE(asyncforwarding) done = true; forwarder.join(); - BOOST_REQUIRE_EQUAL(result, 1); + BOOST_REQUIRE_EQUAL(result, TestValue); } BOOST_AUTO_TEST_CASE(topicAdvertising) From 0e894b1920c3921758ed52033a216b575374b9cb Mon Sep 17 00:00:00 2001 From: Dimitry Date: Wed, 15 Jul 2015 20:35:16 +0300 Subject: [PATCH 17/62] Recursive RLP check quick fix --- test/libdevcore/rlp.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/libdevcore/rlp.cpp b/test/libdevcore/rlp.cpp index 74e422b05..016b183e2 100644 --- a/test/libdevcore/rlp.cpp +++ b/test/libdevcore/rlp.cpp @@ -71,6 +71,7 @@ namespace dev { bytes payloadToDecode = fromHex(o["out"].get_str()); RLP payload(payloadToDecode); + ostringstream() << payload; if (payload.isEmpty()) BOOST_THROW_EXCEPTION(RLPException() << errinfo_comment("Decoded Empty RLP!")); o["in"] = "VALID"; @@ -128,6 +129,7 @@ namespace dev { bytes payloadToDecode = fromHex(o["out"].get_str()); RLP payload(payloadToDecode); + ostringstream() << payload; if (rlpType == RlpType::Test) dev::test::checkRLPAgainstJson(inputData, payload); From fe0f7d2f671ee57f3f2b1fd0bb2881b3a98a2705 Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Wed, 15 Jul 2015 19:52:59 +0200 Subject: [PATCH 18/62] style update --- test/libwhisper/whisperDB.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/libwhisper/whisperDB.cpp b/test/libwhisper/whisperDB.cpp index 1616dd427..333b7dc55 100644 --- a/test/libwhisper/whisperDB.cpp +++ b/test/libwhisper/whisperDB.cpp @@ -125,7 +125,7 @@ BOOST_AUTO_TEST_CASE(messages) { cnote << "Testing load/save Whisper messages..."; VerbosityHolder setTemporaryLevel(2); - const unsigned TestSize = 3; + unsigned const TestSize = 3; map m1; map preexisting; KeyPair us = KeyPair::create(); @@ -136,7 +136,7 @@ BOOST_AUTO_TEST_CASE(messages) preexisting = wh->all(); cnote << preexisting.size() << "preexisting messages in DB"; - for (int i = 0; i < TestSize; ++i) + for (unsigned i = 0; i < TestSize; ++i) wh->post(us.sec(), RLPStream().append(i).out(), BuildTopic("test"), 0xFFFFF); m1 = wh->all(); From cd93a85da18758316308e802d40a6236979bf33d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Wed, 15 Jul 2015 20:00:16 +0200 Subject: [PATCH 19/62] cmake: install OpenCL_ICD shared library --- khronos_icd/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/khronos_icd/CMakeLists.txt b/khronos_icd/CMakeLists.txt index b71a7c433..1dc30d2d6 100644 --- a/khronos_icd/CMakeLists.txt +++ b/khronos_icd/CMakeLists.txt @@ -31,5 +31,7 @@ endif () target_link_libraries (OpenCL_ICD ${CMAKE_DL_LIBS}) target_include_directories(OpenCL_ICD PUBLIC ${OpenCL_INCLUDE_DIR}) +install(TARGETS OpenCL_ICD RUNTIME DESTINATION bin LIBRARY DESTINATION lib) + enable_testing() add_subdirectory (test) From 6a58747fe1662b3f9360dae348c21d9160426303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Wed, 15 Jul 2015 20:05:54 +0200 Subject: [PATCH 20/62] Remove OpenCL ICD test projects --- khronos_icd/CMakeLists.txt | 3 - khronos_icd/test/CMakeLists.txt | 7 - khronos_icd/test/Makefile | 18 - khronos_icd/test/driver_stub/CMakeLists.txt | 10 - khronos_icd/test/driver_stub/Makefile | 14 - khronos_icd/test/driver_stub/cl.c | 1917 ----------------- khronos_icd/test/driver_stub/cl_ext.c | 35 - khronos_icd/test/driver_stub/cl_gl.c | 221 -- khronos_icd/test/driver_stub/driver_stub.def | 3 - khronos_icd/test/driver_stub/icd.c | 185 -- .../test/driver_stub/icd_driver_exports.map | 8 - khronos_icd/test/driver_stub/icd_structs.h | 18 - khronos_icd/test/driver_stub/rename_api.h | 106 - khronos_icd/test/inc/platform/icd_test_log.h | 20 - khronos_icd/test/loader_test/CMakeLists.txt | 15 - khronos_icd/test/loader_test/Makefile | 16 - khronos_icd/test/loader_test/callbacks.c | 43 - khronos_icd/test/loader_test/icd_test_match.c | 36 - khronos_icd/test/loader_test/main.c | 47 - khronos_icd/test/loader_test/param_struct.h | 1115 ---------- .../test/loader_test/test_buffer_object.c | 461 ---- .../test/loader_test/test_cl_runtime.c | 64 - khronos_icd/test/loader_test/test_clgl.c | 345 --- .../test/loader_test/test_create_calls.c | 767 ------- .../test/loader_test/test_image_objects.c | 362 ---- khronos_icd/test/loader_test/test_kernel.c | 596 ----- khronos_icd/test/loader_test/test_platforms.c | 183 -- .../test/loader_test/test_program_objects.c | 260 --- .../test/loader_test/test_sampler_objects.c | 64 - khronos_icd/test/platform/CMakeLists.txt | 2 - khronos_icd/test/platform/Makefile | 15 - khronos_icd/test/platform/icd_test_log.c | 98 - 32 files changed, 7054 deletions(-) delete mode 100644 khronos_icd/test/CMakeLists.txt delete mode 100644 khronos_icd/test/Makefile delete mode 100644 khronos_icd/test/driver_stub/CMakeLists.txt delete mode 100644 khronos_icd/test/driver_stub/Makefile delete mode 100644 khronos_icd/test/driver_stub/cl.c delete mode 100644 khronos_icd/test/driver_stub/cl_ext.c delete mode 100644 khronos_icd/test/driver_stub/cl_gl.c delete mode 100644 khronos_icd/test/driver_stub/driver_stub.def delete mode 100644 khronos_icd/test/driver_stub/icd.c delete mode 100644 khronos_icd/test/driver_stub/icd_driver_exports.map delete mode 100644 khronos_icd/test/driver_stub/icd_structs.h delete mode 100644 khronos_icd/test/driver_stub/rename_api.h delete mode 100644 khronos_icd/test/inc/platform/icd_test_log.h delete mode 100644 khronos_icd/test/loader_test/CMakeLists.txt delete mode 100644 khronos_icd/test/loader_test/Makefile delete mode 100644 khronos_icd/test/loader_test/callbacks.c delete mode 100644 khronos_icd/test/loader_test/icd_test_match.c delete mode 100644 khronos_icd/test/loader_test/main.c delete mode 100644 khronos_icd/test/loader_test/param_struct.h delete mode 100644 khronos_icd/test/loader_test/test_buffer_object.c delete mode 100644 khronos_icd/test/loader_test/test_cl_runtime.c delete mode 100644 khronos_icd/test/loader_test/test_clgl.c delete mode 100644 khronos_icd/test/loader_test/test_create_calls.c delete mode 100644 khronos_icd/test/loader_test/test_image_objects.c delete mode 100644 khronos_icd/test/loader_test/test_kernel.c delete mode 100644 khronos_icd/test/loader_test/test_platforms.c delete mode 100644 khronos_icd/test/loader_test/test_program_objects.c delete mode 100644 khronos_icd/test/loader_test/test_sampler_objects.c delete mode 100644 khronos_icd/test/platform/CMakeLists.txt delete mode 100644 khronos_icd/test/platform/Makefile delete mode 100644 khronos_icd/test/platform/icd_test_log.c diff --git a/khronos_icd/CMakeLists.txt b/khronos_icd/CMakeLists.txt index 1dc30d2d6..8ec311d36 100644 --- a/khronos_icd/CMakeLists.txt +++ b/khronos_icd/CMakeLists.txt @@ -32,6 +32,3 @@ target_link_libraries (OpenCL_ICD ${CMAKE_DL_LIBS}) target_include_directories(OpenCL_ICD PUBLIC ${OpenCL_INCLUDE_DIR}) install(TARGETS OpenCL_ICD RUNTIME DESTINATION bin LIBRARY DESTINATION lib) - -enable_testing() -add_subdirectory (test) diff --git a/khronos_icd/test/CMakeLists.txt b/khronos_icd/test/CMakeLists.txt deleted file mode 100644 index ed84476d9..000000000 --- a/khronos_icd/test/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -include_directories (./inc) - -add_subdirectory (platform) -add_subdirectory (driver_stub) -add_subdirectory (loader_test) - -add_test (OPENCL_ICD_LOADER_TEST ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/icd_loader_test) diff --git a/khronos_icd/test/Makefile b/khronos_icd/test/Makefile deleted file mode 100644 index db52dc5cc..000000000 --- a/khronos_icd/test/Makefile +++ /dev/null @@ -1,18 +0,0 @@ - -.PHONY: all platform driver_stub loader_test clean - -all: platform driver_stub loader_test - -platform: - ${MAKE} -C platform - -driver_stub: - ${MAKE} -C driver_stub - -loader_test: - ${MAKE} -C loader_test - -clean: - ${MAKE} -C platform clean - ${MAKE} -C driver_stub clean - ${MAKE} -C loader_test clean diff --git a/khronos_icd/test/driver_stub/CMakeLists.txt b/khronos_icd/test/driver_stub/CMakeLists.txt deleted file mode 100644 index 13048172f..000000000 --- a/khronos_icd/test/driver_stub/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ - -set (OPENCL_DRIVER_STUB_SOURCES cl.c cl_ext.c cl_gl.c icd.c) - -if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") - list (APPEND OPENCL_DRIVER_STUB_SOURCES driver_stub.def) -endif () - -add_library (OpenCLDriverStub SHARED ${OPENCL_DRIVER_STUB_SOURCES}) - -target_link_libraries (OpenCLDriverStub IcdLog) diff --git a/khronos_icd/test/driver_stub/Makefile b/khronos_icd/test/driver_stub/Makefile deleted file mode 100644 index dd79b51cd..000000000 --- a/khronos_icd/test/driver_stub/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -CC := gcc -CFLAGS := -I ../inc -I ../../ -fPIC -g -O0 - -OUTDIR := ../../bin - -${OUTDIR}/libOpenCLDriverStub.so: cl.c cl_ext.c cl_gl.c icd.c - ${CC} ${CFLAGS} -shared -Wl,-soname,$@ \ - -Wl,--version-script,icd_driver_exports.map \ - -o $@ $^ ${OUTDIR}/libIcdLog.so - -.PHONY: clean - -clean: - rm -f ${OUTDIR}/libOpenCLDriverStub.so diff --git a/khronos_icd/test/driver_stub/cl.c b/khronos_icd/test/driver_stub/cl.c deleted file mode 100644 index f84074e4a..000000000 --- a/khronos_icd/test/driver_stub/cl.c +++ /dev/null @@ -1,1917 +0,0 @@ -#include -#include -#include - -#ifndef CL_USE_DEPRECATED_OPENCL_1_0_APIS -#define CL_USE_DEPRECATED_OPENCL_1_0_APIS -#endif - -#ifndef CL_USE_DEPRECATED_OPENCL_1_1_APIS -#define CL_USE_DEPRECATED_OPENCL_1_1_APIS -#endif - -// Need to rename all CL API functions to prevent ICD loader functions calling -// themselves via the dispatch table. Include this before cl headers. -#include "rename_api.h" - -#include -#include -#include "icd_structs.h" - -#define CL_PLATFORM_ICD_SUFFIX_KHR 0x0920 -CL_API_ENTRY cl_int CL_API_CALL -clIcdGetPlatformIDsKHR(cl_uint, cl_platform_id *, cl_uint *); - -struct _cl_platform_id -{ - CLIicdDispatchTable* dispatch; - const char *profile; - const char *version; - const char *name; - const char *vendor; - const char *extensions; - const char *suffix; -}; - -struct _cl_device_id -{ - CLIicdDispatchTable* dispatch; -}; - -struct _cl_context -{ - CLIicdDispatchTable* dispatch; -}; - -struct _cl_command_queue -{ - CLIicdDispatchTable* dispatch; -}; - -struct _cl_mem -{ - CLIicdDispatchTable* dispatch; -}; - -struct _cl_program -{ - CLIicdDispatchTable* dispatch; -}; - -struct _cl_kernel -{ - CLIicdDispatchTable* dispatch; -}; - -struct _cl_event -{ - CLIicdDispatchTable* dispatch; -}; - -struct _cl_sampler -{ - CLIicdDispatchTable* dispatch; -}; - -static CLIicdDispatchTable* dispatchTable = NULL; -static cl_platform_id platform = NULL; -static cl_bool initialized = CL_FALSE; - -CL_API_ENTRY cl_int CL_API_CALL -clGetPlatformIDs(cl_uint num_entries , - cl_platform_id * platforms , - cl_uint * num_platforms) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clGetPlatformIDs(%u, %p, %p)\n", - num_entries, - platforms, - num_platforms); - return_value = clIcdGetPlatformIDsKHR(num_entries, platforms, num_platforms); - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetPlatformInfo(cl_platform_id platform, - cl_platform_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int result = CL_SUCCESS; - cl_int return_value = CL_SUCCESS; - const char *returnString = NULL; - size_t returnStringLength = 0; - /*test_icd_stub_log("clGetPlatformInfo(%p, %u, %u, %p, %p)\n", - platform, - param_name, - param_value_size, - param_value, - param_value_size_ret);*/ - - // validate the arguments - if (param_value_size == 0 && param_value != NULL) { - return CL_INVALID_VALUE; - } - // select the string to return - switch(param_name) { - case CL_PLATFORM_PROFILE: - returnString = platform->profile; - break; - case CL_PLATFORM_VERSION: - returnString = platform->version; - break; - case CL_PLATFORM_NAME: - returnString = platform->name; - break; - case CL_PLATFORM_VENDOR: - returnString = platform->vendor; - break; - case CL_PLATFORM_EXTENSIONS: - returnString = platform->extensions; - break; - case CL_PLATFORM_ICD_SUFFIX_KHR: - returnString = platform->suffix; - break; - default: - /*test_icd_stub_log("Value returned: %d\n", - CL_INVALID_VALUE);*/ - return CL_INVALID_VALUE; - break; - } - - // make sure the buffer passed in is big enough for the result - returnStringLength = strlen(returnString)+1; - if (param_value_size && param_value_size < returnStringLength) { - /*test_icd_stub_log("Value returned: %d\n", - CL_INVALID_VALUE);*/ - return CL_INVALID_VALUE; - } - - // pass the data back to the user - if (param_value) { - memcpy(param_value, returnString, returnStringLength); - } - if (param_value_size_ret) { - *param_value_size_ret = returnStringLength; - } - - /*test_icd_stub_log("Value returned: %d\n", - return_value);*/ - return return_value; -} - - -/* Device APIs */ -CL_API_ENTRY cl_int CL_API_CALL -clGetDeviceIDs(cl_platform_id platform, - cl_device_type device_type, - cl_uint num_entries, - cl_device_id * devices, - cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_SUCCESS; - - if ((num_entries > 1 || num_entries < 0) && devices != NULL) { - return_value = CL_INVALID_VALUE; - } - else { - cl_device_id obj = (cl_device_id) malloc(sizeof(cl_device_id)); - obj->dispatch = dispatchTable; - *devices = obj; - } - if (num_devices) { - *num_devices = 1; - } - - test_icd_stub_log("clGetDeviceIDs(%p, %x, %u, %p, %p)\n", - platform, - device_type, - num_entries, - devices, - num_devices); - test_icd_stub_log("Value returned: %d\n", CL_SUCCESS); - return CL_SUCCESS; -} - - - -CL_API_ENTRY cl_int CL_API_CALL -clGetDeviceInfo(cl_device_id device, - cl_device_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clGetDeviceInfo(%p, %u, %u, %p, %p)\n", - device, - param_name, - param_value_size, - param_value, - param_value_size_ret); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clCreateSubDevices(cl_device_id in_device, - const cl_device_partition_property *properties, - cl_uint num_entries, - cl_device_id *out_devices, - cl_uint *num_devices) CL_API_SUFFIX__VERSION_1_2 -{ - - cl_int return_value = CL_OUT_OF_RESOURCES; - - test_icd_stub_log("clCreateSubDevices(%p, %p, %u, %p, %p)\n", - in_device, - properties, - num_entries, - out_devices, - num_devices); - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - - -CL_API_ENTRY cl_int CL_API_CALL -clRetainDevice(cl_device_id device) CL_API_SUFFIX__VERSION_1_2 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clRetainDevice(%p)\n", device); - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - - -CL_API_ENTRY cl_int CL_API_CALL -clReleaseDevice(cl_device_id device) CL_API_SUFFIX__VERSION_1_2 - -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clReleaseDevice(%p)\n", device); - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - - -/* Context APIs */ -CL_API_ENTRY cl_context CL_API_CALL -clCreateContext(const cl_context_properties * properties, - cl_uint num_devices , - const cl_device_id * devices, - void (CL_CALLBACK * pfn_notify)(const char *, const void *, size_t, void *), - void * user_data, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - cl_context obj = (cl_context) malloc(sizeof(struct _cl_context)); - obj->dispatch = dispatchTable; - test_icd_stub_log("clCreateContext(%p, %u, %p, %p, %p, %p)\n", - properties, - num_devices, - devices, - pfn_notify, - user_data, - errcode_ret); - pfn_notify(NULL, NULL, 0, NULL); - test_icd_stub_log("createcontext_callback(%p, %p, %u, %p)\n", - NULL, - NULL, - 0, - NULL); - - test_icd_stub_log("Value returned: %p\n", obj); - return obj; -} - - -CL_API_ENTRY cl_context CL_API_CALL -clCreateContextFromType(const cl_context_properties * properties, - cl_device_type device_type, - void (CL_CALLBACK * pfn_notify)(const char *, const void *, size_t, void *), - void * user_data, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - cl_context obj = (cl_context) malloc(sizeof(struct _cl_context)); - obj->dispatch = dispatchTable; - test_icd_stub_log("clCreateContextFromType(%p, %x, %p, %p, %p)\n", - properties, - device_type, - pfn_notify, - user_data, - errcode_ret); - pfn_notify(NULL, NULL, 0, NULL); - - test_icd_stub_log ("createcontext_callback(%p, %p, %u, %p)\n", - NULL, - NULL, - 0, - NULL); - - test_icd_stub_log("Value returned: %p\n", - obj); - return obj; -} - -CL_API_ENTRY cl_int CL_API_CALL -clRetainContext(cl_context context) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clRetainContext(%p)\n", context); - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clReleaseContext(cl_context context) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clReleaseContext(%p)\n", context); - free(context); - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetContextInfo(cl_context context, - cl_context_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clGetContextInfo(%p, %u, %u, %p, %p)\n", - context, - param_name, - param_value_size, - param_value, - param_value_size_ret); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -/* Command Queue APIs */ -CL_API_ENTRY cl_command_queue CL_API_CALL -clCreateCommandQueue(cl_context context, - cl_device_id device, - cl_command_queue_properties properties, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - cl_command_queue obj = (cl_command_queue) malloc(sizeof(struct _cl_command_queue)); - obj->dispatch = dispatchTable; - test_icd_stub_log("clCreateCommandQueue(%p, %p, %x, %p)\n", - context, - device, - properties, - errcode_ret); - - test_icd_stub_log("Value returned: %p\n", obj); - return obj; -} - -CL_API_ENTRY cl_int CL_API_CALL -clSetCommandQueueProperty(cl_command_queue command_queue , - cl_command_queue_properties properties , - cl_bool enable , - cl_command_queue_properties * old_properties) CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clSetCommandQueueProperty(%p, %p, %u, %p)\n", - command_queue, - properties, - enable, - old_properties); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clRetainCommandQueue(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clRetainCommandQueue(%p)\n", command_queue); - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clReleaseCommandQueue(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clReleaseCommandQueue(%p)\n", command_queue); - free(command_queue); - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetCommandQueueInfo(cl_command_queue command_queue , - cl_command_queue_info param_name , - size_t param_value_size , - void * param_value , - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clGetCommandQueueInfo(%p, %u, %u, %p, %p)\n", - command_queue, - param_name, - param_value_size, - param_value, - param_value_size_ret); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - - - -/* Memory Object APIs */ -CL_API_ENTRY cl_mem CL_API_CALL -clCreateBuffer(cl_context context , - cl_mem_flags flags , - size_t size , - void * host_ptr , - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem)); - obj->dispatch = dispatchTable; - test_icd_stub_log("clCreateBuffer(%p, %x, %u, %p, %p)\n", - context, - flags, - size, - host_ptr, - errcode_ret); - - test_icd_stub_log("Value returned: %p\n", obj); - return obj; -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateSubBuffer(cl_mem buffer , - cl_mem_flags flags , - cl_buffer_create_type buffer_create_type , - const void * buffer_create_info , - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_1 -{ - cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem)); - obj->dispatch = dispatchTable; - test_icd_stub_log("clCreateSubBuffer(%p, %x, %u, %p, %p)\n", - buffer, - flags, - buffer_create_type, - buffer_create_info, - errcode_ret); - - test_icd_stub_log("Value returned: %p\n", obj); - return obj; -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateImage(cl_context context, - cl_mem_flags flags, - const cl_image_format * image_format, - const cl_image_desc * image_desc, - void * host_ptr, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2 -{ - cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem)); - obj->dispatch = dispatchTable; - test_icd_stub_log("clCreateImage(%p, %x, %p, %p, %p, %p)\n", - context, - flags, - image_format, - image_desc, - host_ptr, - errcode_ret); - - test_icd_stub_log("Value returned: %p\n", obj); - return obj; -} - - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateImage2D(cl_context context , - cl_mem_flags flags , - const cl_image_format * image_format , - size_t image_width , - size_t image_height , - size_t image_row_pitch , - void * host_ptr , - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem)); - obj->dispatch = dispatchTable; - test_icd_stub_log("clCreateImage2D(%p, %x, %p, %u, %u, %u, %p, %p)\n", - context, - flags, - image_format, - image_width, - image_height, - image_row_pitch, - host_ptr); - - test_icd_stub_log("Value returned: %p\n", obj); - return obj; -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateImage3D(cl_context context, - cl_mem_flags flags, - const cl_image_format * image_format, - size_t image_width, - size_t image_height , - size_t image_depth , - size_t image_row_pitch , - size_t image_slice_pitch , - void * host_ptr , - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem)); - obj->dispatch = dispatchTable; - test_icd_stub_log("clCreateImage3D(%p, %x, %p, %u, %u, %u, %u, %u, %p, %p)\n", - context, - flags, - image_format, - image_width, - image_height, - image_depth, - image_row_pitch, - image_slice_pitch, - host_ptr, - errcode_ret); - - test_icd_stub_log("Value returned: %p\n", obj); - return obj; -} - -CL_API_ENTRY cl_int CL_API_CALL -clRetainMemObject(cl_mem memobj) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clRetainMemObject(%p)\n", memobj); - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clReleaseMemObject(cl_mem memobj) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clReleaseMemObject(%p)\n", memobj); - free(memobj); - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetSupportedImageFormats(cl_context context, - cl_mem_flags flags, - cl_mem_object_type image_type , - cl_uint num_entries , - cl_image_format * image_formats , - cl_uint * num_image_formats) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clGetSupportedImageFormats(%p, %x, %u, %u, %p, %p)\n", - context, - flags, - image_type, - num_entries, - image_formats, - num_image_formats); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetMemObjectInfo(cl_mem memobj , - cl_mem_info param_name , - size_t param_value_size , - void * param_value , - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clGetMemObjectInfo(%p, %u, %u, %p, %p)\n", - memobj, - param_name, - param_value_size, - param_value, - param_value_size_ret); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetImageInfo(cl_mem image , - cl_image_info param_name , - size_t param_value_size , - void * param_value , - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clGetImageInfo(%p, %u, %u, %p, %p)\n", - image, - param_name, - param_value_size, - param_value, - param_value_size_ret); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clSetMemObjectDestructorCallback(cl_mem memobj , - void (CL_CALLBACK * pfn_notify)(cl_mem memobj , void* user_data), - void * user_data) CL_API_SUFFIX__VERSION_1_1 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clSetMemObjectDestructorCallback(%p, %p, %p)\n", - memobj, - pfn_notify, - user_data); - pfn_notify(memobj, NULL); - test_icd_stub_log("setmemobjectdestructor_callback(%p, %p)\n", - memobj, - NULL); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -/* Sampler APIs */ -CL_API_ENTRY cl_sampler CL_API_CALL -clCreateSampler(cl_context context , - cl_bool normalized_coords , - cl_addressing_mode addressing_mode , - cl_filter_mode filter_mode , - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - cl_sampler obj = (cl_sampler) malloc(sizeof(struct _cl_sampler)); - obj->dispatch = dispatchTable; - test_icd_stub_log("clCreateSampler(%p, %u, %u, %u, %p)\n", - context, - normalized_coords, - addressing_mode, - filter_mode, - errcode_ret); - - test_icd_stub_log("Value returned: %p\n", obj); - return obj; -} - -CL_API_ENTRY cl_int CL_API_CALL -clRetainSampler(cl_sampler sampler) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clRetainSampler(%p)\n", sampler); - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clReleaseSampler(cl_sampler sampler) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clReleaseSampler(%p)\n", sampler); - free(sampler); - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetSamplerInfo(cl_sampler sampler , - cl_sampler_info param_name , - size_t param_value_size , - void * param_value , - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clGetSamplerInfo(%p, %u, %u, %p, %p)\n", - sampler, - param_name, - param_value_size, - param_value, - param_value_size_ret); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -/* Program Object APIs */ -CL_API_ENTRY cl_program CL_API_CALL -clCreateProgramWithSource(cl_context context , - cl_uint count , - const char ** strings , - const size_t * lengths , - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - cl_program obj = (cl_program) malloc(sizeof(struct _cl_program)); - obj->dispatch = dispatchTable; - test_icd_stub_log("clCreateProgramWithSource(%p, %u, %p, %p, %p)\n", - context, - count, - strings, - lengths, - errcode_ret); - - test_icd_stub_log("Value returned: %p\n", obj); - return obj; -} - -CL_API_ENTRY cl_program CL_API_CALL -clCreateProgramWithBinary(cl_context context , - cl_uint num_devices , - const cl_device_id * device_list , - const size_t * lengths , - const unsigned char ** binaries , - cl_int * binary_status , - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - cl_program obj = (cl_program) malloc(sizeof(struct _cl_program)); - obj->dispatch = dispatchTable; - test_icd_stub_log("clCreateProgramWithBinary(%p, %u, %p, %p, %p, %p, %p)\n", - context, - num_devices, - device_list, - lengths, - binaries, - binary_status, - errcode_ret); - - test_icd_stub_log("Value returned: %p\n", obj); - return obj; -} - -CL_API_ENTRY cl_program CL_API_CALL -clCreateProgramWithBuiltInKernels(cl_context context , - cl_uint num_devices , - const cl_device_id * device_list , - const char * kernel_names , - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2 -{ - cl_program obj = (cl_program) malloc(sizeof(struct _cl_program)); - obj->dispatch = dispatchTable; - test_icd_stub_log("clCreateProgramWithBuiltInKernels(%p, %u, %p, %p, %p)\n", - context, - num_devices, - device_list, - kernel_names, - errcode_ret); - - test_icd_stub_log("Value returned: %p\n", obj); - return obj; -} - - -CL_API_ENTRY cl_int CL_API_CALL -clRetainProgram(cl_program program) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clRetainProgram(%p)\n", - program); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clReleaseProgram(cl_program program) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clReleaseProgram(%p)\n", program); - free(program); - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clBuildProgram(cl_program program , - cl_uint num_devices , - const cl_device_id * device_list , - const char * options , - void (CL_CALLBACK * pfn_notify)(cl_program program , void * user_data), - void * user_data) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clBuildProgram(%p, %u, %p, %p, %p, %p)\n", - program, - num_devices, - device_list, - options, - pfn_notify, - user_data); - pfn_notify(program, NULL); - test_icd_stub_log("program_callback(%p, %p)\n", program, NULL); - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clUnloadCompiler(void) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clUnloadCompiler()\n"); - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clCompileProgram(cl_program program , - cl_uint num_devices , - const cl_device_id * device_list , - const char * options , - cl_uint num_input_headers , - const cl_program * input_headers, - const char ** header_include_names , - void (CL_CALLBACK * pfn_notify)(cl_program program , void * user_data), - void * user_data) CL_API_SUFFIX__VERSION_1_2 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clCompileProgram(%p, %u, %p, %p, %u, %p, %p, %p)\n", - program, - num_devices, - device_list, - options, - num_input_headers, - header_include_names, - pfn_notify, - user_data); - pfn_notify(program, NULL); - test_icd_stub_log("program_callback(%p, %p)\n", program, NULL); - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_program CL_API_CALL -clLinkProgram(cl_context context , - cl_uint num_devices , - const cl_device_id * device_list , - const char * options , - cl_uint num_input_programs , - const cl_program * input_programs , - void (CL_CALLBACK * pfn_notify)(cl_program program , void * user_data), - void * user_data , - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2 -{ - cl_program obj = (cl_program) malloc(sizeof(cl_program)); - obj->dispatch = dispatchTable; - test_icd_stub_log("clLinkProgram(%p, %u, %p, %p, %u, %p, %p, %p, %p)\n", - context, - num_devices, - device_list, - options, - num_input_programs, - input_programs, - pfn_notify, - user_data, - errcode_ret); - pfn_notify(obj, NULL); - test_icd_stub_log("program_callback(%p, %p)\n", obj, NULL); - test_icd_stub_log("Value returned: %p\n", obj); - return obj; -} - - -CL_API_ENTRY cl_int CL_API_CALL -clUnloadPlatformCompiler(cl_platform_id platform) CL_API_SUFFIX__VERSION_1_2 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clUnloadPlatformCompiler(%p)\n", platform); - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetProgramInfo(cl_program program , - cl_program_info param_name , - size_t param_value_size , - void * param_value , - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clGetProgramInfo(%p, %u, %u, %p, %p)\n", - program, - param_name, - param_value_size, - param_value, - param_value_size_ret); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetProgramBuildInfo(cl_program program , - cl_device_id device , - cl_program_build_info param_name , - size_t param_value_size , - void * param_value , - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clGetProgramBuildInfo(%p, %p, %u, %u, %p, %p)\n", - program, - device, - param_name, - param_value_size, - param_value, - param_value_size_ret); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -/* Kernel Object APIs */ -CL_API_ENTRY cl_kernel CL_API_CALL -clCreateKernel(cl_program program , - const char * kernel_name , - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - cl_kernel obj = (cl_kernel) malloc(sizeof(struct _cl_kernel)); - obj->dispatch = dispatchTable; - test_icd_stub_log("clCreateKernel(%p, %p, %p)\n", - program, - kernel_name, - errcode_ret); - - test_icd_stub_log("Value returned: %p\n", obj); - return obj; -} - -CL_API_ENTRY cl_int CL_API_CALL -clCreateKernelsInProgram(cl_program program , - cl_uint num_kernels , - cl_kernel * kernels , - cl_uint * num_kernels_ret) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clCreateKernelsInProgram(%p, %u, %p, %p)\n", - program, - num_kernels, - kernels, - num_kernels_ret); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clRetainKernel(cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clRetainKernel(%p)\n", kernel); - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clReleaseKernel(cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clReleaseKernel(%p)\n", kernel); - free(kernel); - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clSetKernelArg(cl_kernel kernel , - cl_uint arg_index , - size_t arg_size , - const void * arg_value) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clSetKernelArg(%p, %u, %u, %p)\n", - kernel, - arg_index, - arg_size, - arg_value); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetKernelInfo(cl_kernel kernel , - cl_kernel_info param_name , - size_t param_value_size , - void * param_value , - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clGetKernelInfo(%p, %u, %u, %p, %p)\n", - kernel, - param_name, - param_value_size, - param_value, - param_value_size_ret); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetKernelArgInfo(cl_kernel kernel , - cl_uint arg_indx , - cl_kernel_arg_info param_name , - size_t param_value_size , - void * param_value , - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_2 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clGetKernelArgInfo(%p, %u, %u, %u, %p, %p)\n", - kernel, - arg_indx, - param_name, - param_value_size, - param_value, - param_value_size_ret); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetKernelWorkGroupInfo(cl_kernel kernel , - cl_device_id device , - cl_kernel_work_group_info param_name , - size_t param_value_size , - void * param_value , - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clGetKernelWorkGroupInfo(%p, %p, %u, %u, %p, %p)\n", - kernel, - device, - param_name, - param_value_size, - param_value, - param_value_size_ret); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -/* Event Object APIs */ -CL_API_ENTRY cl_int CL_API_CALL -clWaitForEvents(cl_uint num_events , - const cl_event * event_list) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clWaitForEvents(%u, %p)\n", - num_events, - event_list); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetEventInfo(cl_event event , - cl_event_info param_name , - size_t param_value_size , - void * param_value , - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clGetEventInfo(%p, %u, %u, %p, %p)\n", - event, - param_name, - param_value_size, - param_value, - param_value_size_ret); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_event CL_API_CALL -clCreateUserEvent(cl_context context , - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_1 -{ - cl_event obj = (cl_event) malloc(sizeof(struct _cl_event)); - obj->dispatch = dispatchTable; - test_icd_stub_log("clCreateUserEvent(%p, %p)\n", context, errcode_ret); - test_icd_stub_log("Value returned: %p\n", obj); - return obj; -} - -CL_API_ENTRY cl_int CL_API_CALL -clRetainEvent(cl_event event) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clRetainEvent(%p)\n", event); - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clReleaseEvent(cl_event event) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clReleaseEvent(%p)\n", event); - free(event); - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clSetUserEventStatus(cl_event event , - cl_int execution_status) CL_API_SUFFIX__VERSION_1_1 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clSetUserEventStatus(%p, %d)\n", - event, - execution_status); - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clSetEventCallback(cl_event event , - cl_int command_exec_callback_type , - void (CL_CALLBACK * pfn_notify)(cl_event, cl_int, void *), - void * user_data) CL_API_SUFFIX__VERSION_1_1 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clSetEventCallback(%p, %d, %p, %p)\n", - event, - command_exec_callback_type, - pfn_notify, - user_data); - pfn_notify(event, command_exec_callback_type, NULL); - test_icd_stub_log("setevent_callback(%p, %d, %p)\n", - event, - command_exec_callback_type, - NULL); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -/* Profiling APIs */ -CL_API_ENTRY cl_int CL_API_CALL -clGetEventProfilingInfo(cl_event event , - cl_profiling_info param_name , - size_t param_value_size , - void * param_value , - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clGetEventProfilingInfo(%p, %u, %u, %p, %p)\n", - event, - param_name, - param_value_size, - param_value, - param_value_size_ret); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -/* Flush and Finish APIs */ -CL_API_ENTRY cl_int CL_API_CALL -clFlush(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clFlush(%p)\n", command_queue); - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clFinish(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clFinish(%p)\n", command_queue); - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -/* Enqueued Commands APIs */ -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReadBuffer(cl_command_queue command_queue , - cl_mem buffer , - cl_bool blocking_read , - size_t offset , - size_t cb , - void * ptr , - cl_uint num_events_in_wait_list , - const cl_event * event_wait_list , - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clEnqueueReadBuffer(%p, %p, %u, %u, %u, %p, %u, %p, %p)\n", - command_queue, - buffer, - blocking_read, - offset, - cb, - ptr, - num_events_in_wait_list, - event_wait_list, event); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReadBufferRect(cl_command_queue command_queue , - cl_mem buffer , - cl_bool blocking_read , - const size_t * buffer_origin , - const size_t * host_origin , - const size_t * region , - size_t buffer_row_pitch , - size_t buffer_slice_pitch , - size_t host_row_pitch , - size_t host_slice_pitch , - void * ptr , - cl_uint num_events_in_wait_list , - const cl_event * event_wait_list , - cl_event * event) CL_API_SUFFIX__VERSION_1_1 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clEnqueueReadBufferRect(%p, %p, %u, %p, %p, %p, %u, %u, %u, %u, %p, %u, %p, %p)\n", - command_queue, - buffer, - blocking_read, - buffer_origin, - host_origin, - region, - buffer_row_pitch, - buffer_slice_pitch, - host_row_pitch, - host_slice_pitch, - ptr, - num_events_in_wait_list, - event_wait_list, - event); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueWriteBuffer(cl_command_queue command_queue , - cl_mem buffer , - cl_bool blocking_write , - size_t offset , - size_t cb , - const void * ptr , - cl_uint num_events_in_wait_list , - const cl_event * event_wait_list , - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clEnqueueWriteBuffer(%p, %p, %u, %u, %u, %p, %u, %p, %p)\n", - command_queue, - buffer, - blocking_write, - offset, - cb, - ptr, - num_events_in_wait_list, - event_wait_list, - event); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueWriteBufferRect(cl_command_queue command_queue , - cl_mem buffer , - cl_bool blocking_write , - const size_t * buffer_origin , - const size_t * host_origin , - const size_t * region , - size_t buffer_row_pitch , - size_t buffer_slice_pitch , - size_t host_row_pitch , - size_t host_slice_pitch , - const void * ptr , - cl_uint num_events_in_wait_list , - const cl_event * event_wait_list , - cl_event * event) CL_API_SUFFIX__VERSION_1_1 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clEnqueueWriteBufferRect(%p, %p, %u, %p, %p, %p, %u, %u, %u, %u, %p, %u, %p, %p)\n", - command_queue, - buffer, - blocking_write, - buffer_origin, - host_origin, - region, - buffer_row_pitch, - buffer_slice_pitch, - host_row_pitch, - host_slice_pitch, - ptr, - num_events_in_wait_list, - event_wait_list, - event); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueCopyBuffer(cl_command_queue command_queue , - cl_mem src_buffer , - cl_mem dst_buffer , - size_t src_offset , - size_t dst_offset , - size_t cb , - cl_uint num_events_in_wait_list , - const cl_event * event_wait_list , - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clEnqueueCopyBuffer(%p, %p, %p, %u, %u, %u, %u, %p, %p)\n", - command_queue, - src_buffer, - dst_buffer, - src_offset, - dst_offset, - cb, - num_events_in_wait_list, - event_wait_list, - event); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueCopyBufferRect(cl_command_queue command_queue , - cl_mem src_buffer , - cl_mem dst_buffer , - const size_t * src_origin , - const size_t * dst_origin , - const size_t * region , - size_t src_row_pitch , - size_t src_slice_pitch , - size_t dst_row_pitch , - size_t dst_slice_pitch , - cl_uint num_events_in_wait_list , - const cl_event * event_wait_list , - cl_event * event) CL_API_SUFFIX__VERSION_1_1 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clEnqueueCopyBufferRect(%p, %p, %p, %p, %p, %p, %u, %u, %u, %u, %u, %p, %p)\n", - command_queue, - src_buffer, - dst_buffer, - src_origin, - dst_origin, - region, - src_row_pitch, - src_slice_pitch, - dst_row_pitch, - dst_slice_pitch, - num_events_in_wait_list, - event_wait_list, - event); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueFillBuffer(cl_command_queue command_queue , - cl_mem buffer , - const void * pattern , - size_t pattern_size , - size_t offset , - size_t cb , - cl_uint num_events_in_wait_list , - const cl_event * event_wait_list , - cl_event * event) CL_API_SUFFIX__VERSION_1_2 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clEnqueueFillBuffer(%p, %p, %p, %u, %u, %u, %u, %p, %p)\n", - command_queue, - buffer, - pattern, - pattern_size, - offset, - cb, - num_events_in_wait_list, - event_wait_list, - event); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueFillImage(cl_command_queue command_queue , - cl_mem image , - const void * fill_color , - const size_t * origin , - const size_t * region , - cl_uint num_events_in_wait_list , - const cl_event * event_wait_list , - cl_event * event) CL_API_SUFFIX__VERSION_1_2 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clEnqueueFillImage(%p, %p, %p, %p, %p, %u, %p, %p)\n", - command_queue, - image, - fill_color, - origin, - region, - num_events_in_wait_list, - event_wait_list, - event); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReadImage(cl_command_queue command_queue , - cl_mem image , - cl_bool blocking_read , - const size_t * origin , - const size_t * region , - size_t row_pitch , - size_t slice_pitch , - void * ptr , - cl_uint num_events_in_wait_list , - const cl_event * event_wait_list , - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clEnqueueReadImage(%p, %p, %u, %p, %p, %u, %u, %p, %u, %p, %p)\n", - command_queue, - image, - blocking_read, - origin, - region, - row_pitch, - slice_pitch, - ptr, - num_events_in_wait_list, - event_wait_list, - event); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueWriteImage(cl_command_queue command_queue , - cl_mem image , - cl_bool blocking_write , - const size_t * origin , - const size_t * region , - size_t input_row_pitch , - size_t input_slice_pitch , - const void * ptr , - cl_uint num_events_in_wait_list , - const cl_event * event_wait_list , - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clEnqueueWriteImage(%p, %p, %u, %p, %p, %u, %u, %p, %u, %p, %p)\n", - command_queue, - image, - blocking_write, - origin, - region, - input_row_pitch, - input_slice_pitch, - ptr, - num_events_in_wait_list, - event_wait_list, - event); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueCopyImage(cl_command_queue command_queue , - cl_mem src_image , - cl_mem dst_image , - const size_t * src_origin , - const size_t * dst_origin , - const size_t * region , - cl_uint num_events_in_wait_list , - const cl_event * event_wait_list , - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clEnqueueCopyImage(%p, %p, %p, %p, %p, %p, %u, %p, %p)\n", - command_queue, - src_image, - dst_image, - src_origin, - dst_origin, - region, - num_events_in_wait_list, - event_wait_list , - event); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueCopyImageToBuffer(cl_command_queue command_queue , - cl_mem src_image , - cl_mem dst_buffer , - const size_t * src_origin , - const size_t * region , - size_t dst_offset , - cl_uint num_events_in_wait_list , - const cl_event * event_wait_list , - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clEnqueueCopyImageToBuffer(%p, %p, %p, %p, %p, %u, %u, %p, %p)\n", - command_queue, - src_image, - dst_buffer, - src_origin, - region, - dst_offset, - num_events_in_wait_list, - event_wait_list, - event); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueCopyBufferToImage(cl_command_queue command_queue , - cl_mem src_buffer , - cl_mem dst_image , - size_t src_offset , - const size_t * dst_origin , - const size_t * region , - cl_uint num_events_in_wait_list , - const cl_event * event_wait_list , - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clEnqueueCopyBufferToImage(%p, %p, %p, %u, %p, %p, %u, %p, %p)\n", - command_queue, - src_buffer, - dst_image, - src_offset, - dst_origin, - region, - num_events_in_wait_list, - event_wait_list, - event); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY void * CL_API_CALL -clEnqueueMapBuffer(cl_command_queue command_queue , - cl_mem buffer , - cl_bool blocking_map , - cl_map_flags map_flags , - size_t offset , - size_t cb , - cl_uint num_events_in_wait_list , - const cl_event * event_wait_list , - cl_event * event , - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - void *return_value = (void *) malloc(sizeof(void *)); - test_icd_stub_log("clEnqueueMapBuffer(%p, %p, %u, %x, %u, %u, %u, %p, %p, %p)\n", - command_queue, - buffer, - blocking_map, - map_flags, - offset, - cb, - num_events_in_wait_list, - event_wait_list, - event, - errcode_ret); - - test_icd_stub_log("Value returned: %p\n", return_value); - return return_value; -} - -CL_API_ENTRY void * CL_API_CALL -clEnqueueMapImage(cl_command_queue command_queue , - cl_mem image , - cl_bool blocking_map , - cl_map_flags map_flags , - const size_t * origin , - const size_t * region , - size_t * image_row_pitch , - size_t * image_slice_pitch , - cl_uint num_events_in_wait_list , - const cl_event * event_wait_list , - cl_event * event , - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - void *return_value = (void *) malloc(sizeof(void *)); - test_icd_stub_log("clEnqueueMapImage(%p, %p, %u, %x, %p, %p, %p, %p, %u, %p, %p, %p)\n", - command_queue, - image, - blocking_map, - map_flags, - origin, - region, - image_row_pitch, - image_slice_pitch, - num_events_in_wait_list, - event_wait_list, - event, - errcode_ret); - - test_icd_stub_log("Value returned: %p\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueUnmapMemObject(cl_command_queue command_queue , - cl_mem memobj , - void * mapped_ptr , - cl_uint num_events_in_wait_list , - const cl_event * event_wait_list , - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clEnqueueUnmapMemObject(%p, %p, %p, %u, %p, %p)\n", - command_queue, - memobj, - mapped_ptr, - num_events_in_wait_list, - event_wait_list, - event); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueMigrateMemObjects(cl_command_queue command_queue , - cl_uint num_mem_objects , - const cl_mem * mem_objects , - cl_mem_migration_flags flags , - cl_uint num_events_in_wait_list , - const cl_event * event_wait_list , - cl_event * event) CL_API_SUFFIX__VERSION_1_2 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clEnqueueMigrateMemObjects(%p, %u, %p, %x, %u, %p, %p)\n", - command_queue, - num_mem_objects, - mem_objects, - flags, - num_events_in_wait_list, - event_wait_list, - event); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueNDRangeKernel(cl_command_queue command_queue , - cl_kernel kernel , - cl_uint work_dim , - const size_t * global_work_offset , - const size_t * global_work_size , - const size_t * local_work_size , - cl_uint num_events_in_wait_list , - const cl_event * event_wait_list , - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clEnqueueNDRangeKernel(%p, %p, %u, %p, %p, %p, %u, %p, %p)\n", - command_queue, - kernel, - work_dim, - global_work_offset, - global_work_size, - local_work_size, - num_events_in_wait_list, - event_wait_list, - event); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueTask(cl_command_queue command_queue , - cl_kernel kernel , - cl_uint num_events_in_wait_list , - const cl_event * event_wait_list , - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clEnqueueTask(%p, %p, %u, %p, %p)\n", - command_queue, - kernel, - num_events_in_wait_list, - event_wait_list, - event); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueNativeKernel(cl_command_queue command_queue , - void (CL_CALLBACK *user_func)(void *), - void * args , - size_t cb_args , - cl_uint num_mem_objects , - const cl_mem * mem_list , - const void ** args_mem_loc , - cl_uint num_events_in_wait_list , - const cl_event * event_wait_list , - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clEnqueueNativeKernel(%p, %p, %p, %u, %u, %p, %p, %u, %p, %p)\n", - command_queue, - user_func, - args, - cb_args, - num_mem_objects, - mem_list, - args_mem_loc, - num_events_in_wait_list, - event_wait_list, - event); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY void * CL_API_CALL -clGetExtensionFunctionAddressForPlatform(cl_platform_id platform , - const char * func_name) CL_API_SUFFIX__VERSION_1_2 -{ - void *return_value = (void *) malloc(sizeof(void *)); - test_icd_stub_log("clGetExtensionFunctionAddressForPlatform(%p, %p)\n", - platform, - func_name); - - test_icd_stub_log("Value returned: %p\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueMarkerWithWaitList(cl_command_queue command_queue , - cl_uint num_events_in_wait_list , - const cl_event * event_wait_list , - cl_event * event) CL_API_SUFFIX__VERSION_1_2 - -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clEnqueueMarkerWithWaitList(%p, %u, %p, %p)\n", - command_queue, - num_events_in_wait_list, - event_wait_list, - event); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueBarrierWithWaitList(cl_command_queue command_queue , - cl_uint num_events_in_wait_list , - const cl_event * event_wait_list , - cl_event * event) CL_API_SUFFIX__VERSION_1_2 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clEnqueueBarrierWithWaitList(%p, %u, %p, %p)\n", - command_queue, - num_events_in_wait_list, - event_wait_list, - event); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -extern CL_API_ENTRY cl_int CL_API_CALL -clSetPrintfCallback(cl_context context , - void (CL_CALLBACK * pfn_notify)(cl_context program , - cl_uint printf_data_len , - char * printf_data_ptr , - void * user_data), - void * user_data) CL_API_SUFFIX__VERSION_1_2 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clSetPrintfCallback(%p, %p, %p)\n", - context, - pfn_notify, - user_data); - pfn_notify(context, 0, NULL, NULL); - test_icd_stub_log("setprintf_callback(%p, %u, %p, %p)\n", - context, - 0, - NULL, - NULL); - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueMarker(cl_command_queue command_queue , - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clEnqueueMarker(%p, %p)\n", command_queue, event); - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueWaitForEvents(cl_command_queue command_queue , - cl_uint num_events , - const cl_event * event_list) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clEnqueueWaitForEvents(%p, %u, %p)\n", - command_queue, - num_events, - event_list); - - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueBarrier(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clEnqueueBarrier(%p)\n", command_queue); - test_icd_stub_log("Value returned: %d\n", return_value); - return return_value; -} - -extern cl_int cliIcdDispatchTableCreate(CLIicdDispatchTable **outDispatchTable); - -CL_API_ENTRY cl_int CL_API_CALL -clIcdGetPlatformIDsKHR(cl_uint num_entries, - cl_platform_id * platforms, - cl_uint * num_platforms) -{ - cl_int result = CL_SUCCESS; - if (!initialized) { - result = cliIcdDispatchTableCreate(&dispatchTable); - platform = (cl_platform_id) malloc(sizeof(struct _cl_platform_id)); - memset(platform, 0, sizeof(struct _cl_platform_id)); - - platform->dispatch = dispatchTable; - platform->version = "OpenCL 1.2 Stub"; - platform->vendor = "stubvendorxxx"; - platform->profile = "stubprofilexxx"; - platform->name = "ICD_LOADER_TEST_OPENCL_STUB"; - platform->extensions = "cl_khr_icd cl_khr_gl cl_khr_d3d10"; - platform->suffix = "ilts"; - platform->dispatch = dispatchTable; - initialized = CL_TRUE; - } - - if ((platforms && num_entries >1) || - (platforms && num_entries <= 0) || - (!platforms && num_entries >= 1)) { - result = CL_INVALID_VALUE; - goto Done; - } - - if (platforms && num_entries == 1) { - platforms[0] = platform; - } - -Done: - if (num_platforms) { - *num_platforms = 1; - } - - return result; -} - diff --git a/khronos_icd/test/driver_stub/cl_ext.c b/khronos_icd/test/driver_stub/cl_ext.c deleted file mode 100644 index ece0c591b..000000000 --- a/khronos_icd/test/driver_stub/cl_ext.c +++ /dev/null @@ -1,35 +0,0 @@ -#include - -#define CL_USE_DEPRECATED_OPENCL_1_1_APIS -#include "CL/cl.h" -#include "CL/cl_ext.h" - -struct driverStubextFunc_st -{ - const char *name; - void *func; -}; - -#define EXT_FUNC(name) { #name, (void*)(name) } - -static struct driverStubextFunc_st clExtensions[] = -{ - EXT_FUNC(clIcdGetPlatformIDsKHR), -}; - -static const int clExtensionCount = sizeof(clExtensions) / sizeof(clExtensions[0]); - -CL_API_ENTRY void * CL_API_CALL -clGetExtensionFunctionAddress(const char *name) -{ - int ii; - - for (ii = 0; ii < clExtensionCount; ii++) { - if (!strcmp(name, clExtensions[ii].name)) { - return clExtensions[ii].func; - } - } - - return NULL; -} - diff --git a/khronos_icd/test/driver_stub/cl_gl.c b/khronos_icd/test/driver_stub/cl_gl.c deleted file mode 100644 index 3cc5cbb80..000000000 --- a/khronos_icd/test/driver_stub/cl_gl.c +++ /dev/null @@ -1,221 +0,0 @@ -#include -#include -#include - -// Need to rename all CL API functions to prevent ICD loader functions calling -// themselves via the dispatch table. Include this before cl headers. -#include "rename_api.h" - -#define SIZE_T_MAX (size_t) 0xFFFFFFFFFFFFFFFFULL - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromGLBuffer(cl_context context , - cl_mem_flags flags , - cl_GLuint bufret_mem , - int * errcode_ret ) CL_API_SUFFIX__VERSION_1_0 -{ - cl_mem ret_mem = (cl_mem)(SIZE_T_MAX); - test_icd_stub_log("clCreateFromGLBuffer(%p, %x, %u, %p)\n", - context, - flags, - bufret_mem, - errcode_ret); - test_icd_stub_log("Value returned: %p\n", - ret_mem); - return ret_mem; -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromGLTexture(cl_context context , - cl_mem_flags flags , - cl_GLenum target , - cl_GLint miplevel , - cl_GLuint texture , - cl_int * errcode_ret ) CL_API_SUFFIX__VERSION_1_2 -{ - cl_mem ret_mem = (cl_mem)(SIZE_T_MAX); - test_icd_stub_log("clCreateFromGLTexture(%p, %x, %d, %d, %u, %p)\n", - context , - flags , - target , - miplevel , - texture , - errcode_ret ); - test_icd_stub_log("Value returned: %p\n", - ret_mem); - return ret_mem; -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromGLTexture2D(cl_context context, - cl_mem_flags flags, - cl_GLenum target, - cl_GLint miplevel, - cl_GLuint texture, - cl_int * errcode_ret ) CL_API_SUFFIX__VERSION_1_0 -{ - cl_mem ret_mem = (cl_mem)(SIZE_T_MAX); - test_icd_stub_log("clCreateFromGLTexture2D(%p, %x, %d, %d, %u, %p)\n", - context, - flags, - target, - miplevel, - texture, - errcode_ret ); - test_icd_stub_log("Value returned: %p\n", - ret_mem); - return ret_mem; -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromGLTexture3D(cl_context context, - cl_mem_flags flags, - cl_GLenum target, - cl_GLint miplevel, - cl_GLuint texture, - cl_int * errcode_ret ) CL_API_SUFFIX__VERSION_1_0 - -{ - cl_mem ret_mem = (cl_mem)(SIZE_T_MAX); - test_icd_stub_log("clCreateFromGLTexture3D(%p, %x, %d, %d, %u, %p)\n", - context, - flags, - target, - miplevel, - texture, - errcode_ret ); - test_icd_stub_log("Value returned: %p\n", - ret_mem); - return ret_mem; -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromGLRenderbuffer(cl_context context, - cl_mem_flags flags, - cl_GLuint renderbuffer, - cl_int * errcode_ret ) CL_API_SUFFIX__VERSION_1_0 -{ - cl_mem ret_mem = (cl_mem)(SIZE_T_MAX); - test_icd_stub_log("clCreateFromGLRenderbuffer(%p, %x, %d, %p)\n", - context, - flags, - renderbuffer, - errcode_ret); - test_icd_stub_log("Value returned: %p\n", - ret_mem); - return ret_mem; -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetGLObjectInfo(cl_mem memobj, - cl_gl_object_type * gl_object_type, - cl_GLuint * gl_object_name ) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int ret_val = -5; - test_icd_stub_log("clGetGLObjectInfo(%p, %p, %p)\n", - memobj, - gl_object_type, - gl_object_name); - test_icd_stub_log("Value returned: %p\n", - ret_val); - return ret_val; -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetGLTextureInfo(cl_mem memobj, - cl_gl_texture_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret ) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int ret_val = -5; - test_icd_stub_log("clGetGLTextureInfo(%p, %u, %u, %p, %p)\n", - memobj, - param_name, - param_value_size, - param_value, - param_value_size_ret ); - test_icd_stub_log("Value returned: %p\n", - ret_val); - return ret_val; -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueAcquireGLObjects(cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event ) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int ret_val = -5; - test_icd_stub_log("clEnqueueAcquireGLObjects(%p, %u, %p, %u, %p, %p)\n", - command_queue, - num_objects, - mem_objects, - num_events_in_wait_list, - event_wait_list, - event); - - test_icd_stub_log("Value returned: %p\n", - ret_val); - return ret_val; -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReleaseGLObjects(cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event ) CL_API_SUFFIX__VERSION_1_0 - -{ - cl_int ret_val = -5; - test_icd_stub_log("clEnqueueReleaseGLObjects(%p, %u, %p, %u, %p, %p)\n", - command_queue, - num_objects, - mem_objects, - num_events_in_wait_list, - event_wait_list, - event); - test_icd_stub_log("Value returned: %p\n", - ret_val); - return ret_val; -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetGLContextInfoKHR(const cl_context_properties * properties, - cl_gl_context_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret ) CL_API_SUFFIX__VERSION_1_0 -{ - cl_int ret_val = -5; - test_icd_stub_log("clGetGLContextInfoKHR(%p, %u, %u, %p, %p)\n", - properties, - param_name, - param_value_size, - param_value, - param_value_size_ret); - - test_icd_stub_log("Value returned: %p\n", - ret_val); - return ret_val; -} - -CL_API_ENTRY cl_event CL_API_CALL -clCreateEventFromGLsyncKHR(cl_context context , - cl_GLsync cl_GLsync , - cl_int * errcode_ret ) CL_EXT_SUFFIX__VERSION_1_1 - -{ - cl_event ret_event = (cl_event)(SIZE_T_MAX); - test_icd_stub_log("clCreateEventFromGLsyncKHR(%p, %p, %p)\n", - context, - cl_GLsync, - errcode_ret); - test_icd_stub_log("Value returned: %p\n", - ret_event); - return ret_event; -} diff --git a/khronos_icd/test/driver_stub/driver_stub.def b/khronos_icd/test/driver_stub/driver_stub.def deleted file mode 100644 index 5b238e8e1..000000000 --- a/khronos_icd/test/driver_stub/driver_stub.def +++ /dev/null @@ -1,3 +0,0 @@ -EXPORTS -clGetExtensionFunctionAddress -clIcdGetPlatformIDsKHR diff --git a/khronos_icd/test/driver_stub/icd.c b/khronos_icd/test/driver_stub/icd.c deleted file mode 100644 index e456e431a..000000000 --- a/khronos_icd/test/driver_stub/icd.c +++ /dev/null @@ -1,185 +0,0 @@ -#include -#include -#include -#include -#include "icd_structs.h" - -#define CL_USE_DEPRECATED_OPENCL_1_1_APIS -#define CL_USE_DEPRECATED_OPENCL_1_0_APIS - -// Need to rename all CL API functions to prevent ICD loader functions calling -// themselves via the dispatch table. Include this before cl headers. -#include "rename_api.h" - -#include "CL/cl.h" -#include "CL/cl_gl.h" -#include "CL/cl_gl_ext.h" - -/* - * Prototypes for deprecated functions no longer present in cl.h - */ -extern CL_API_ENTRY cl_int CL_API_CALL -clSetCommandQueueProperty(cl_command_queue /* command_queue */, - cl_command_queue_properties /* properties */, - cl_bool /* enable */, - cl_command_queue_properties * /* old_properties */); - -#define ICD_DISPATCH_TABLE_ENTRY(fn) \ - assert(dispatchTable->entryCount < 256); \ - dispatchTable->entries[dispatchTable->entryCount++] = (void*)(fn) - -cl_int cliIcdDispatchTableCreate(CLIicdDispatchTable **outDispatchTable) -{ - CLIicdDispatchTable *dispatchTable = NULL; - cl_int result = CL_SUCCESS; - - // allocate the public handle - dispatchTable = (CLIicdDispatchTable *) malloc(sizeof(*dispatchTable)); - if (!dispatchTable) { - result = CL_OUT_OF_HOST_MEMORY; - goto Error; - } - memset(dispatchTable, 0, sizeof(*dispatchTable)); - - // OpenCL 1.0 - ICD_DISPATCH_TABLE_ENTRY ( clGetPlatformIDs ); - ICD_DISPATCH_TABLE_ENTRY ( clGetPlatformInfo ); - ICD_DISPATCH_TABLE_ENTRY ( clGetDeviceIDs ); - ICD_DISPATCH_TABLE_ENTRY ( clGetDeviceInfo ); - ICD_DISPATCH_TABLE_ENTRY ( clCreateContext ); - ICD_DISPATCH_TABLE_ENTRY ( clCreateContextFromType ); - ICD_DISPATCH_TABLE_ENTRY ( clRetainContext ); - ICD_DISPATCH_TABLE_ENTRY ( clReleaseContext ); - ICD_DISPATCH_TABLE_ENTRY ( clGetContextInfo ); - ICD_DISPATCH_TABLE_ENTRY ( clCreateCommandQueue ); - ICD_DISPATCH_TABLE_ENTRY ( clRetainCommandQueue ); - ICD_DISPATCH_TABLE_ENTRY ( clReleaseCommandQueue ); - ICD_DISPATCH_TABLE_ENTRY ( clGetCommandQueueInfo ); - ICD_DISPATCH_TABLE_ENTRY ( clSetCommandQueueProperty ); - ICD_DISPATCH_TABLE_ENTRY ( clCreateBuffer ); - ICD_DISPATCH_TABLE_ENTRY ( clCreateImage2D ); - ICD_DISPATCH_TABLE_ENTRY ( clCreateImage3D ); - ICD_DISPATCH_TABLE_ENTRY ( clRetainMemObject ); - ICD_DISPATCH_TABLE_ENTRY ( clReleaseMemObject ); - ICD_DISPATCH_TABLE_ENTRY ( clGetSupportedImageFormats ); - ICD_DISPATCH_TABLE_ENTRY ( clGetMemObjectInfo ); - ICD_DISPATCH_TABLE_ENTRY ( clGetImageInfo ); - ICD_DISPATCH_TABLE_ENTRY ( clCreateSampler ); - ICD_DISPATCH_TABLE_ENTRY ( clRetainSampler ); - ICD_DISPATCH_TABLE_ENTRY ( clReleaseSampler ); - ICD_DISPATCH_TABLE_ENTRY ( clGetSamplerInfo ); - ICD_DISPATCH_TABLE_ENTRY ( clCreateProgramWithSource ); - ICD_DISPATCH_TABLE_ENTRY ( clCreateProgramWithBinary ); - ICD_DISPATCH_TABLE_ENTRY ( clRetainProgram ); - ICD_DISPATCH_TABLE_ENTRY ( clReleaseProgram ); - ICD_DISPATCH_TABLE_ENTRY ( clBuildProgram ); - ICD_DISPATCH_TABLE_ENTRY ( clUnloadCompiler ); - ICD_DISPATCH_TABLE_ENTRY ( clGetProgramInfo ); - ICD_DISPATCH_TABLE_ENTRY ( clGetProgramBuildInfo ); - ICD_DISPATCH_TABLE_ENTRY ( clCreateKernel ); - ICD_DISPATCH_TABLE_ENTRY ( clCreateKernelsInProgram ); - ICD_DISPATCH_TABLE_ENTRY ( clRetainKernel ); - ICD_DISPATCH_TABLE_ENTRY ( clReleaseKernel ); - ICD_DISPATCH_TABLE_ENTRY ( clSetKernelArg ); - ICD_DISPATCH_TABLE_ENTRY ( clGetKernelInfo ); - ICD_DISPATCH_TABLE_ENTRY ( clGetKernelWorkGroupInfo ); - ICD_DISPATCH_TABLE_ENTRY ( clWaitForEvents ); - ICD_DISPATCH_TABLE_ENTRY ( clGetEventInfo ); - ICD_DISPATCH_TABLE_ENTRY ( clRetainEvent ); - ICD_DISPATCH_TABLE_ENTRY ( clReleaseEvent ); - ICD_DISPATCH_TABLE_ENTRY ( clGetEventProfilingInfo ); - ICD_DISPATCH_TABLE_ENTRY ( clFlush ); - ICD_DISPATCH_TABLE_ENTRY ( clFinish ); - ICD_DISPATCH_TABLE_ENTRY ( clEnqueueReadBuffer ); - ICD_DISPATCH_TABLE_ENTRY ( clEnqueueWriteBuffer ); - ICD_DISPATCH_TABLE_ENTRY ( clEnqueueCopyBuffer ); - ICD_DISPATCH_TABLE_ENTRY ( clEnqueueReadImage ); - ICD_DISPATCH_TABLE_ENTRY ( clEnqueueWriteImage ); - ICD_DISPATCH_TABLE_ENTRY ( clEnqueueCopyImage ); - ICD_DISPATCH_TABLE_ENTRY ( clEnqueueCopyImageToBuffer ); - ICD_DISPATCH_TABLE_ENTRY ( clEnqueueCopyBufferToImage ); - ICD_DISPATCH_TABLE_ENTRY ( clEnqueueMapBuffer ); - ICD_DISPATCH_TABLE_ENTRY ( clEnqueueMapImage ); - ICD_DISPATCH_TABLE_ENTRY ( clEnqueueUnmapMemObject ); - ICD_DISPATCH_TABLE_ENTRY ( clEnqueueNDRangeKernel ); - ICD_DISPATCH_TABLE_ENTRY ( clEnqueueTask ); - ICD_DISPATCH_TABLE_ENTRY ( clEnqueueNativeKernel ); - ICD_DISPATCH_TABLE_ENTRY ( clEnqueueMarker ); - ICD_DISPATCH_TABLE_ENTRY ( clEnqueueWaitForEvents ); - ICD_DISPATCH_TABLE_ENTRY ( clEnqueueBarrier ); - ICD_DISPATCH_TABLE_ENTRY ( clGetExtensionFunctionAddress ); - ICD_DISPATCH_TABLE_ENTRY ( clCreateFromGLBuffer ); - ICD_DISPATCH_TABLE_ENTRY ( clCreateFromGLTexture2D ); - ICD_DISPATCH_TABLE_ENTRY ( clCreateFromGLTexture3D ); - ICD_DISPATCH_TABLE_ENTRY ( clCreateFromGLRenderbuffer ); - ICD_DISPATCH_TABLE_ENTRY ( clGetGLObjectInfo ); - ICD_DISPATCH_TABLE_ENTRY ( clGetGLTextureInfo ); - ICD_DISPATCH_TABLE_ENTRY ( clEnqueueAcquireGLObjects ); - ICD_DISPATCH_TABLE_ENTRY ( clEnqueueReleaseGLObjects ); - - // cl_khr_gl_sharing - ICD_DISPATCH_TABLE_ENTRY ( clGetGLContextInfoKHR ); - - // cl_khr_d3d10_sharing (windows-only) -#if 0 && defined(_WIN32) - ICD_DISPATCH_TABLE_ENTRY ( clGetDeviceIDsFromD3D10KHR ); - ICD_DISPATCH_TABLE_ENTRY ( clCreateFromD3D10BufferKHR ); - ICD_DISPATCH_TABLE_ENTRY ( clCreateFromD3D10Texture2DKHR ); - ICD_DISPATCH_TABLE_ENTRY ( clCreateFromD3D10Texture3DKHR ); - ICD_DISPATCH_TABLE_ENTRY ( clEnqueueAcquireD3D10ObjectsKHR ); - ICD_DISPATCH_TABLE_ENTRY ( clEnqueueReleaseD3D10ObjectsKHR ); -#else - ICD_DISPATCH_TABLE_ENTRY( NULL ); - ICD_DISPATCH_TABLE_ENTRY( NULL ); - ICD_DISPATCH_TABLE_ENTRY( NULL ); - ICD_DISPATCH_TABLE_ENTRY( NULL ); - ICD_DISPATCH_TABLE_ENTRY( NULL ); - ICD_DISPATCH_TABLE_ENTRY( NULL ); -#endif - - // OpenCL 1.1 - ICD_DISPATCH_TABLE_ENTRY ( clSetEventCallback); - ICD_DISPATCH_TABLE_ENTRY ( clCreateSubBuffer); - ICD_DISPATCH_TABLE_ENTRY ( clSetMemObjectDestructorCallback); - ICD_DISPATCH_TABLE_ENTRY ( clCreateUserEvent); - ICD_DISPATCH_TABLE_ENTRY ( clSetUserEventStatus); - ICD_DISPATCH_TABLE_ENTRY ( clEnqueueReadBufferRect); - ICD_DISPATCH_TABLE_ENTRY ( clEnqueueWriteBufferRect); - ICD_DISPATCH_TABLE_ENTRY ( clEnqueueCopyBufferRect); - - ICD_DISPATCH_TABLE_ENTRY ( /*clCreateSubDevicesEXT*/NULL); - ICD_DISPATCH_TABLE_ENTRY ( /*clRetainDeviceEXT*/ NULL); - ICD_DISPATCH_TABLE_ENTRY ( /*clReleaseDevice*/NULL); - - ICD_DISPATCH_TABLE_ENTRY ( clCreateEventFromGLsyncKHR); - - ICD_DISPATCH_TABLE_ENTRY ( clCreateSubDevices); - ICD_DISPATCH_TABLE_ENTRY ( clRetainDevice); - ICD_DISPATCH_TABLE_ENTRY ( clReleaseDevice); - ICD_DISPATCH_TABLE_ENTRY ( clCreateImage); - ICD_DISPATCH_TABLE_ENTRY ( clCreateProgramWithBuiltInKernels); - ICD_DISPATCH_TABLE_ENTRY ( clCompileProgram); - ICD_DISPATCH_TABLE_ENTRY ( clLinkProgram); - ICD_DISPATCH_TABLE_ENTRY ( clUnloadPlatformCompiler); - ICD_DISPATCH_TABLE_ENTRY ( clGetKernelArgInfo); - ICD_DISPATCH_TABLE_ENTRY ( clEnqueueFillBuffer); - ICD_DISPATCH_TABLE_ENTRY ( clEnqueueFillImage); - ICD_DISPATCH_TABLE_ENTRY ( clEnqueueMigrateMemObjects); - ICD_DISPATCH_TABLE_ENTRY ( clEnqueueMarkerWithWaitList); - ICD_DISPATCH_TABLE_ENTRY ( clEnqueueBarrierWithWaitList); - ICD_DISPATCH_TABLE_ENTRY ( clGetExtensionFunctionAddressForPlatform); - ICD_DISPATCH_TABLE_ENTRY ( clCreateFromGLTexture); - - // return success - *outDispatchTable = dispatchTable; - return CL_SUCCESS; - -Error: - return result; -} - -void -cliIcdDispatchTableDestroy(CLIicdDispatchTable *dispatchTable) -{ - free(dispatchTable); -} diff --git a/khronos_icd/test/driver_stub/icd_driver_exports.map b/khronos_icd/test/driver_stub/icd_driver_exports.map deleted file mode 100644 index c6386a26e..000000000 --- a/khronos_icd/test/driver_stub/icd_driver_exports.map +++ /dev/null @@ -1,8 +0,0 @@ -{ - global: -clGetExtensionFunctionAddress; -clGetPlatformInfo; - - local: - *; -}; diff --git a/khronos_icd/test/driver_stub/icd_structs.h b/khronos_icd/test/driver_stub/icd_structs.h deleted file mode 100644 index 4b7e68b11..000000000 --- a/khronos_icd/test/driver_stub/icd_structs.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef _ICD_STRUCTS_H_ -#define _ICD_STRUCTS_H_ - -typedef struct CLIicdDispatchTable_st CLIicdDispatchTable; -typedef struct CLIplatform_st CLIplatform; - -struct CLIicdDispatchTable_st -{ - void *entries[256]; - int entryCount; -}; - -struct CLIplatform_st -{ - CLIicdDispatchTable* dispatch; -}; - -#endif /* _ICD_STRUCTS_H_ */ diff --git a/khronos_icd/test/driver_stub/rename_api.h b/khronos_icd/test/driver_stub/rename_api.h deleted file mode 100644 index 7d5130cec..000000000 --- a/khronos_icd/test/driver_stub/rename_api.h +++ /dev/null @@ -1,106 +0,0 @@ -#ifndef _RENAME_API_H_ -#define _RENAME_API_H_ - -#define clGetPlatformIDs ___clGetPlatformIDs -#define clGetPlatformInfo ___clGetPlatformInfo -#define clGetDeviceIDs ___clGetDeviceIDs -#define clGetDeviceInfo ___clGetDeviceInfo -#define clCreateSubDevices ___clCreateSubDevices -#define clRetainDevice ___clRetainDevice -#define clReleaseDevice ___clReleaseDevice -#define clCreateContext ___clCreateContext -#define clCreateContextFromType ___clCreateContextFromType -#define clRetainContext ___clRetainContext -#define clReleaseContext ___clReleaseContext -#define clGetContextInfo ___clGetContextInfo -#define clCreateCommandQueue ___clCreateCommandQueue -#define clSetCommandQueueProperty ___clSetCommandQueueProperty -#define clRetainCommandQueue ___clRetainCommandQueue -#define clReleaseCommandQueue ___clReleaseCommandQueue -#define clGetCommandQueueInfo ___clGetCommandQueueInfo -#define clCreateBuffer ___clCreateBuffer -#define clCreateSubBuffer ___clCreateSubBuffer -#define clCreateImage ___clCreateImage -#define clCreateImage2D ___clCreateImage2D -#define clCreateImage3D ___clCreateImage3D -#define clRetainMemObject ___clRetainMemObject -#define clReleaseMemObject ___clReleaseMemObject -#define clGetSupportedImageFormats ___clGetSupportedImageFormats -#define clGetMemObjectInfo ___clGetMemObjectInfo -#define clGetImageInfo ___clGetImageInfo -#define clSetMemObjectDestructorCallback ___clSetMemObjectDestructorCallback -#define clCreateSampler ___clCreateSampler -#define clRetainSampler ___clRetainSampler -#define clReleaseSampler ___clReleaseSampler -#define clGetSamplerInfo ___clGetSamplerInfo -#define clCreateProgramWithSource ___clCreateProgramWithSource -#define clCreateProgramWithBinary ___clCreateProgramWithBinary -#define clCreateProgramWithBuiltInKernels ___clCreateProgramWithBuiltInKernels -#define clRetainProgram ___clRetainProgram -#define clReleaseProgram ___clReleaseProgram -#define clBuildProgram ___clBuildProgram -#define clUnloadCompiler ___clUnloadCompiler -#define clCompileProgram ___clCompileProgram -#define clLinkProgram ___clLinkProgram -#define clUnloadPlatformCompiler ___clUnloadPlatformCompiler -#define clGetProgramInfo ___clGetProgramInfo -#define clGetProgramBuildInfo ___clGetProgramBuildInfo -#define clCreateKernel ___clCreateKernel -#define clCreateKernelsInProgram ___clCreateKernelsInProgram -#define clRetainKernel ___clRetainKernel -#define clReleaseKernel ___clReleaseKernel -#define clSetKernelArg ___clSetKernelArg -#define clGetKernelInfo ___clGetKernelInfo -#define clGetKernelArgInfo ___clGetKernelArgInfo -#define clGetKernelWorkGroupInfo ___clGetKernelWorkGroupInfo -#define clWaitForEvents ___clWaitForEvents -#define clGetEventInfo ___clGetEventInfo -#define clCreateUserEvent ___clCreateUserEvent -#define clRetainEvent ___clRetainEvent -#define clReleaseEvent ___clReleaseEvent -#define clSetUserEventStatus ___clSetUserEventStatus -#define clSetEventCallback ___clSetEventCallback -#define clGetEventProfilingInfo ___clGetEventProfilingInfo -#define clFlush ___clFlush -#define clFinish ___clFinish -#define clEnqueueReadBuffer ___clEnqueueReadBuffer -#define clEnqueueReadBufferRect ___clEnqueueReadBufferRect -#define clEnqueueWriteBuffer ___clEnqueueWriteBuffer -#define clEnqueueWriteBufferRect ___clEnqueueWriteBufferRect -#define clEnqueueCopyBuffer ___clEnqueueCopyBuffer -#define clEnqueueCopyBufferRect ___clEnqueueCopyBufferRect -#define clEnqueueFillBuffer ___clEnqueueFillBuffer -#define clEnqueueFillImage ___clEnqueueFillImage -#define clEnqueueReadImage ___clEnqueueReadImage -#define clEnqueueWriteImage ___clEnqueueWriteImage -#define clEnqueueCopyImage ___clEnqueueCopyImage -#define clEnqueueCopyImageToBuffer ___clEnqueueCopyImageToBuffer -#define clEnqueueCopyBufferToImage ___clEnqueueCopyBufferToImage -#define clEnqueueMapBuffer ___clEnqueueMapBuffer -#define clEnqueueMapImage ___clEnqueueMapImage -#define clEnqueueUnmapMemObject ___clEnqueueUnmapMemObject -#define clEnqueueMigrateMemObjects ___clEnqueueMigrateMemObjects -#define clEnqueueNDRangeKernel ___clEnqueueNDRangeKernel -#define clEnqueueTask ___clEnqueueTask -#define clEnqueueNativeKernel ___clEnqueueNativeKernel -#define clGetExtensionFunctionAddressForPlatform ___clGetExtensionFunctionAddressForPlatform -#define clEnqueueMarkerWithWaitList ___clEnqueueMarkerWithWaitList -#define clEnqueueBarrierWithWaitList ___clEnqueueBarrierWithWaitList -#define clSetPrintfCallback ___clSetPrintfCallback -#define clEnqueueMarker ___clEnqueueMarker -#define clEnqueueWaitForEvents ___clEnqueueWaitForEvents -#define clEnqueueBarrier ___clEnqueueBarrier - -#define clCreateFromGLBuffer ___clCreateFromGLBuffer -#define clCreateFromGLTexture ___clCreateFromGLTexture -#define clCreateFromGLTexture2D ___clCreateFromGLTexture2D -#define clCreateFromGLTexture3D ___clCreateFromGLTexture3D -#define clCreateFromGLRenderbuffer ___clCreateFromGLRenderbuffer -#define clGetGLObjectInfo ___clGetGLObjectInfo -#define clGetGLTextureInfo ___clGetGLTextureInfo -#define clEnqueueAcquireGLObjects ___clEnqueueAcquireGLObjects -#define clEnqueueReleaseGLObjects ___clEnqueueReleaseGLObjects -#define clGetGLContextInfoKHR ___clGetGLContextInfoKHR -#define clCreateEventFromGLsyncKHR ___clCreateEventFromGLsyncKHR - -#endif /* __RENAME_API_H__ */ diff --git a/khronos_icd/test/inc/platform/icd_test_log.h b/khronos_icd/test/inc/platform/icd_test_log.h deleted file mode 100644 index 6db0bfe6a..000000000 --- a/khronos_icd/test/inc/platform/icd_test_log.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef _ICD_TEST_LOG_H_ -#define _ICD_TEST_LOG_H_ - -#if defined (_WIN32) -#define DllExport __declspec( dllexport ) -#else -#define DllExport -#endif - -DllExport int test_icd_initialize_app_log(void); -DllExport void test_icd_app_log(const char *format, ...); -DllExport void test_icd_close_app_log(void); -DllExport char *test_icd_get_stub_log(void); - -DllExport int test_icd_initialize_stub_log(void); -DllExport void test_icd_stub_log(const char *format, ...); -DllExport void test_icd_close_stub_log(void); -DllExport char *test_icd_get_app_log(void); - -#endif /* _ICD_TEST_LOG_H_ */ diff --git a/khronos_icd/test/loader_test/CMakeLists.txt b/khronos_icd/test/loader_test/CMakeLists.txt deleted file mode 100644 index ddc675b42..000000000 --- a/khronos_icd/test/loader_test/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -add_executable (icd_loader_test - test_kernel.c - main.c - test_platforms.c - icd_test_match.c - test_program_objects.c - test_sampler_objects.c - test_buffer_object.c - test_cl_runtime.c - callbacks.c - test_create_calls.c - test_clgl.c - test_image_objects.c ) - -target_link_libraries (icd_loader_test OpenCL IcdLog) diff --git a/khronos_icd/test/loader_test/Makefile b/khronos_icd/test/loader_test/Makefile deleted file mode 100644 index 4b0dfe33d..000000000 --- a/khronos_icd/test/loader_test/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -CC := gcc -CFLAGS := -I ../inc -I ../../ -g -O0 - -OUTDIR := ../../bin - -${OUTDIR}/icd_loader_test: main.c callbacks.c icd_test_match.c - -${OUTDIR}/icd_loader_test: test_buffer_object.c test_clgl.c test_cl_runtime.c test_create_calls.c test_image_objects.c - -${OUTDIR}/icd_loader_test: test_kernel.c test_platforms.c test_program_objects.c test_sampler_objects.c - ${CC} ${CFLAGS} ${OUTDIR}/libOpenCL.so -o $@ $^ ${OUTDIR}/libIcdLog.so - -.PHONY: clean - -clean: - rm -f ${OUTDIR}/icd_loader_test diff --git a/khronos_icd/test/loader_test/callbacks.c b/khronos_icd/test/loader_test/callbacks.c deleted file mode 100644 index 8e0b4934b..000000000 --- a/khronos_icd/test/loader_test/callbacks.c +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include -#include - -void CL_CALLBACK createcontext_callback(const char* _a, const void* _b, size_t _c, void* _d) -{ - test_icd_app_log("createcontext_callback(%p, %p, %u, %p)\n", - _a, - _b, - _c, - _d); -} - -void CL_CALLBACK setmemobjectdestructor_callback(cl_mem _a, void* _b) -{ - test_icd_app_log("setmemobjectdestructor_callback(%p, %p)\n", - _a, - _b); -} - -void CL_CALLBACK program_callback(cl_program _a, void* _b) -{ - test_icd_app_log("program_callback(%p, %p)\n", - _a, - _b); -} - -void CL_CALLBACK setevent_callback(cl_event _a, cl_int _b, void* _c) -{ - test_icd_app_log("setevent_callback(%p, %d, %p)\n", - _a, - _b, - _c); -} - -void CL_CALLBACK setprintf_callback(cl_context _a, cl_uint _b, char* _c, void* _d ) -{ - test_icd_app_log("setprintf_callback(%p, %u, %p, %p)\n", - _a, - _b, - _c, - _d); -} diff --git a/khronos_icd/test/loader_test/icd_test_match.c b/khronos_icd/test/loader_test/icd_test_match.c deleted file mode 100644 index a58bb5fcc..000000000 --- a/khronos_icd/test/loader_test/icd_test_match.c +++ /dev/null @@ -1,36 +0,0 @@ -#include -#include -#include -#include - -int test_icd_match() -{ - int error = 0; - char *app_log = NULL, *stub_log = NULL; - - app_log = test_icd_get_app_log(); - if (!app_log) { - printf("ERROR: Could not retrieve app log\n"); - error = 1; - goto End; - } - - stub_log = test_icd_get_stub_log(); - if (!stub_log) { - printf("ERROR: Could not retrieve stub log\n"); - error = 1; - goto End; - } - - if (strcmp(app_log, stub_log)) { - printf("ERROR: App log and stub log differ.\n"); - error = 1; - goto End; - } - -End: - free(app_log); - free(stub_log); - return error; -} - diff --git a/khronos_icd/test/loader_test/main.c b/khronos_icd/test/loader_test/main.c deleted file mode 100644 index a933946fa..000000000 --- a/khronos_icd/test/loader_test/main.c +++ /dev/null @@ -1,47 +0,0 @@ -#include -#include -#include -#include "param_struct.h" - -extern int test_create_calls(); -extern int test_platforms(); -extern int test_cl_runtime(); -extern int test_kernel(); -extern int test_buffer_object(); -extern int test_program_objects(); -extern int test_image_objects(); -extern int test_sampler_objects(); -extern int initialize_log(); -extern int test_icd_match(); - -extern int test_OpenGL_share(); -extern int test_Direct3D10_share(); - -int main(int argc, char **argv) -{ - test_icd_initialize_app_log(); - test_icd_initialize_stub_log(); - - test_create_calls(); - test_platforms(); - test_cl_runtime(); - test_kernel(); - test_buffer_object(); - test_program_objects(); - test_image_objects(); - test_sampler_objects(); - test_OpenGL_share(); - -// test_Direct3D10_share(); - test_release_calls(); - test_icd_close_app_log(); - test_icd_close_stub_log(); - - if (test_icd_match()) { - printf("ICD Loader Test FAILED\n"); - return 1; - } else { - printf("ICD Loader Test PASSED\n"); - return 0; - } -} diff --git a/khronos_icd/test/loader_test/param_struct.h b/khronos_icd/test/loader_test/param_struct.h deleted file mode 100644 index 1e1aab619..000000000 --- a/khronos_icd/test/loader_test/param_struct.h +++ /dev/null @@ -1,1115 +0,0 @@ -#ifndef _PARAM_STRUCT_H_ -#define _PARAM_STRUCT_H_ - -#include -#include -#include - -#ifdef _WIN32 -#include /* Needed for gl.h */ -#endif -#include - -struct clCreateCommandQueue_st -{ - cl_context context; - cl_device_id device; - cl_command_queue_properties properties; - cl_int *errcode_ret; -}; - -struct clSetCommandQueueProperty_st -{ - cl_command_queue command_queue; - cl_command_queue_properties properties; - cl_bool enable; - cl_command_queue_properties *old_properties; -}; - -struct clGetCommandQueueInfo_st -{ - cl_command_queue command_queue; - cl_command_queue_info param_name; - size_t param_value_size; - void *param_value; - size_t *param_value_size_ret; -}; - -struct clCreateContext_st -{ - const cl_context_properties *properties; - cl_uint num_devices; - const cl_device_id *devices; - void (CL_CALLBACK*pfn_notify)(const char *errinfo, const void *private_info, size_t cb, void *user_data); - void *user_data; - cl_int *errcode_ret; -}; - -struct clCreateContextFromType_st -{ - const cl_context_properties *properties; - cl_device_type device_type; - void (CL_CALLBACK *pfn_notify)(const char *errinfo, const void *private_info, size_t cb,void *user_data); - void *user_data; - cl_int *errcode_ret; -}; - -struct clRetainContext_st -{ - cl_context context; -}; - -struct clReleaseContext_st -{ - cl_context context; -}; - -struct clGetContextInfo_st -{ - cl_context context; - cl_context_info param_name; - size_t param_value_size; - void *param_value; - size_t *param_value_size_ret; -}; - -struct clGetPlatformIDs_st -{ - cl_uint num_entries; - cl_platform_id *platforms; - cl_uint *num_platforms; -}; - -struct clGetPlatformInfo_st -{ - cl_platform_id platform; - cl_platform_info param_name; - size_t param_value_size; - void *param_value; - size_t *param_value_size_ret; -}; - -struct clGetDeviceIDs_st -{ - cl_platform_id platform; - cl_device_type device_type; - cl_uint num_entries; - cl_device_id *devices; - cl_uint *num_devices; -}; - -struct clRetainCommandQueue_st -{ - cl_command_queue command_queue; -}; - -struct clReleaseCommandQueue_st -{ - cl_command_queue command_queue; -}; - -#define NUM_ITEMS_clCreateCommandQueue 1 -#define NUM_ITEMS_clRetainCommandQueue 1 -#define NUM_ITEMS_clReleaseCommandQueue 1 -#define NUM_ITEMS_clGetCommandQueueInfo 1 -#define NUM_ITEMS_clSetCommandQueueProperty 1 -#define NUM_ITEMS_clCreateContext 1 -#define NUM_ITEMS_clCreateContextFromType 1 -#define NUM_ITEMS_clRetainContext 1 -#define NUM_ITEMS_clReleaseContext 1 -#define NUM_ITEMS_clGetContextInfo 1 -#define NUM_ITEMS_clGetPlatformIDs 1 -#define NUM_ITEMS_clGetPlatformInfo 1 -#define NUM_ITEMS_clGetDeviceIDs 1 -#define NUM_ITEMS_clGetDeviceInfo 1 -#define NUM_ITEMS_clCreateSubDevices 1 -#define NUM_ITEMS_clRetainDevice 1 -#define NUM_ITEMS_clReleaseDevice 1 - -struct clGetDeviceInfo_st -{ - cl_device_id device; - cl_device_info param_name; - size_t param_value_size; - void *param_value; - size_t *param_value_size_ret; -}; - -struct clCreateSubDevices_st -{ - cl_device_id in_device; - cl_device_partition_property *properties; - cl_uint num_entries; - cl_device_id *out_devices; - cl_uint *num_devices; -}; - -struct clRetainDevice_st -{ - cl_device_id device; -}; - -struct clReleaseDevice_st -{ - cl_device_id device; -}; - - -#define NUM_ITEMS_clCreateBuffer 1 -#define NUM_ITEMS_clCreateSubBuffer 1 -#define NUM_ITEMS_clEnqueueReadBuffer 1 -#define NUM_ITEMS_clEnqueueWriteBuffer 1 -#define NUM_ITEMS_clEnqueueReadBufferRect 1 -#define NUM_ITEMS_clEnqueueWriteBufferRect 1 -#define NUM_ITEMS_clEnqueueFillBuffer 1 -#define NUM_ITEMS_clEnqueueCopyBuffer 1 -#define NUM_ITEMS_clEnqueueCopyBufferRect 1 -#define NUM_ITEMS_clEnqueueMapBuffer 1 -#define NUM_ITEMS_clRetainMemObject 1 -#define NUM_ITEMS_clReleaseMemObject 1 -#define NUM_ITEMS_clSetMemObjectDestructorCallback 1 -#define NUM_ITEMS_clEnqueueUnmapMemObject 1 -#define NUM_ITEMS_clGetMemObjectInfo 1 - -struct clCreateBuffer_st -{ - cl_context context; - cl_mem_flags flags; - size_t size; - void *host_ptr; - cl_int *errcode_ret; -}; -struct clCreateSubBuffer_st -{ - cl_mem buffer; - cl_mem_flags flags; - cl_buffer_create_type buffer_create_type; - const void *buffer_create_info; - cl_int *errcode_ret; -}; - -struct clEnqueueReadBuffer_st -{ - cl_command_queue command_queue; - cl_mem buffer; - cl_bool blocking_read; - size_t offset; - size_t cb; - void *ptr; - cl_uint num_events_in_wait_list; - const cl_event *event_wait_list; - cl_event *event; -}; - -struct clEnqueueWriteBuffer_st -{ - cl_command_queue command_queue; - cl_mem buffer; - cl_bool blocking_write; - size_t offset; - size_t cb; - const void *ptr; - cl_uint num_events_in_wait_list; - const cl_event *event_wait_list; - cl_event *event; -}; - -struct clEnqueueReadBufferRect_st -{ - cl_command_queue command_queue; - cl_mem buffer; - cl_bool blocking_read; - const size_t * buffer_offset; - const size_t * host_offset; - const size_t * region; - size_t buffer_row_pitch; - size_t buffer_slice_pitch; - size_t host_row_pitch; - size_t host_slice_pitch; - void *ptr; - cl_uint num_events_in_wait_list; - const cl_event *event_wait_list; - cl_event *event; -}; - -struct clEnqueueWriteBufferRect_st -{ - cl_command_queue command_queue; - cl_mem buffer; - cl_bool blocking_write; - const size_t *buffer_offset; - const size_t *host_offset; - const size_t *region; - size_t buffer_row_pitch; - size_t buffer_slice_pitch; - size_t host_row_pitch; - size_t host_slice_pitch; - void *ptr; - cl_uint num_events_in_wait_list; - const cl_event *event_wait_list; - cl_event *event; -}; - -struct clEnqueueFillBuffer_st -{ - cl_command_queue command_queue; - cl_mem buffer; - const void *pattern; - size_t pattern_size; - size_t offset; - size_t cb; - cl_uint num_events_in_wait_list; - const cl_event *event_wait_list; - cl_event *event; -}; - -struct clEnqueueCopyBuffer_st -{ - cl_command_queue command_queue; - cl_mem src_buffer; - cl_mem dst_buffer; - size_t src_offset; - size_t dst_offset; - size_t cb; - cl_uint num_events_in_wait_list; - const cl_event *event_wait_list; - cl_event *event; -}; - -struct clEnqueueCopyBufferRect_st -{ - cl_command_queue command_queue; - cl_mem src_buffer; - cl_mem dst_buffer; - const size_t *src_origin; - const size_t *dst_origin; - const size_t *region; - size_t src_row_pitch; - size_t src_slice_pitch; - size_t dst_row_pitch; - size_t dst_slice_pitch; - cl_uint num_events_in_wait_list; - const cl_event *event_wait_list; - cl_event *event; -}; - -struct clEnqueueMapBuffer_st -{ - cl_command_queue command_queue; - cl_mem buffer; - cl_bool blocking_map; - cl_map_flags map_flags; - size_t offset; - size_t cb; - cl_uint num_events_in_wait_list; - const cl_event *event_wait_list; - cl_event *event; - cl_int *errcode_ret; -}; - -struct clRetainMemObject_st -{ - cl_mem memobj; -}; - -struct clReleaseMemObject_st -{ - cl_mem memobj; -}; - -struct clSetMemObjectDestructorCallback_st -{ - cl_mem memobj; - void (CL_CALLBACK *pfn_notify)(cl_mem memobj, void *user_data); - void *user_data; -}; - -struct clEnqueueUnmapMemObject_st -{ - cl_command_queue command_queue; - cl_mem memobj; - void *mapped_ptr; - cl_uint num_events_in_wait_list; - const cl_event *event_wait_list; - cl_event *event; -}; - -struct clGetMemObjectInfo_st -{ - cl_mem memobj; - cl_mem_info param_name; - size_t param_value_size; - void *param_value; - size_t *param_value_size_ret; -}; - -#define NUM_ITEMS_clCreateProgramWithSource 1 -#define NUM_ITEMS_clCreateProgramWithBinary 1 -#define NUM_ITEMS_clCreateProgramWithBuiltInKernels 1 -#define NUM_ITEMS_clRetainProgram 1 -#define NUM_ITEMS_clReleaseProgram 1 -#define NUM_ITEMS_clBuildProgram 1 -#define NUM_ITEMS_clCompileProgram 1 -#define NUM_ITEMS_clLinkProgram 1 -#define NUM_ITEMS_clUnloadPlatformCompiler 1 -#define NUM_ITEMS_clGetProgramInfo 1 -#define NUM_ITEMS_clGetProgramBuildInfo 1 -#define NUM_ITEMS_clUnloadCompiler 1 -#define NUM_ITEMS_clGetExtensionFunctionAddress 1 -#define NUM_ITEMS_clGetExtensionFunctionAddressForPlatform 1 - -struct clCreateProgramWithSource_st -{ - cl_context context; - cl_uint count; - const char **strings; - const size_t *lengths; - cl_int *errcode_ret; -}; - -struct clCreateProgramWithBinary_st -{ - cl_context context; - cl_uint num_devices; - const cl_device_id *device_list; - const size_t *lengths; - const unsigned char **binaries; - cl_int *binary_status; - cl_int *errcode_ret; -}; - -struct clCreateProgramWithBuiltInKernels_st -{ - cl_context context; - cl_uint num_devices; - const cl_device_id *device_list; - const char *kernel_names; - cl_int *errcode_ret; -}; - -struct clRetainProgram_st -{ - cl_program program; -}; - -struct clReleaseProgram_st -{ - cl_program program; -}; - -struct clBuildProgram_st -{ - cl_program program; - cl_uint num_devices; - const cl_device_id *device_list; - const char *options; - void (CL_CALLBACK*pfn_notify)(cl_program program, void *user_data); - void *user_data; -}; - -struct clCompileProgram_st -{ - cl_program program; - cl_uint num_devices; - const cl_device_id *device_list; - const char *options; - cl_uint num_input_headers; - const cl_program *headers; - const char **header_include_names; - void (CL_CALLBACK *pfn_notify)(cl_program program, void * user_data); - void *user_data; -}; - -struct clLinkProgram_st -{ - cl_context context; - cl_uint num_devices; - const cl_device_id *device_list; - const char *options; - cl_uint num_input_programs; - const cl_program *input_programs; - void (CL_CALLBACK *pfn_notify)(cl_program program, void *user_data); - void *user_data; - cl_int *errcode_ret; -}; - -struct clUnloadPlatformCompiler_st -{ - cl_platform_id platform; -}; - -#if 0 -struct clUnloadCompiler_st -{ - void ; -}; -#endif - -struct clGetExtensionFunctionAddress_st -{ - const char *func_name; -}; - -struct clGetExtensionFunctionAddressForPlatform_st -{ - cl_platform_id platform; - const char *func_name; -}; - -struct clGetProgramInfo_st -{ - cl_program program; - cl_program_info param_name; - size_t param_value_size; - void *param_value; - size_t *param_value_size_ret; -}; - -struct clGetProgramBuildInfo_st -{ - cl_program program; - cl_device_id device; - cl_program_build_info param_name; - size_t param_value_size; - void *param_value; - size_t *param_value_size_ret; -}; - -#define NUM_ITEMS_clCreateImage2D 1 -#define NUM_ITEMS_clCreateImage3D 1 -#define NUM_ITEMS_clCreateImage 1 -#define NUM_ITEMS_clGetSupportedImageFormats 1 -#define NUM_ITEMS_clEnqueueCopyImageToBuffer 1 -#define NUM_ITEMS_clEnqueueCopyBufferToImage 1 -#define NUM_ITEMS_clEnqueueMapImage 1 -#define NUM_ITEMS_clEnqueueReadImage 1 -#define NUM_ITEMS_clEnqueueWriteImage 1 -#define NUM_ITEMS_clEnqueueFillImage 1 -#define NUM_ITEMS_clEnqueueCopyImage 1 -#define NUM_ITEMS_clGetMemObjectInfo 1 -#define NUM_ITEMS_clGetImageInfo 1 - -struct clCreateImage_st -{ - cl_context context; - cl_mem_flags flags; - const cl_image_format *image_format; - const cl_image_desc *image_desc; - void *host_ptr; - cl_int *errcode_ret; -}; - -struct clCreateImage2D_st -{ - cl_context context; - cl_mem_flags flags; - const cl_image_format *image_format; - size_t image_width; - size_t image_height; - size_t image_row_pitch; - void *host_ptr; - cl_int *errcode_ret; -}; - -struct clCreateImage3D_st -{ - cl_context context; - cl_mem_flags flags; - const cl_image_format *image_format; - size_t image_width; - size_t image_height; - size_t image_depth; - size_t image_row_pitch; - size_t image_slice_pitch; - void *host_ptr; - cl_int *errcode_ret; -}; - -struct clGetSupportedImageFormats_st -{ - cl_context context; - cl_mem_flags flags; - cl_mem_object_type image_type; - cl_uint num_entries; - cl_image_format *image_formats; - cl_uint *num_image_formats; -}; - -struct clEnqueueCopyImageToBuffer_st -{ - cl_command_queue command_queue; - cl_mem src_image; - cl_mem dst_buffer; - const size_t *src_origin; - const size_t *region; - size_t dst_offset; - cl_uint num_events_in_wait_list; - const cl_event *event_wait_list; - cl_event *event; -}; - -struct clEnqueueCopyBufferToImage_st -{ - cl_command_queue command_queue; - cl_mem src_buffer; - cl_mem dst_image; - size_t src_offset; - const size_t *dst_origin; - const size_t *region; - cl_uint num_events_in_wait_list; - const cl_event *event_wait_list; - cl_event *event; -}; - -struct clEnqueueMapImage_st -{ - cl_command_queue command_queue; - cl_mem image; - cl_bool blocking_map; - cl_map_flags map_flags; - const size_t *origin; - const size_t *region; - size_t *image_row_pitch; - size_t *image_slice_pitch; - cl_uint num_events_in_wait_list; - const cl_event *event_wait_list; - cl_event *event; - cl_int *errcode_ret; -}; - -struct clEnqueueReadImage_st -{ - cl_command_queue command_queue; - cl_mem image; - cl_bool blocking_read; - const size_t *origin; - const size_t *region; - size_t row_pitch; - size_t slice_pitch; - void *ptr; - cl_uint num_events_in_wait_list; - const cl_event *event_wait_list; - cl_event *event; -}; - -struct clEnqueueWriteImage_st -{ - cl_command_queue command_queue; - cl_mem image; - cl_bool blocking_write; - const size_t *origin; - const size_t *region; - size_t input_row_pitch; - size_t input_slice_pitch; - const void *ptr; - cl_uint num_events_in_wait_list; - const cl_event *event_wait_list; - cl_event *event; -}; - -struct clEnqueueFillImage_st -{ - cl_command_queue command_queue; - cl_mem image; - const void *fill_color; - const size_t *origin; - const size_t *region; - cl_uint num_events_in_wait_list; - const cl_event *event_wait_list; - cl_event *event; -}; - -struct clEnqueueCopyImage_st -{ - cl_command_queue command_queue; - cl_mem src_image; - cl_mem dst_image; - const size_t *src_origin; - const size_t *dst_origin; - const size_t *region; - cl_uint num_events_in_wait_list; - const cl_event *event_wait_list; - cl_event *event; -}; - -#if 0 -struct clGetMemObjectInfo_st -{ - cl_mem memobj; - cl_mem_info param_name; - size_t param_value_size; - void *param_value; - size_t *param_value_size_ret; -}; -#endif - -struct clGetImageInfo_st -{ - cl_mem image; - cl_image_info param_name; - size_t param_value_size; - void *param_value; - size_t *param_value_size_ret; -}; - -#define NUM_ITEMS_clCreateSampler 1 -#define NUM_ITEMS_clRetainSampler 1 -#define NUM_ITEMS_clReleaseSampler 1 -#define NUM_ITEMS_clGetSamplerInfo 1 - -struct clCreateSampler_st -{ - cl_context context; - cl_bool normalized_coords; - cl_addressing_mode addressing_mode; - cl_filter_mode filter_mode; - cl_int *errcode_ret; -}; - -struct clRetainSampler_st -{ - cl_sampler sampler; -}; - -struct clReleaseSampler_st -{ - cl_sampler sampler; -}; - -struct clGetSamplerInfo_st -{ - cl_sampler sampler; - cl_sampler_info param_name; - size_t param_value_size; - void *param_value; - size_t *param_value_size_ret; -}; - -#define NUM_ITEMS_clCreateKernel 1 -#define NUM_ITEMS_clCreateKernelsInProgram 1 -#define NUM_ITEMS_clRetainKernel 1 -#define NUM_ITEMS_clReleaseKernel 1 - -struct clCreateKernel_st -{ - cl_program program; - const char *kernel_name; - cl_int *errcode_ret; -}; - -struct clCreateKernelsInProgram_st -{ - cl_program program; - cl_uint num_kernels; - cl_kernel *kernels; - cl_uint *num_kernels_ret; -}; - -struct clRetainKernel_st -{ - cl_kernel kernel; -}; - -struct clReleaseKernel_st -{ - cl_kernel kernel; -}; - -#define NUM_ITEMS_clSetKernelArg 1 -#define NUM_ITEMS_clGetKernelInfo 1 -#define NUM_ITEMS_clGetKernelArgInfo 1 -#define NUM_ITEMS_clGetKernelWorkGroupInfo 1 - -struct clSetKernelArg_st -{ - cl_kernel kernel; - cl_uint arg_index; - size_t arg_size; - const void *arg_value; -}; - -struct clGetKernelInfo_st -{ - cl_kernel kernel; - cl_kernel_info param_name; - size_t param_value_size; - void *param_value; - size_t *param_value_size_ret; -}; - -struct clGetKernelArgInfo_st -{ - cl_kernel kernel; - cl_uint arg_indx; - cl_kernel_arg_info param_name; - size_t param_value_size; - void *param_value; - size_t *param_value_size_ret; -}; - -struct clGetKernelWorkGroupInfo_st -{ - cl_kernel kernel; - cl_device_id device; - cl_kernel_work_group_info param_name; - size_t param_value_size; - void *param_value; - size_t *param_value_size_ret; -}; - -#define NUM_ITEMS_clEnqueueMigrateMemObjects 1 -#define NUM_ITEMS_clEnqueueNDRangeKernel 1 -#define NUM_ITEMS_clEnqueueTask 1 -#define NUM_ITEMS_clEnqueueNativeKernel 1 - -struct clEnqueueMigrateMemObjects_st -{ - cl_command_queue command_queue; - size_t num_mem_objects; - const cl_mem *mem_objects; - cl_mem_migration_flags flags; - cl_uint num_events_in_wait_list; - const cl_event *event_wait_list; - cl_event *event; -}; - -struct clEnqueueNDRangeKernel_st -{ - cl_command_queue command_queue; - cl_kernel kernel; cl_uint work_dim; - const size_t *global_work_offset; - const size_t *global_work_size; - const size_t *local_work_size; - cl_uint num_events_in_wait_list; - const cl_event *event_wait_list; - cl_event *event; -}; - -struct clEnqueueTask_st -{ - cl_command_queue command_queue; - cl_kernel kernel; - cl_uint num_events_in_wait_list; - const cl_event *event_wait_list; - cl_event *event; -}; - -struct clEnqueueNativeKernel_st -{ - cl_command_queue command_queue; - void (CL_CALLBACK *user_func)(void *); - void *args; - size_t cb_args; - cl_uint num_mem_objects; - const cl_mem *mem_list; - const void **args_mem_loc; - cl_uint num_events_in_wait_list; - const cl_event *event_wait_list; - cl_event *event; -}; - -#define NUM_ITEMS_clCreateUserEvent 1 -#define NUM_ITEMS_clSetUserEventStatus 1 -#define NUM_ITEMS_clWaitForEvents 1 -#define NUM_ITEMS_clGetEventInfo 1 -#define NUM_ITEMS_clSetEventCallback 1 -#define NUM_ITEMS_clRetainEvent 1 -#define NUM_ITEMS_clReleaseEvent 1 - -struct clCreateUserEvent_st -{ - cl_context context; - cl_int *errcode_ret; -}; - -struct clSetUserEventStatus_st -{ - cl_event event; - cl_int execution_status; -}; - -struct clWaitForEvents_st -{ - cl_uint num_events; - const cl_event *event_list; -}; - -struct clGetEventInfo_st -{ - cl_event event; - cl_event_info param_name; - size_t param_value_size; - void *param_value; - size_t *param_value_size_ret; -}; - -struct clSetEventCallback_st -{ - cl_event event; - cl_int command_exec_callback_type; - void (CL_CALLBACK *pfn_event_notify)(cl_event event, cl_int event_command_exec_status,void *user_data); - void *user_data; -}; - -struct clRetainEvent_st -{ - cl_event event; -}; - -struct clReleaseEvent_st -{ - cl_event event; -}; - -#define NUM_ITEMS_clEnqueueMarker 1 -#define NUM_ITEMS_clEnqueueWaitForEvents 1 -#define NUM_ITEMS_clEnqueueBarrier 1 -#define NUM_ITEMS_clEnqueueMarkerWithWaitList 1 -#define NUM_ITEMS_clEnqueueBarrierWithWaitList 1 - -struct clEnqueueMarker_st -{ - cl_command_queue command_queue; - cl_event *event; -}; - -struct clEnqueueWaitForEvents_st -{ - cl_command_queue command_queue; - cl_uint num_events; - const cl_event *event_list; -}; - -struct clEnqueueBarrier_st -{ - cl_command_queue command_queue; -}; - -struct clEnqueueMarkerWithWaitList_st -{ - cl_command_queue command_queue; - cl_uint num_events_in_wait_list; - const cl_event *event_wait_list; - cl_event *event; -}; - -struct clEnqueueBarrierWithWaitList_st -{ - cl_command_queue command_queue; - cl_uint num_events_in_wait_list; - const cl_event *event_wait_list; - cl_event *event; -}; - -#define NUM_ITEMS_clGetEventProfilingInfo 1 - -struct clGetEventProfilingInfo_st -{ - cl_event event; - cl_profiling_info param_name; - size_t param_value_size; - void *param_value; - size_t *param_value_size_ret; -}; - -#define NUM_ITEMS_clFlush 1 -#define NUM_ITEMS_clFinish 1 - -struct clFlush_st -{ - cl_command_queue command_queue; -}; - -struct clFinish_st -{ - cl_command_queue command_queue; -}; - -#define NUM_ITEMS_clCreateFromGLBuffer 1 -struct clCreateFromGLBuffer_st -{ - cl_context context; - cl_mem_flags flags; - GLuint bufobj; - int *errcode_ret; -}; - -#define NUM_ITEMS_clCreateFromGLTexture 1 -#define NUM_ITEMS_clCreateFromGLTexture2D 1 -#define NUM_ITEMS_clCreateFromGLTexture3D 1 - -struct clCreateFromGLTexture_st -{ - cl_context context; - cl_mem_flags flags; - GLenum texture_target; - GLint miplevel; - GLuint texture; - cl_int *errcode_ret; -}; - -struct clCreateFromGLTexture2D_st -{ - cl_context context; - cl_mem_flags flags; - GLenum texture_target; - GLint miplevel; - GLuint texture; - cl_int *errcode_ret; -}; - -struct clCreateFromGLTexture3D_st -{ - cl_context context; - cl_mem_flags flags; - GLenum texture_target; - GLint miplevel; - GLuint texture; - cl_int *errcode_ret; -}; - -#define NUM_ITEMS_clCreateFromGLRenderbuffer 1 - -struct clCreateFromGLRenderbuffer_st -{ - cl_context context; - cl_mem_flags flags; - GLuint renderbuffer; - cl_int *errcode_ret; -}; - - - // Query Information [9.8.5] -#define NUM_ITEMS_clGetGLObjectInfo 1 -#define NUM_ITEMS_clGetGLTextureInfo 1 - -struct clGetGLObjectInfo_st -{ - cl_mem memobj; - cl_gl_object_type *gl_object_type; - GLuint *gl_object_name; -}; - -struct clGetGLTextureInfo_st -{ - cl_mem memobj; - cl_gl_texture_info param_name; - size_t param_value_size; - void *param_value; - size_t *param_value_size_ret; -}; - -// Share Objects [9.8.6] - -#define NUM_ITEMS_clEnqueueAcquireGLObjects 1 -#define NUM_ITEMS_clEnqueueReleaseGLObjects 1 - -struct clEnqueueAcquireGLObjects_st -{ - cl_command_queue command_queue; - cl_uint num_objects; - const cl_mem *mem_objects; - cl_uint num_events_in_wait_list; - const cl_event *event_wait_list; - cl_event *event; -}; - -struct clEnqueueReleaseGLObjects_st -{ - cl_command_queue command_queue; - cl_uint num_objects; - const cl_mem *mem_objects; - cl_uint num_events_in_wait_list; - const cl_event *event_wait_list; - cl_event *event; -}; - -// CL Event Objects > GL Sync Objects [9.9] -#define NUM_ITEMS_clCreateEventFromGLsyncKHR 1 - -struct clCreateEventFromGLsyncKHR_st -{ - cl_context context; - cl_GLsync sync; - cl_int *errcode_ret; -}; - -// CL Context > GL Context; Sharegroup [9.7] -#define NUM_ITEMS_clGetGLContextInfoKHR 1 - -struct clGetGLContextInfoKHR_st -{ - const cl_context_properties *properties; - cl_gl_context_info param_name; - size_t param_value_size; - void *param_value; - size_t *param_value_size_ret; -}; - -#if 0 -// OpenCL/Direct3D 10 Sharing APIs [9.10] - -#define NUM_ITEMS_clGetDeviceIDsFromD3D10KHR 1 -#define NUM_ITEMS_clCreateFromD3D10BufferKHR 1 -#define NUM_ITEMS_clCreateFromD3D10Texture2DKHR 1 -#define NUM_ITEMS_clCreateFromD3D10Texture3DKHR 1 -#define NUM_ITEMS_clEnqueueAcquireD3D10ObjectsKHR 1 -#define NUM_ITEMS_clEnqueueReleaseD3D10ObjectsKHR 1 - -struct clGetDeviceIDsFromD3D10KHR_st -{ - cl_platform_id platform; - cl_d3d10_device_source_khr d3d_device_source; - void *d3d_object; - cl_d3d10_device_set_khr d3d_device_set; - cl_uint num_entries; - cl_device_id *devices; cl_uint *num_devices; -}; - -struct clCreateFromD3D10BufferKHR_st -{ - cl_context context; - cl_mem_flags flags; - ID3D10Buffer *resource; - cl_int *errcode_ret; -}; - -struct clCreateFromD3D10Texture2DKHR_st -{ - cl_context context; - cl_mem_flags flags; - ID3D10Texture2D *resource; - UINT subresource; - cl_int *errcode_ret; -}; - -struct clCreateFromD3D10Texture3DKHR_st -{ - cl_context context; - cl_mem_flags flags; - ID3D10Texture3D *resource; - UINT subresource; - cl_int *errcode_ret; -}; - -struct clEnqueueAcquireD3D10ObjectsKHR_st -{ - cl_command_queue command_queue; - cl_uint num_objects; - const cl_mem *mem_objects; - cl_uint num_events_in_wait_list; - const cl_event *event_wait_list; - cl_event *event;}; - -struct clEnqueueReleaseD3D10ObjectsKHR_st -{ - cl_command_queue command_queue; - cl_uint num_objects; - const cl_mem *mem_objects; - cl_uint num_events_in_wait_list; - const cl_event *event_wait_list; - cl_event *event; -}; -#endif - -#endif /* _PARAM_STRUCT_H_ */ diff --git a/khronos_icd/test/loader_test/test_buffer_object.c b/khronos_icd/test/loader_test/test_buffer_object.c deleted file mode 100644 index 85a2178c6..000000000 --- a/khronos_icd/test/loader_test/test_buffer_object.c +++ /dev/null @@ -1,461 +0,0 @@ -#include -#include "param_struct.h" -#include - -extern cl_mem buffer; -extern cl_command_queue command_queue; -extern cl_event event; - -static int ret_val; - -extern void CL_CALLBACK setmemobjectdestructor_callback(cl_mem _a, void* _b); - -const struct clEnqueueReadBuffer_st clEnqueueReadBufferData[NUM_ITEMS_clEnqueueReadBuffer] = -{ - {NULL, NULL, 0, 0, 0, NULL, 0, NULL, NULL} -}; - -const struct clEnqueueWriteBuffer_st clEnqueueWriteBufferData[NUM_ITEMS_clEnqueueWriteBuffer] = -{ - {NULL, NULL, 0, 0, 0, NULL, 0, NULL, NULL} -}; - -const struct clEnqueueReadBufferRect_st clEnqueueReadBufferRectData[NUM_ITEMS_clEnqueueReadBufferRect] = -{ - {NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0, NULL, NULL} -}; - -const struct clEnqueueWriteBufferRect_st clEnqueueWriteBufferRectData[NUM_ITEMS_clEnqueueWriteBufferRect] = -{ - {NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0, NULL, NULL} -}; - -const struct clEnqueueFillBuffer_st clEnqueueFillBufferData[NUM_ITEMS_clEnqueueFillBuffer] = -{ - {NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL} -}; - -const struct clEnqueueCopyBuffer_st clEnqueueCopyBufferData[NUM_ITEMS_clEnqueueCopyBuffer] = -{ - {NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL} -}; - -const struct clEnqueueCopyBufferRect_st clEnqueueCopyBufferRectData[NUM_ITEMS_clEnqueueCopyBufferRect] = -{ - {NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL} -}; - -const struct clEnqueueMapBuffer_st clEnqueueMapBufferData[NUM_ITEMS_clEnqueueMapBuffer] = -{ - {NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL} -}; - -const struct clRetainMemObject_st clRetainMemObjectData[NUM_ITEMS_clRetainMemObject] = -{ - {NULL} -}; - -const struct clSetMemObjectDestructorCallback_st clSetMemObjectDestructorCallbackData[NUM_ITEMS_clSetMemObjectDestructorCallback] = -{ - {NULL, setmemobjectdestructor_callback, NULL} -}; - -const struct clEnqueueUnmapMemObject_st clEnqueueUnmapMemObjectData[NUM_ITEMS_clEnqueueUnmapMemObject] = -{ - {NULL, NULL, NULL, 0, NULL, NULL} -}; - -const struct clGetMemObjectInfo_st clGetMemObjectInfoData[NUM_ITEMS_clGetMemObjectInfo] = -{ - {NULL, 0, 0, NULL, NULL} -}; - -int test_clEnqueueReadBuffer(const struct clEnqueueReadBuffer_st *data) -{ - test_icd_app_log("clEnqueueReadBuffer(%p, %p, %u, %u, %u, %p, %u, %p, %p)\n", - command_queue, - buffer, - data->blocking_read, - data->offset, - data->cb, - data->ptr, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - ret_val=clEnqueueReadBuffer(command_queue, - buffer, - data->blocking_read, - data->offset, - data->cb, - data->ptr, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; -} - -int test_clEnqueueWriteBuffer(const struct clEnqueueWriteBuffer_st *data) -{ - test_icd_app_log("clEnqueueWriteBuffer(%p, %p, %u, %u, %u, %p, %u, %p, %p)\n", - command_queue, - buffer, - data->blocking_write, - data->offset, - data->cb, - data->ptr, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - ret_val=clEnqueueWriteBuffer(command_queue, - buffer, - data->blocking_write, - data->offset, - data->cb, - data->ptr, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; -} - -int test_clEnqueueReadBufferRect(const struct clEnqueueReadBufferRect_st *data) -{ - test_icd_app_log("clEnqueueReadBufferRect(%p, %p, %u, %p, %p, %p, %u, %u, %u, %u, %p, %u, %p, %p)\n", - command_queue, - buffer, - data->blocking_read, - data->buffer_offset, - data->host_offset, - data->region, - data->buffer_row_pitch, - data->buffer_slice_pitch, - data->host_row_pitch, - data->host_slice_pitch, - data->ptr, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - ret_val=clEnqueueReadBufferRect(command_queue, - buffer, - data->blocking_read, - data->buffer_offset, - data->host_offset, - data->region, - data->buffer_row_pitch, - data->buffer_slice_pitch, - data->host_row_pitch, - data->host_slice_pitch, - data->ptr, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - -int test_clEnqueueWriteBufferRect(const struct clEnqueueWriteBufferRect_st *data) -{ - test_icd_app_log("clEnqueueWriteBufferRect(%p, %p, %u, %p, %p, %p, %u, %u, %u, %u, %p, %u, %p, %p)\n", - command_queue, - buffer, - data->blocking_write, - data->buffer_offset, - data->host_offset, - data->region, - data->buffer_row_pitch, - data->buffer_slice_pitch, - data->host_row_pitch, - data->host_slice_pitch, - data->ptr, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - ret_val=clEnqueueWriteBufferRect(command_queue, - buffer, - data->blocking_write, - data->buffer_offset, - data->host_offset, - data->region, - data->buffer_row_pitch, - data->buffer_slice_pitch, - data->host_row_pitch, - data->host_slice_pitch, - data->ptr, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; -} - -int test_clEnqueueFillBuffer(const struct clEnqueueFillBuffer_st *data) -{ - test_icd_app_log("clEnqueueFillBuffer(%p, %p, %p, %u, %u, %u, %u, %p, %p)\n", - command_queue, - buffer, - data->pattern, - data->pattern_size, - data->offset, - data->cb, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - ret_val=clEnqueueFillBuffer(command_queue, - buffer, - data->pattern, - data->pattern_size, - data->offset, - data->cb, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - -int test_clEnqueueCopyBuffer(const struct clEnqueueCopyBuffer_st *data) -{ - test_icd_app_log("clEnqueueCopyBuffer(%p, %p, %p, %u, %u, %u, %u, %p, %p)\n", - command_queue, - data->src_buffer, - buffer, - data->src_offset, - data->dst_offset, - data->cb, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - ret_val=clEnqueueCopyBuffer(command_queue, - data->src_buffer, - buffer, - data->src_offset, - data->dst_offset, - data->cb, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - -int test_clEnqueueCopyBufferRect(const struct clEnqueueCopyBufferRect_st *data) -{ - test_icd_app_log("clEnqueueCopyBufferRect(%p, %p, %p, %p, %p, %p, %u, %u, %u, %u, %u, %p, %p)\n", - command_queue, - buffer, - buffer, - data->src_origin, - data->dst_origin, - data->region, - data->src_row_pitch, - data->src_slice_pitch, - data->dst_row_pitch, - data->dst_slice_pitch, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - ret_val=clEnqueueCopyBufferRect(command_queue, - buffer, - buffer, - data->src_origin, - data->dst_origin, - data->region, - data->src_row_pitch, - data->src_slice_pitch, - data->dst_row_pitch, - data->dst_slice_pitch, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - -int test_clEnqueueMapBuffer(const struct clEnqueueMapBuffer_st *data) -{ - void * return_value; - test_icd_app_log("clEnqueueMapBuffer(%p, %p, %u, %x, %u, %u, %u, %p, %p, %p)\n", - command_queue, - buffer, - data->blocking_map, - data->map_flags, - data->offset, - data->cb, - data->num_events_in_wait_list, - data->event_wait_list, - &event, - data->errcode_ret); - - return_value=clEnqueueMapBuffer(command_queue, - buffer, - data->blocking_map, - data->map_flags, - data->offset, - data->cb, - data->num_events_in_wait_list, - data->event_wait_list, - &event, - data->errcode_ret); - - test_icd_app_log("Value returned: %p\n", return_value); - - free(return_value); - - return 0; - -} - -int test_clRetainMemObject(const struct clRetainMemObject_st *data) -{ - test_icd_app_log("clRetainMemObject(%p)\n", buffer); - - ret_val=clRetainMemObject(buffer); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - -int test_clSetMemObjectDestructorCallback(const struct clSetMemObjectDestructorCallback_st *data) -{ - test_icd_app_log("clSetMemObjectDestructorCallback(%p, %p, %p)\n", - buffer, - data->pfn_notify, - data->user_data); - - ret_val=clSetMemObjectDestructorCallback(buffer, - data->pfn_notify, - data->user_data); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - -int test_clEnqueueUnmapMemObject(const struct clEnqueueUnmapMemObject_st *data) -{ - test_icd_app_log("clEnqueueUnmapMemObject(%p, %p, %p, %u, %p, %p)\n", - command_queue, - buffer, - data->mapped_ptr, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - ret_val=clEnqueueUnmapMemObject(command_queue, - buffer, - data->mapped_ptr, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - - -int test_clGetMemObjectInfo (const struct clGetMemObjectInfo_st *data) -{ - test_icd_app_log("clGetMemObjectInfo(%p, %u, %u, %p, %p)\n", - buffer, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - ret_val=clGetMemObjectInfo(buffer, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - test_icd_app_log("Value returned: %d\n",ret_val); - - return 0; -} - -int test_buffer_object() -{ - int i; - for (i=0; i -#include "param_struct.h" -#include - -extern cl_command_queue command_queue; - -cl_int ret_val; - -const struct clRetainCommandQueue_st clRetainCommandQueueData[NUM_ITEMS_clRetainCommandQueue] = { - {NULL} -}; - -const struct clGetCommandQueueInfo_st clGetCommandQueueInfoData[NUM_ITEMS_clGetCommandQueueInfo] = { - {NULL, 0, 0, NULL, NULL} -}; - -int test_clRetainCommandQueue(const struct clRetainCommandQueue_st *data) -{ - test_icd_app_log("clRetainCommandQueue(%p)\n", command_queue); - - ret_val = clRetainCommandQueue(command_queue); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - -int test_clGetCommandQueueInfo(const struct clGetCommandQueueInfo_st *data) -{ - test_icd_app_log("clGetCommandQueueInfo(%p, %u, %u, %p, %p)\n", - command_queue, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - ret_val = clGetCommandQueueInfo(command_queue, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - -int test_cl_runtime() -{ - int i; - - for (i=0; i -#include -#include -#include "param_struct.h" -#include - -extern cl_context context; -extern cl_mem buffer; -extern cl_command_queue command_queue; -extern cl_event event; -extern cl_context_properties context_properties[3]; -cl_int ret_val; -cl_mem ret_mem; - -struct clCreateFromGLBuffer_st clCreateFromGLBufferData[NUM_ITEMS_clCreateFromGLBuffer] = { - {NULL, 0x0, 0, NULL} -}; - -int test_clCreateFromGLBuffer(const struct clCreateFromGLBuffer_st* data) -{ - - test_icd_app_log("clCreateFromGLBuffer(%p, %x, %u, %p)\n", - context, - data->flags, - data->bufobj, - data->errcode_ret); - - ret_mem = clCreateFromGLBuffer(context, - data->flags, - data->bufobj, - data->errcode_ret); - - test_icd_app_log("Value returned: %p\n", ret_mem); - - return 0; -} - -struct clCreateFromGLTexture_st clCreateFromGLTextureData[NUM_ITEMS_clCreateFromGLTexture] = { - {NULL, 0x0, 0, 0, 0, NULL} -}; - -int test_clCreateFromGLTexture(const struct clCreateFromGLTexture_st* data) -{ - test_icd_app_log("clCreateFromGLTexture(%p, %x, %d, %d, %u, %p)\n", - context, - data->flags, - data->texture_target, - data->miplevel, - data->texture, - data->errcode_ret); - - ret_mem = clCreateFromGLTexture(context, - data->flags, - data->texture_target, - data->miplevel, - data->texture, - data->errcode_ret); - - test_icd_app_log("Value returned: %p\n", ret_mem); - - return 0; -} - -struct clCreateFromGLTexture2D_st clCreateFromGLTexture2DData[NUM_ITEMS_clCreateFromGLTexture2D] = { - {NULL, 0x0, 0, 0, 0, NULL} -}; - -int test_clCreateFromGLTexture2D(const struct clCreateFromGLTexture2D_st* data) -{ - test_icd_app_log("clCreateFromGLTexture2D(%p, %x, %d, %d, %u, %p)\n", - context, - data->flags, - data->texture_target, - data->miplevel, - data->texture, - data->errcode_ret); - - ret_mem = clCreateFromGLTexture2D(context, - data->flags, - data->texture_target, - data->miplevel, - data->texture, - data->errcode_ret); - - test_icd_app_log("Value returned: %p\n", ret_mem); - - return 0; -} - -struct clCreateFromGLTexture3D_st clCreateFromGLTexture3DData[NUM_ITEMS_clCreateFromGLTexture3D] = { - {NULL, 0, 0, 0, 0, NULL} -}; - -int test_clCreateFromGLTexture3D(const struct clCreateFromGLTexture3D_st* data) -{ - test_icd_app_log("clCreateFromGLTexture3D(%p, %x, %d, %d, %u, %p)\n", - context, - data->flags, - data->texture_target, - data->miplevel, - data->texture, - data->errcode_ret); - - ret_mem = clCreateFromGLTexture3D(context, - data->flags, - data->texture_target, - data->miplevel, - data->texture, - data->errcode_ret); - - test_icd_app_log("Value returned: %p\n", ret_mem); - - return 0; -} - -struct clCreateFromGLRenderbuffer_st clCreateFromGLRenderbufferData[NUM_ITEMS_clCreateFromGLRenderbuffer] = { - {NULL, 0x0, 0, NULL} -}; - -int test_clCreateFromGLRenderbuffer(const struct clCreateFromGLRenderbuffer_st* data) -{ - test_icd_app_log("clCreateFromGLRenderbuffer(%p, %x, %d, %p)\n", - context, - data->flags, - data->renderbuffer, - data->errcode_ret); - - ret_mem = clCreateFromGLRenderbuffer(context, - data->flags, - data->renderbuffer, - data->errcode_ret); - - test_icd_app_log("Value returned: %p\n", ret_mem); - - return 0; -} - -struct clGetGLObjectInfo_st clGetGLObjectInfoData[NUM_ITEMS_clGetGLObjectInfo] = { - {NULL, NULL, NULL} -}; - -int test_clGetGLObjectInfo(const struct clGetGLObjectInfo_st* data) -{ - test_icd_app_log("clGetGLObjectInfo(%p, %p, %p)\n", - buffer, - data->gl_object_type, - data->gl_object_name); - - ret_val = clGetGLObjectInfo(buffer, - data->gl_object_type, - data->gl_object_name); - - test_icd_app_log("Value returned: %p\n", ret_val); - -} - -struct clGetGLTextureInfo_st clGetGLTextureInfoData[NUM_ITEMS_clGetGLTextureInfo] = { - {NULL, 0, 0, NULL, NULL} -}; - -int test_clGetGLTextureInfo(const struct clGetGLTextureInfo_st* data) -{ - test_icd_app_log("clGetGLTextureInfo(%p, %u, %u, %p, %p)\n", - buffer, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - ret_val = clGetGLTextureInfo (buffer, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - test_icd_app_log("Value returned: %p\n", ret_val); - - return 0; -} - -struct clEnqueueAcquireGLObjects_st clEnqueueAcquireGLObjectsData[NUM_ITEMS_clEnqueueAcquireGLObjects] = { - {NULL, 0, NULL, 0, NULL, NULL} -}; - -int test_clEnqueueAcquireGLObjects(const struct clEnqueueAcquireGLObjects_st* data) -{ - test_icd_app_log("clEnqueueAcquireGLObjects(%p, %u, %p, %u, %p, %p)\n", - command_queue, - data->num_objects, - data->mem_objects, - data->num_events_in_wait_list, - &event, - &event); - - ret_val = clEnqueueAcquireGLObjects (command_queue, - data->num_objects, - data->mem_objects, - data->num_events_in_wait_list, - &event, - &event); - - test_icd_app_log("Value returned: %p\n", ret_val); - - return 0; -} - -struct clEnqueueReleaseGLObjects_st clEnqueueReleaseGLObjectsData[NUM_ITEMS_clEnqueueReleaseGLObjects] = { - {NULL, 0, NULL, 0, NULL, NULL} -}; - -int test_clEnqueueReleaseGLObjects(const struct clEnqueueReleaseGLObjects_st* data) -{ - test_icd_app_log("clEnqueueReleaseGLObjects(%p, %u, %p, %u, %p, %p)\n", - command_queue, - data->num_objects, - data->mem_objects, - data->num_events_in_wait_list, - &event, - &event); - - ret_val = clEnqueueReleaseGLObjects (command_queue, - data->num_objects, - data->mem_objects, - data->num_events_in_wait_list, - &event, - &event); - - - test_icd_app_log("Value returned: %p\n", ret_val); - - return 0; -} - -struct clCreateEventFromGLsyncKHR_st clCreateEventFromGLsyncKHRData[NUM_ITEMS_clCreateEventFromGLsyncKHR] = { - {NULL, NULL, NULL} -}; - -typedef CL_API_ENTRY cl_event -(CL_API_CALL *PFN_clCreateEventFromGLsyncKHR)(cl_context /* context */, - cl_GLsync /* cl_GLsync */, - cl_int * /* errcode_ret */); - -int test_clCreateEventFromGLsyncKHR(const struct clCreateEventFromGLsyncKHR_st* data) -{ cl_event ret_event; - PFN_clCreateEventFromGLsyncKHR pfn_clCreateEventFromGLsyncKHR = NULL; - - test_icd_app_log("clCreateEventFromGLsyncKHR(%p, %p, %p)\n", - context, - data->sync, - data->errcode_ret); - - pfn_clCreateEventFromGLsyncKHR = clGetExtensionFunctionAddress("clCreateEventFromGLsyncKHR"); - if (!pfn_clCreateEventFromGLsyncKHR) { - test_icd_app_log("clGetExtensionFunctionAddress failed!\n"); - return 1; - } - - ret_event = pfn_clCreateEventFromGLsyncKHR (context, - data->sync, - data->errcode_ret); - - test_icd_app_log("Value returned: %p\n", ret_event); - return 0; -} - -struct clGetGLContextInfoKHR_st clGetGLContextInfoKHRData[NUM_ITEMS_clGetGLContextInfoKHR] = { - {NULL, 0, 0, NULL, NULL} -}; - -typedef CL_API_ENTRY cl_int -(CL_API_CALL *PFN_clGetGLContextInfoKHR)(const cl_context_properties * /* properties */, - cl_gl_context_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */); - -int test_clGetGLContextInfoKHR(const struct clGetGLContextInfoKHR_st* data) -{ - PFN_clGetGLContextInfoKHR pfn_clGetGLContextInfoKHR = NULL; - test_icd_app_log("clGetGLContextInfoKHR(%p, %u, %u, %p, %p)\n", - context_properties, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - pfn_clGetGLContextInfoKHR = clGetExtensionFunctionAddress("clGetGLContextInfoKHR"); - if (!pfn_clGetGLContextInfoKHR) { - test_icd_app_log("clGetExtensionFunctionAddress failed!\n"); - return 1; - } - - ret_val = pfn_clGetGLContextInfoKHR(context_properties, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - test_icd_app_log("Value returned: %p\n", ret_val); - return 0; - -} - -int test_OpenGL_share() -{ - int i; - - for(i=0;i - -#define CL_USE_DEPRECATED_OPENCL_1_0_APIS -#define CL_USE_DEPRECATED_OPENCL_1_1_APIS - -#include -#include "param_struct.h" -#include - -extern void CL_CALLBACK createcontext_callback(const char* a, const void* b, size_t c, void* d); - -cl_platform_id* all_platforms; -cl_platform_id platform; -cl_uint num_platforms; -cl_context context; -cl_command_queue command_queue; -cl_mem buffer; -cl_mem subBuffer; -cl_mem image; -cl_sampler sampler; -cl_program program; -cl_kernel kernel; -cl_event event; -cl_device_id devices; -cl_context_properties context_properties[3] = { - (cl_context_properties)CL_CONTEXT_PLATFORM, - 0, - 0, -}; - -const struct clGetDeviceIDs_st clGetDeviceIDsData[NUM_ITEMS_clGetDeviceIDs] = -{ - {NULL, 0, 1, NULL, NULL} -}; - -const struct clCreateSampler_st clCreateSamplerData[NUM_ITEMS_clCreateSampler] = -{ - {NULL, 0x0, 0, 0, NULL}, -}; - -const struct clCreateCommandQueue_st clCreateCommandQueueData[NUM_ITEMS_clCreateCommandQueue] = -{ - {NULL, NULL, 0, NULL} -}; - -const struct clCreateContext_st clCreateContextData[NUM_ITEMS_clCreateContext] = -{ - {NULL, 1, NULL, NULL, NULL, NULL} -}; - -const struct clCreateContextFromType_st clCreateContextFromTypeData[NUM_ITEMS_clCreateContextFromType] = -{ - {NULL, 0, createcontext_callback, NULL, NULL} -}; - -const struct clCreateBuffer_st clCreateBufferData[NUM_ITEMS_clCreateBuffer] = -{ - {NULL, 0, 0, NULL, NULL} -}; - -const struct clCreateSubBuffer_st clCreateSubBufferData[NUM_ITEMS_clCreateSubBuffer] = -{ - {NULL, 0, 0, NULL, NULL} -}; - -const struct clCreateImage_st clCreateImageData[NUM_ITEMS_clCreateImage] = -{ - { NULL, 0x0, NULL, NULL, NULL, NULL} -}; - -const struct clCreateImage2D_st clCreateImage2DData[NUM_ITEMS_clCreateImage2D] = -{ - { NULL, 0x0, NULL, 0, 0, 0, NULL, NULL} -}; - -const struct clCreateImage3D_st clCreateImage3DData[NUM_ITEMS_clCreateImage3D] = -{ - { NULL, 0x0, NULL, 0, 0, 0, 0, 0, NULL, NULL } -}; - - -struct clReleaseMemObject_st clReleaseMemObjectData[NUM_ITEMS_clReleaseMemObject] = -{ - {NULL} -}; - -struct clReleaseMemObject_st clReleaseMemObjectDataImage[NUM_ITEMS_clReleaseMemObject] = -{ - {NULL} -};const struct clCreateProgramWithSource_st clCreateProgramWithSourceData[NUM_ITEMS_clCreateProgramWithSource] = -{ - {NULL, 0, NULL, NULL, NULL} -}; - -const struct clCreateProgramWithBinary_st clCreateProgramWithBinaryData[NUM_ITEMS_clCreateProgramWithBinary] = -{ - {NULL, 0, NULL, NULL, NULL, NULL, NULL} -}; - -const struct clCreateProgramWithBuiltInKernels_st clCreateProgramWithBuiltInKernelsData[NUM_ITEMS_clCreateProgramWithBuiltInKernels] = -{ - {NULL, 0, NULL, NULL, NULL} -}; - -const struct clCreateKernel_st clCreateKernelData[NUM_ITEMS_clCreateKernel] = -{ - {NULL, NULL, NULL} -}; - -const struct clCreateKernelsInProgram_st clCreateKernelsInProgramData[NUM_ITEMS_clCreateKernelsInProgram] = -{ - {NULL, 0, NULL, NULL} -}; - -const struct clCreateUserEvent_st clCreateUserEventData[NUM_ITEMS_clCreateUserEvent] = -{ - {NULL, NULL} -}; - -const struct clGetPlatformIDs_st clGetPlatformIDsData[NUM_ITEMS_clGetPlatformIDs] = -{ - {0, NULL, 0} -}; - -/* - * Some log messages cause log mismatches when ICD loader calls a driver - * function while initializing platforms. The functions clGetPlatform* are most - * likely to be called at that time. But nothing stops an ICD loader from - * calling a ICD driver function anytime. - * - * FIXME: Figure out a good way to handle this. - */ -#define ENABLE_MISMATCHING_PRINTS 0 - -int test_clGetPlatformIDs(const struct clGetPlatformIDs_st* data) -{ - cl_int ret_val; - size_t param_val_ret_size; - #define PLATFORM_NAME_SIZE 40 - char platform_name[PLATFORM_NAME_SIZE]; - cl_uint i; - -#if ENABLE_MISMATCHING_PRINTS - test_icd_app_log("clGetPlatformIDs(%u, %p, %p)\n", - data->num_entries, - &platforms, - &num_platforms); -#endif - - ret_val = clGetPlatformIDs(0, - NULL, - &num_platforms); - - if (ret_val != CL_SUCCESS){ - return -1; - } - - all_platforms = (cl_platform_id *) malloc (num_platforms * sizeof(cl_platform_id)); - - ret_val = clGetPlatformIDs(num_platforms, - all_platforms, - NULL); - - if (ret_val != CL_SUCCESS){ - return -1; - } - - for (i = 0; i < num_platforms; i++) { - ret_val = clGetPlatformInfo(all_platforms[i], - CL_PLATFORM_NAME, - PLATFORM_NAME_SIZE, - (void*)platform_name, - ¶m_val_ret_size ); - - if (ret_val == CL_SUCCESS ){ - if(!strcmp(platform_name, "ICD_LOADER_TEST_OPENCL_STUB")) { - platform = all_platforms[i]; - } - } - } - -#if ENABLE_MISMATCHING_PRINTS - test_icd_app_log("Value returned: %d\n", ret_val); -#endif - - return 0; - -} - -int test_clGetDeviceIDs(const struct clGetDeviceIDs_st* data) -{ - int ret_val; - - test_icd_app_log("clGetDeviceIDs(%p, %x, %u, %p, %p)\n", - platform, - data->device_type, - data->num_entries, - &devices, - data->num_devices); - - ret_val = clGetDeviceIDs(platform, - data->device_type, - data->num_entries, - &devices, - data->num_devices); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - -int test_clCreateContext(const struct clCreateContext_st* data) -{ - test_icd_app_log("clCreateContext(%p, %u, %p, %p, %p, %p)\n", - data->properties, - data->num_devices, - &devices, - &createcontext_callback, - data->user_data, - data->errcode_ret); - - context = clCreateContext(data->properties, - data->num_devices, - &devices, - &createcontext_callback, - data->user_data, - data->errcode_ret); - - test_icd_app_log("Value returned: %p\n", context); - - return 0; - -} - -int test_clCreateContextFromType(const struct clCreateContextFromType_st* data) -{ - test_icd_app_log("clCreateContextFromType(%p, %x, %p, %p, %p)\n", - context_properties, - data->device_type, - data->pfn_notify, - data->user_data, - data->errcode_ret); - - - context = clCreateContextFromType(context_properties, - data->device_type, - data->pfn_notify, - data->user_data, - data->errcode_ret); - - test_icd_app_log("Value returned: %p\n", context); - - return 0; - -} - -int test_clCreateCommandQueue(const struct clCreateCommandQueue_st *data) -{ - test_icd_app_log("clCreateCommandQueue(%p, %p, %x, %p)\n", - context, - devices, - data->properties, - data->errcode_ret); - - command_queue = clCreateCommandQueue(context, - devices, - data->properties, - data->errcode_ret); - - test_icd_app_log("Value returned: %p\n", command_queue); - - return 0; - -} - -int test_clCreateBuffer(const struct clCreateBuffer_st *data) -{ - test_icd_app_log("clCreateBuffer(%p, %x, %u, %p, %p)\n", - context, - data->flags, - data->size, - data->host_ptr, - data->errcode_ret); - - buffer = clCreateBuffer(context, - data->flags, - data->size, - data->host_ptr, - data->errcode_ret); - - clReleaseMemObjectData->memobj = buffer; - - test_icd_app_log("Value returned: %p\n", buffer); - - return 0; - -} - -int test_clCreateSubBuffer(const struct clCreateSubBuffer_st *data) -{ - test_icd_app_log("clCreateSubBuffer(%p, %x, %u, %p, %p)\n", - buffer, - data->flags, - data->buffer_create_type, - data->buffer_create_info, - data->errcode_ret); - - subBuffer = clCreateSubBuffer(buffer, - data->flags, - data->buffer_create_type, - data->buffer_create_info, - data->errcode_ret); - - clReleaseMemObjectData->memobj = buffer; - - test_icd_app_log("Value returned: %p\n", subBuffer); - - return 0; - -} - -int test_clCreateImage(const struct clCreateImage_st *data) -{ - test_icd_app_log("clCreateImage(%p, %x, %p, %p, %p, %p)\n", - context, - data->flags, - data->image_format, - data->image_desc, - data->host_ptr, - data->errcode_ret); - - image = clCreateImage(context, - data->flags, - data->image_format, - data->image_desc, - data->host_ptr, - data->errcode_ret); - - clReleaseMemObjectDataImage[0].memobj = image; - test_icd_app_log("Value returned: %p\n", image); - - return 0; - -} - -int test_clCreateImage2D(const struct clCreateImage2D_st *data) -{ - test_icd_app_log("clCreateImage2D(%p, %x, %p, %u, %u, %u, %p, %p)\n", - context, - data->flags, - data->image_format, - data->image_width, - data->image_height, - data->image_row_pitch, - data->host_ptr, - data->errcode_ret); - - image = clCreateImage2D(context, - data->flags, - data->image_format, - data->image_width, - data->image_height, - data->image_row_pitch, - data->host_ptr, - data->errcode_ret); - - clReleaseMemObjectDataImage[0].memobj = image; - test_icd_app_log("Value returned: %p\n", image); - - return 0; - -} - -int test_clCreateImage3D(const struct clCreateImage3D_st *data) -{ - test_icd_app_log("clCreateImage3D(%p, %x, %p, %u, %u, %u, %u, %u, %p, %p)\n", - context, - data->flags, - data->image_format, - data->image_width, - data->image_height, - data->image_depth, - data->image_row_pitch, - data->image_slice_pitch, - data->host_ptr, - data->errcode_ret); - - image = clCreateImage3D(context, - data->flags, - data->image_format, - data->image_width, - data->image_height, - data->image_depth, - data->image_row_pitch, - data->image_slice_pitch, - data->host_ptr, - data->errcode_ret); - - clReleaseMemObjectDataImage[0].memobj = image; - test_icd_app_log("Value returned: %p\n", image); - - return 0; - -} - -int test_clCreateSampler(const struct clCreateSampler_st *data) -{ - test_icd_app_log("clCreateSampler(%p, %u, %u, %u, %p)\n", - context, - data->normalized_coords, - data->addressing_mode, - data->filter_mode, - data->errcode_ret); - - sampler = clCreateSampler(context, - data->normalized_coords, - data->addressing_mode, - data->filter_mode, - data->errcode_ret); - - test_icd_app_log("Value returned: %p\n", sampler); - - return 0; - -} - -int test_clCreateProgramWithSource(const struct clCreateProgramWithSource_st *data) -{ - test_icd_app_log("clCreateProgramWithSource(%p, %u, %p, %p, %p)\n", - context, - data->count, - data->strings, - data->lengths, - data->errcode_ret); - - program = clCreateProgramWithSource(context, - data->count, - data->strings, - data->lengths, - data->errcode_ret); - - test_icd_app_log("Value returned: %p\n", program); - - return 0; - -} - -int test_clCreateProgramWithBinary(const struct clCreateProgramWithBinary_st *data) -{ - test_icd_app_log("clCreateProgramWithBinary(%p, %u, %p, %p, %p, %p, %p)\n", - context, - data->num_devices, - &devices, - data->lengths, - data->binaries, - data->binary_status, - data->errcode_ret); - - program = clCreateProgramWithBinary(context, - data->num_devices, - &devices, - data->lengths, - data->binaries, - data->binary_status, - data->errcode_ret); - - test_icd_app_log("Value returned: %p\n", program); - - return 0; - -} - -int test_clCreateProgramWithBuiltInKernels(const struct clCreateProgramWithBuiltInKernels_st *data) -{ - test_icd_app_log("clCreateProgramWithBuiltInKernels(%p, %u, %p, %p, %p)\n", - context, - data->num_devices, - &devices, - data->kernel_names, - data->errcode_ret); - - program = clCreateProgramWithBuiltInKernels(context, - data->num_devices, - &devices, - data->kernel_names, - data->errcode_ret); - - test_icd_app_log("Value returned: %p\n", program); - - return 0; - -} - -int test_clCreateKernel(const struct clCreateKernel_st* data) -{ - test_icd_app_log("clCreateKernel(%p, %p, %p)\n", - program, - data->kernel_name, - data->errcode_ret); - - kernel = clCreateKernel(program, - data->kernel_name, - data->errcode_ret); - - test_icd_app_log("Value returned: %p\n", kernel); - - return 0; - -} - -int test_clCreateKernelsInProgram(const struct clCreateKernelsInProgram_st* data) -{ - int ret_val; - test_icd_app_log("clCreateKernelsInProgram(%p, %u, %p, %p)\n", - program, - data->num_kernels, - &kernel, - data->num_kernels_ret); - - ret_val = clCreateKernelsInProgram(program, - data->num_kernels, - &kernel, - data->num_kernels_ret); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - -int test_clCreateUserEvent(const struct clCreateUserEvent_st* data) -{ - test_icd_app_log("clCreateUserEvent(%p, %p)\n", - context, - data->errcode_ret); - - event = clCreateUserEvent(context, - data->errcode_ret); - - test_icd_app_log("Value returned: %p\n", event); - - return 0; - -} - -const struct clReleaseSampler_st clReleaseSamplerData[NUM_ITEMS_clReleaseSampler] = -{ - { NULL } -}; - -int test_clReleaseSampler(const struct clReleaseSampler_st *data) -{ - int ret_val = CL_OUT_OF_RESOURCES; - - test_icd_app_log("clReleaseSampler(%p)\n", sampler); - - ret_val = clReleaseSampler(sampler); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - - -int test_clReleaseMemObject(const struct clReleaseMemObject_st *data) -{ - int ret_val = -15; - test_icd_app_log("clReleaseMemObject(%p)\n", data->memobj); - - ret_val = clReleaseMemObject(data->memobj); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; -} - -const struct clReleaseEvent_st clReleaseEventData[NUM_ITEMS_clReleaseEvent] = -{ - {NULL} -}; - -int test_clReleaseEvent(const struct clReleaseEvent_st* data) -{ - int ret_val = CL_OUT_OF_RESOURCES; - - test_icd_app_log("clReleaseEvent(%p)\n", event); - - ret_val = clReleaseEvent(event); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - -const struct clReleaseKernel_st clReleaseKernelData[NUM_ITEMS_clReleaseKernel] = -{ - {NULL} -}; - -int test_clReleaseKernel(const struct clReleaseKernel_st* data) -{ - int ret_val = CL_OUT_OF_RESOURCES; - - test_icd_app_log("clReleaseKernel(%p)\n", kernel); - - ret_val = clReleaseKernel(kernel); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - -const struct clReleaseProgram_st clReleaseProgramData[NUM_ITEMS_clReleaseProgram] = -{ - {NULL} -}; - -int test_clReleaseProgram(const struct clReleaseProgram_st *data) -{ - int ret_val = CL_OUT_OF_RESOURCES; - - test_icd_app_log("clReleaseProgram(%p)\n", program); - - ret_val = clReleaseProgram(program); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - -const struct clReleaseCommandQueue_st clReleaseCommandQueueData[NUM_ITEMS_clReleaseCommandQueue] = -{ - {NULL} -}; - -int test_clReleaseCommandQueue(const struct clReleaseCommandQueue_st *data) -{ - int ret_val = CL_OUT_OF_RESOURCES; - - test_icd_app_log("clReleaseCommandQueue(%p)\n", command_queue); - - ret_val = clReleaseCommandQueue(command_queue); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - -const struct clReleaseContext_st clReleaseContextData[NUM_ITEMS_clReleaseContext] = -{ - {NULL} -}; - -int test_clReleaseContext(const struct clReleaseContext_st* data) -{ - int ret_val = CL_OUT_OF_RESOURCES; - - test_icd_app_log("clReleaseContext(%p)\n", context); - - ret_val = clReleaseContext(context); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - -const struct clReleaseDevice_st clReleaseDeviceData[NUM_ITEMS_clReleaseDevice] = -{ - {NULL} -}; - -int test_clReleaseDevice(const struct clReleaseDevice_st* data) -{ - int ret_val = CL_OUT_OF_RESOURCES; - - test_icd_app_log("clReleaseDevice(%p)\n", devices); - - ret_val = clReleaseDevice(devices); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - -int test_create_calls() -{ - test_clGetPlatformIDs(clGetPlatformIDsData); - - context_properties[1] = (cl_context_properties) platform; - - test_clGetDeviceIDs(clGetDeviceIDsData); - - test_clCreateContext(clCreateContextData); - - test_clReleaseContext(clReleaseContextData); - - test_clCreateContextFromType(clCreateContextFromTypeData); - - test_clCreateCommandQueue(clCreateCommandQueueData); - - test_clCreateBuffer(clCreateBufferData); - - test_clCreateSubBuffer(clCreateSubBufferData); - - test_clCreateImage(clCreateImageData); - - test_clReleaseMemObject(clReleaseMemObjectDataImage); - - test_clCreateImage2D(clCreateImage2DData); - - test_clReleaseMemObject(clReleaseMemObjectDataImage); - - test_clCreateImage3D(clCreateImage3DData); - - test_clCreateSampler(clCreateSamplerData); - - test_clCreateProgramWithSource(clCreateProgramWithSourceData); - - test_clReleaseProgram(clReleaseProgramData); - - test_clCreateProgramWithBinary(clCreateProgramWithBinaryData); - - test_clReleaseProgram(clReleaseProgramData); - - test_clCreateProgramWithBuiltInKernels(clCreateProgramWithBuiltInKernelsData); - - test_clCreateKernel(clCreateKernelData); - - test_clCreateKernelsInProgram(clCreateKernelsInProgramData); - - test_clCreateUserEvent(clCreateUserEventData); - - return 0; - -} - -int test_release_calls() -{ - test_clReleaseSampler(clReleaseSamplerData); - - test_clReleaseMemObject(clReleaseMemObjectData); - - test_clReleaseMemObject(clReleaseMemObjectDataImage); - - test_clReleaseEvent(clReleaseEventData); - - test_clReleaseKernel(clReleaseKernelData); - - test_clReleaseProgram(clReleaseProgramData); - - test_clReleaseCommandQueue(clReleaseCommandQueueData); - - test_clReleaseContext(clReleaseContextData); - - test_clReleaseDevice(clReleaseDeviceData); - - return 0; -} - diff --git a/khronos_icd/test/loader_test/test_image_objects.c b/khronos_icd/test/loader_test/test_image_objects.c deleted file mode 100644 index 0c47d1300..000000000 --- a/khronos_icd/test/loader_test/test_image_objects.c +++ /dev/null @@ -1,362 +0,0 @@ -#include -#include "param_struct.h" -#include - -extern cl_mem image; -extern cl_context context; -extern cl_command_queue command_queue; -extern cl_event event; -extern cl_mem buffer; - -int ret_val; - -const struct clGetSupportedImageFormats_st clGetSupportedImageFormatsData[NUM_ITEMS_clGetSupportedImageFormats] = -{ - { NULL, 0x0, 0, 0, NULL, NULL } -}; - -const struct clEnqueueCopyImageToBuffer_st clEnqueueCopyImageToBufferData[NUM_ITEMS_clEnqueueCopyImageToBuffer] = -{ - { NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, NULL } -}; - -const struct clEnqueueCopyBufferToImage_st clEnqueueCopyBufferToImageData[NUM_ITEMS_clEnqueueCopyBufferToImage] = -{ - { NULL, NULL, NULL, 0, NULL, NULL, 0, NULL, NULL } -}; - -const struct clEnqueueMapImage_st clEnqueueMapImageData[NUM_ITEMS_clEnqueueMapImage] = -{ - { NULL, NULL, 0, 0x0, NULL, NULL, NULL, NULL,0, NULL, NULL} -}; - -const struct clEnqueueReadImage_st clEnqueueReadImageData[NUM_ITEMS_clEnqueueReadImage] = -{ - { NULL, NULL, 0, NULL, NULL, 0, 0, NULL, 0, NULL, NULL } -}; - -const struct clEnqueueWriteImage_st clEnqueueWriteImageData[NUM_ITEMS_clEnqueueWriteImage] = -{ - { NULL, NULL, 0, NULL, NULL, 0, 0, NULL, 0, NULL, NULL } -}; - -const struct clEnqueueFillImage_st clEnqueueFillImageData[NUM_ITEMS_clEnqueueFillImage] = -{ - { NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL } -}; - -const struct clEnqueueCopyImage_st clEnqueueCopyImageData[NUM_ITEMS_clEnqueueCopyImage] = -{ - { NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL } -}; - -const struct clGetImageInfo_st clGetImageInfoData[NUM_ITEMS_clGetImageInfo] = -{ - { NULL, 0, 0, NULL, NULL} -}; - -int test_clGetSupportedImageFormats(const struct clGetSupportedImageFormats_st *data) -{ - test_icd_app_log("clGetSupportedImageFormats(%p, %x, %u, %u, %p, %p)\n", - context, - data->flags, - data->image_type, - data->num_entries, - data->image_formats, - data->num_image_formats); - - ret_val = clGetSupportedImageFormats(context, - data->flags, - data->image_type, - data->num_entries, - data->image_formats, - data->num_image_formats); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - -int test_clEnqueueCopyImageToBuffer(const struct clEnqueueCopyImageToBuffer_st *data) -{ - test_icd_app_log("clEnqueueCopyImageToBuffer(%p, %p, %p, %p, %p, %u, %u, %p, %p)\n", - command_queue, - image, - buffer, - data->src_origin, - data->region, - data->dst_offset, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - ret_val = clEnqueueCopyImageToBuffer(command_queue, - image, - buffer, - data->src_origin, - data->region, - data->dst_offset, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - -int test_clEnqueueCopyBufferToImage(const struct clEnqueueCopyBufferToImage_st *data) -{ - test_icd_app_log("clEnqueueCopyBufferToImage(%p, %p, %p, %u, %p, %p, %u, %p, %p)\n", - command_queue, - buffer, - image, - data->src_offset, - data->dst_origin, - data->region, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - ret_val = clEnqueueCopyBufferToImage(command_queue, - buffer, - image, - data->src_offset, - data->dst_origin, - data->region, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - -int test_clEnqueueMapImage(const struct clEnqueueMapImage_st *data) -{ - void *return_value; - test_icd_app_log("clEnqueueMapImage(%p, %p, %u, %x, %p, %p, %p, %p, %u, %p, %p, %p)\n", - command_queue, - image, - data->blocking_map, - data->map_flags, - data->origin, - data->region, - data->image_row_pitch, - data->image_slice_pitch, - data->num_events_in_wait_list, - data->event_wait_list, - &event, - data->errcode_ret); - - return_value = clEnqueueMapImage(command_queue, - image, - data->blocking_map, - data->map_flags, - data->origin, - data->region, - data->image_row_pitch, - data->image_slice_pitch, - data->num_events_in_wait_list, - data->event_wait_list, - &event, - data->errcode_ret); - - test_icd_app_log("Value returned: %p\n", return_value); - - free(return_value); - - return 0; - -} - -int test_clEnqueueReadImage(const struct clEnqueueReadImage_st *data) -{ - test_icd_app_log("clEnqueueReadImage(%p, %p, %u, %p, %p, %u, %u, %p, %u, %p, %p)\n", - command_queue, - image, - data->blocking_read, - data->origin, - data->region, - data->row_pitch, - data->slice_pitch, - data->ptr, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - ret_val = clEnqueueReadImage(command_queue, - image, - data->blocking_read, - data->origin, - data->region, - data->row_pitch, - data->slice_pitch, - data->ptr, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - -int test_clEnqueueWriteImage(const struct clEnqueueWriteImage_st *data) -{ - test_icd_app_log("clEnqueueWriteImage(%p, %p, %u, %p, %p, %u, %u, %p, %u, %p, %p)\n", - command_queue, - image, - data->blocking_write, - data->origin, - data->region, - data->input_row_pitch, - data->input_slice_pitch, - data->ptr, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - ret_val = clEnqueueWriteImage(command_queue, - image, - data->blocking_write, - data->origin, - data->region, - data->input_row_pitch, - data->input_slice_pitch, - data->ptr, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - -int test_clEnqueueFillImage(const struct clEnqueueFillImage_st *data) -{ - test_icd_app_log("clEnqueueFillImage(%p, %p, %p, %p, %p, %u, %p, %p)\n", - command_queue, - image, - data->fill_color, - data->origin, - data->region, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - ret_val = clEnqueueFillImage(command_queue, - image, - data->fill_color, - data->origin, - data->region, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} -int test_clEnqueueCopyImage(const struct clEnqueueCopyImage_st *data) -{ - test_icd_app_log("clEnqueueCopyImage(%p, %p, %p, %p, %p, %p, %u, %p, %p)\n", - command_queue, - image, - image, - data->src_origin, - data->dst_origin, - data->region, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - ret_val = clEnqueueCopyImage(command_queue, - image, - image, - data->src_origin, - data->dst_origin, - data->region, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - - -int test_clGetImageInfo(const struct clGetImageInfo_st *data) -{ - test_icd_app_log("clGetImageInfo(%p, %u, %u, %p, %p)\n", - image, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - ret_val = clGetImageInfo(image, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - -int test_image_objects() -{ - int i; - - for (i = 0; i -#include "param_struct.h" -#include - -extern cl_kernel kernel; -extern cl_event event; -extern cl_context context; -extern cl_command_queue command_queue; -extern cl_device_id devices; -int ret_val; -extern void CL_CALLBACK setevent_callback(cl_event _a, cl_int _b, void* _c); -extern void CL_CALLBACK setprintf_callback(cl_context _a, cl_uint _b, char* _c, void* _d ); - -struct clRetainKernel_st clRetainKernelData[NUM_ITEMS_clRetainKernel] = -{ - {NULL} -}; - -int test_clRetainKernel(const struct clRetainKernel_st* data) -{ - test_icd_app_log("clRetainKernel(%p)\n", kernel); - - ret_val=clRetainKernel(kernel); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; -} - -struct clSetKernelArg_st clSetKernelArgData[NUM_ITEMS_clSetKernelArg] = -{ - {NULL, 0, 0, NULL} -}; - -int test_clSetKernelArg(const struct clSetKernelArg_st* data) -{ - test_icd_app_log("clSetKernelArg(%p, %u, %u, %p)\n", - kernel, - data->arg_index, - data->arg_size, - data->arg_value); - - ret_val=clSetKernelArg(kernel, - data->arg_index, - data->arg_size, - data->arg_value); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; -} - -struct clGetKernelInfo_st clGetKernelInfoData[NUM_ITEMS_clGetKernelInfo] = -{ - {NULL, 0, 0, NULL, NULL} -}; - -int test_clGetKernelInfo(const struct clGetKernelInfo_st* data) -{ - test_icd_app_log("clGetKernelInfo(%p, %u, %u, %p, %p)\n", - kernel, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - ret_val=clGetKernelInfo(kernel, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; -} - -struct clGetKernelArgInfo_st clGetKernelArgInfoData[NUM_ITEMS_clGetKernelArgInfo] = -{ - {NULL, 0, 0, 0, NULL, NULL} -}; - -int test_clGetKernelArgInfo(const struct clGetKernelArgInfo_st* data) -{ - test_icd_app_log("clGetKernelArgInfo(%p, %u, %u, %u, %p, %p)\n", - kernel, - data->arg_indx, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - ret_val=clGetKernelArgInfo(kernel, - data->arg_indx, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; -} - -struct clGetKernelWorkGroupInfo_st clGetKernelWorkGroupInfoData[NUM_ITEMS_clGetKernelWorkGroupInfo] = -{ - {NULL, NULL, 0, 0, NULL, NULL} -}; - -int test_clGetKernelWorkGroupInfo(const struct clGetKernelWorkGroupInfo_st* data) -{ - test_icd_app_log("clGetKernelWorkGroupInfo(%p, %p, %u, %u, %p, %p)\n", - kernel, - devices, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - ret_val=clGetKernelWorkGroupInfo(kernel, - devices, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; -} - -struct clEnqueueMigrateMemObjects_st clEnqueueMigrateMemObjectsData[NUM_ITEMS_clEnqueueMigrateMemObjects] = -{ - {NULL, 0, NULL, 0x0, 0, NULL, NULL} -}; - -int test_clEnqueueMigrateMemObjects(const struct clEnqueueMigrateMemObjects_st* data) -{ - test_icd_app_log("clEnqueueMigrateMemObjects(%p, %u, %p, %x, %u, %p, %p)\n", - command_queue, - data->num_mem_objects, - data->mem_objects, - data->flags, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - ret_val=clEnqueueMigrateMemObjects(command_queue, - data->num_mem_objects, - data->mem_objects, - data->flags, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; -} - -struct clEnqueueNDRangeKernel_st clEnqueueNDRangeKernelData[NUM_ITEMS_clEnqueueNDRangeKernel] = -{ - {NULL, NULL, 0, NULL, NULL, NULL, 0, NULL} -}; - -int test_clEnqueueNDRangeKernel(const struct clEnqueueNDRangeKernel_st* data) -{ - test_icd_app_log("clEnqueueNDRangeKernel(%p, %p, %u, %p, %p, %p, %u, %p, %p)\n", - command_queue, - kernel, - data->work_dim, - data->global_work_offset, - data->global_work_size, - data->local_work_size, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - ret_val=clEnqueueNDRangeKernel(command_queue, - kernel, - data->work_dim, - data->global_work_offset, - data->global_work_size, - data->local_work_size, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; -} - -struct clEnqueueTask_st clEnqueueTaskData[NUM_ITEMS_clEnqueueTask] = -{ - {NULL, NULL, 0, NULL, NULL} -}; - -int test_clEnqueueTask(const struct clEnqueueTask_st* data) -{ - test_icd_app_log("clEnqueueTask(%p, %p, %u, %p, %p)\n", - command_queue, - kernel, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - ret_val=clEnqueueTask(command_queue, - kernel, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; -} -struct clEnqueueNativeKernel_st clEnqueueNativeKernelData[NUM_ITEMS_clEnqueueNativeKernel] = -{ - {NULL, NULL, NULL, 0, 0, NULL, NULL, 0, NULL, NULL} -}; - -int test_clEnqueueNativeKernel(const struct clEnqueueNativeKernel_st* data) { - test_icd_app_log("clEnqueueNativeKernel(%p, %p, %p, %u, %u, %p, %p, %u, %p, %p)\n", - command_queue, - data->user_func, - data->args, - data->cb_args, - data->num_mem_objects, - data->mem_list, - data->args_mem_loc, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - ret_val=clEnqueueNativeKernel(command_queue, - data->user_func, - data->args, - data->cb_args, - data->num_mem_objects, - data->mem_list, - data->args_mem_loc, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - test_icd_app_log("Value returned: %d\n", ret_val); - return 0; -} - -struct clSetUserEventStatus_st clSetUserEventStatusData[NUM_ITEMS_clSetUserEventStatus] = -{ - {NULL, 0} -}; - -int test_clSetUserEventStatus(const struct clSetUserEventStatus_st* data) -{ - test_icd_app_log("clSetUserEventStatus(%p, %d)\n", - event, - data->execution_status); - - ret_val=clSetUserEventStatus(event, - data->execution_status); - - test_icd_app_log("Value returned: %d\n", ret_val); - return 0; -} - -struct clWaitForEvents_st clWaitForEventsData[NUM_ITEMS_clWaitForEvents] = -{ - {1, NULL} -}; - -int test_clWaitForEvents(const struct clWaitForEvents_st* data) -{ - test_icd_app_log("clWaitForEvents(%u, %p)\n", - data->num_events, - &event); - - ret_val=clWaitForEvents(data->num_events, - &event); - - test_icd_app_log("Value returned: %d\n", ret_val); - return 0; -} - -struct clGetEventInfo_st clGetEventInfoData[NUM_ITEMS_clGetEventInfo] = -{ - {NULL, 0, 0, NULL, NULL} -}; - -int test_clGetEventInfo(const struct clGetEventInfo_st* data){ - test_icd_app_log("clGetEventInfo(%p, %u, %u, %p, %p)\n", - event, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - ret_val=clGetEventInfo(event, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; -} - -struct clSetEventCallback_st clSetEventCallbackData[NUM_ITEMS_clSetEventCallback] = -{ - {NULL, 0, setevent_callback, NULL} -}; - -int test_clSetEventCallback(const struct clSetEventCallback_st* data) -{ - test_icd_app_log("clSetEventCallback(%p, %d, %p, %p)\n", - event, - data->command_exec_callback_type, - data->pfn_event_notify, - data->user_data); - - ret_val=clSetEventCallback(event, - data->command_exec_callback_type, - data->pfn_event_notify, - data->user_data); - - test_icd_app_log("Value returned: %d\n", ret_val); - return 0; -} - -struct clRetainEvent_st clRetainEventData[NUM_ITEMS_clRetainEvent] = -{ - {NULL} -}; - -int test_clRetainEvent(const struct clRetainEvent_st* data) -{ - test_icd_app_log("clRetainEvent(%p)\n", event); - - ret_val=clRetainEvent(event); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; -} - -struct clEnqueueMarker_st clEnqueueMarkerData[NUM_ITEMS_clEnqueueMarker] = -{ - {NULL, NULL} -}; - -int test_clEnqueueMarker(const struct clEnqueueMarker_st* data) -{ - test_icd_app_log("clEnqueueMarker(%p, %p)\n", command_queue, &event); - - ret_val = clEnqueueMarker(command_queue, &event); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; -} - -struct clEnqueueMarkerWithWaitList_st clEnqueueMarkerWithWaitListData[NUM_ITEMS_clEnqueueMarkerWithWaitList] = -{ - {NULL, 0, NULL, NULL} -}; - -int test_clEnqueueMarkerWithWaitList(const struct clEnqueueMarkerWithWaitList_st* data) -{ - test_icd_app_log("clEnqueueMarkerWithWaitList(%p, %u, %p, %p)\n", - command_queue, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - ret_val=clEnqueueMarkerWithWaitList(command_queue, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; -} - -struct clEnqueueBarrierWithWaitList_st clEnqueueBarrierWithWaitListData[NUM_ITEMS_clEnqueueBarrierWithWaitList] = -{ - {NULL, 0, NULL, NULL} -}; -int test_clEnqueueBarrierWithWaitList(const struct clEnqueueBarrierWithWaitList_st* data) -{ - test_icd_app_log("clEnqueueBarrierWithWaitList(%p, %u, %p, %p)\n", - command_queue, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - ret_val=clEnqueueBarrierWithWaitList(command_queue, - data->num_events_in_wait_list, - data->event_wait_list, - &event); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; -} - -struct clEnqueueWaitForEvents_st clEnqueueWaitForEventsData[NUM_ITEMS_clEnqueueWaitForEvents] = -{ - {NULL, 0, NULL} -}; - -int test_clEnqueueWaitForEvents(const struct clEnqueueWaitForEvents_st* data) -{ - test_icd_app_log("clEnqueueWaitForEvents(%p, %u, %p)\n", - command_queue, - data->num_events, - data->event_list); - - ret_val = clEnqueueWaitForEvents(command_queue, - data->num_events, - data->event_list); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; -} - -struct clEnqueueBarrier_st clEnqueueBarrierData[NUM_ITEMS_clEnqueueBarrier] = -{ - {NULL} -}; - -int test_clEnqueueBarrier(const struct clEnqueueBarrier_st* data) -{ - test_icd_app_log("clEnqueueBarrier(%p)\n", command_queue); - - ret_val = clEnqueueBarrier(command_queue); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; -} -struct clGetEventProfilingInfo_st clGetEventProfilingInfoData[NUM_ITEMS_clGetEventProfilingInfo] = -{ - {NULL, 0, 0, NULL, NULL} -}; - -int test_clGetEventProfilingInfo(const struct clGetEventProfilingInfo_st* data) -{ - test_icd_app_log("clGetEventProfilingInfo(%p, %u, %u, %p, %p)\n", - event, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - ret_val=clGetEventProfilingInfo(event, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; -} - -struct clFlush_st clFlushData[NUM_ITEMS_clFlush] = -{ - {NULL} -}; - -int test_clFlush(const struct clFlush_st* data) -{ - test_icd_app_log("clFlush(%p)\n", command_queue); - - ret_val=clFlush(command_queue); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; -} - -struct clFinish_st clFinishData[NUM_ITEMS_clFinish] = -{ - {NULL} -}; - -int test_clFinish(const struct clFinish_st* data) -{ - test_icd_app_log("clFinish(%p)\n", command_queue); - - ret_val=clFinish(command_queue); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; -} - -int test_kernel() -{ - int i; - - for (i=0; i -#include "param_struct.h" -#include - -extern cl_context context; - -extern cl_platform_id platform; - -extern cl_device_id devices; - -int ret_val; - -struct clRetainContext_st clRetainContextData[NUM_ITEMS_clRetainContext] = -{ - {NULL} -}; - -struct clGetContextInfo_st clGetContextInfoData[NUM_ITEMS_clGetContextInfo] = -{ - {NULL, 0, 0, NULL, NULL} -}; - - -struct clGetPlatformInfo_st clGetPlatformInfoData[NUM_ITEMS_clGetPlatformInfo] = -{ - {NULL, 0, 0, NULL, NULL} -}; - -struct clGetDeviceInfo_st clGetDeviceInfoData[NUM_ITEMS_clGetDeviceInfo] = -{ - {NULL, 0, 0, NULL, NULL} -}; - -struct clCreateSubDevices_st clCreateSubDevicesData[NUM_ITEMS_clCreateSubDevices] = -{ - {NULL, NULL, 0, NULL, NULL} -}; - - -struct clRetainDevice_st clRetainDeviceData[NUM_ITEMS_clRetainDevice] = -{ - {NULL} -}; - - -int test_clRetainContext(const struct clRetainContext_st* data) -{ - test_icd_app_log("clRetainContext(%p)\n", context); - - ret_val = clRetainContext(context); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; -} - - - -int test_clGetContextInfo(const struct clGetContextInfo_st* data) -{ - test_icd_app_log("clGetContextInfo(%p, %u, %u, %p, %p)\n", - context, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - - ret_val = clGetContextInfo(context, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; -} - -int test_clGetPlatformInfo(const struct clGetPlatformInfo_st* data) -{ - test_icd_app_log("clGetPlatformInfo(%p, %u, %u, %p, %p)\n", - platform, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - ret_val = clGetPlatformInfo(platform, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - -int test_clGetDeviceInfo(const struct clGetDeviceInfo_st* data) -{ - test_icd_app_log("clGetDeviceInfo(%p, %u, %u, %p, %p)\n", - devices, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - ret_val = clGetDeviceInfo(devices, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; -} - -int test_clCreateSubDevices(const struct clCreateSubDevices_st* data) -{ - test_icd_app_log("clCreateSubDevices(%p, %p, %u, %p, %p)\n", - devices, - data->properties, - data->num_entries, - &devices, - data->num_devices); - - ret_val = clCreateSubDevices(devices, - data->properties, - data->num_entries, - &devices, - data->num_devices); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; -} - -int test_clRetainDevice(const struct clRetainDevice_st* data) -{ - test_icd_app_log("clRetainDevice(%p)\n", devices); - - ret_val = clRetainDevice(devices); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; -} - -int test_platforms() -{ - int i; - - for (i = 0;i -#include "param_struct.h" -#include - -extern cl_context context; -extern cl_program program; -extern cl_platform_id platform; -extern cl_device_id devices; - -int ret_val; - -extern void CL_CALLBACK program_callback(cl_program _a, void* _b); - -const struct clRetainProgram_st clRetainProgramData[NUM_ITEMS_clRetainProgram]= -{ - {NULL} -}; - -const struct clBuildProgram_st clBuildProgramData[NUM_ITEMS_clBuildProgram]= -{ - {NULL,0,NULL,NULL,program_callback,NULL} -}; - -const struct clCompileProgram_st clCompileProgramData[NUM_ITEMS_clCompileProgram]= -{ - {NULL,0,NULL,NULL,0,NULL,NULL,program_callback,NULL} -}; - -const struct clLinkProgram_st clLinkProgramData[NUM_ITEMS_clLinkProgram]= -{ - {NULL,0,NULL,NULL,0,NULL,program_callback,NULL,NULL} -}; - -const struct clUnloadPlatformCompiler_st clUnloadPlatformCompilerData[NUM_ITEMS_clUnloadPlatformCompiler]= -{ - {NULL} -}; - -const struct clGetExtensionFunctionAddressForPlatform_st clGetExtensionFunctionAddressForPlatformData[NUM_ITEMS_clGetExtensionFunctionAddressForPlatform]= -{ - {NULL, ""} -}; - -const struct clGetProgramInfo_st clGetProgramInfoData[NUM_ITEMS_clGetProgramInfo]= -{ - {NULL,0,0,NULL,NULL} -}; - -const struct clGetProgramBuildInfo_st clGetProgramBuildInfoData[NUM_ITEMS_clGetProgramBuildInfo]= -{ - {NULL,NULL,0,0,NULL,NULL} -}; - -int test_clRetainProgram(const struct clRetainProgram_st *data) -{ - test_icd_app_log("clRetainProgram(%p)\n", - program); - - ret_val=clRetainProgram(program); - - test_icd_app_log("Value returned: %d\n", - ret_val); - - return 0; - -} - -int test_clBuildProgram(const struct clBuildProgram_st *data) -{ - test_icd_app_log("clBuildProgram(%p, %u, %p, %p, %p, %p)\n", - program, - data->num_devices, - &devices, - data->options, - data->pfn_notify, - data->user_data); - - ret_val=clBuildProgram(program, - data->num_devices, - &devices, - data->options, - data->pfn_notify, - data->user_data); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - -int test_clCompileProgram(const struct clCompileProgram_st *data) -{ - test_icd_app_log("clCompileProgram(%p, %u, %p, %p, %u, %p, %p, %p)\n", - program, - data->num_devices, - &devices, - data->options, - data->num_input_headers, - data->header_include_names, - data->pfn_notify, - data->user_data); - - ret_val=clCompileProgram(program, - data->num_devices, - &devices, - data->options, - data->num_input_headers, - data->headers, - data->header_include_names, - data->pfn_notify, - data->user_data); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - -int test_clLinkProgram(const struct clLinkProgram_st *data) -{ - cl_program program; - test_icd_app_log("clLinkProgram(%p, %u, %p, %p, %u, %p, %p, %p, %p)\n", - context, - data->num_devices, - data->device_list, - data->options, - data->num_input_programs, - data->input_programs, - data->pfn_notify, - data->user_data, - data->errcode_ret); - - program=clLinkProgram(context, - data->num_devices, - data->device_list, - data->options, - data->num_input_programs, - data->input_programs, - data->pfn_notify, - data->user_data, - data->errcode_ret); - - test_icd_app_log("Value returned: %p\n", program); - - return 0; - -} - -int test_clUnloadPlatformCompiler(const struct clUnloadPlatformCompiler_st *data) -{ - test_icd_app_log("clUnloadPlatformCompiler(%p)\n", platform); - - ret_val=clUnloadPlatformCompiler(platform); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - -int test_clGetExtensionFunctionAddressForPlatform(const struct clGetExtensionFunctionAddressForPlatform_st *data) -{ - void *return_value; - test_icd_app_log("clGetExtensionFunctionAddressForPlatform(%p, %p)\n", - platform, - data->func_name); - - return_value=clGetExtensionFunctionAddressForPlatform(platform, - data->func_name); - - test_icd_app_log("Value returned: %p\n", return_value); - - return 0; - -} - -int test_clGetProgramInfo(const struct clGetProgramInfo_st *data) -{ - test_icd_app_log("clGetProgramInfo(%p, %u, %u, %p, %p)\n", - program, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - ret_val=clGetProgramInfo(program, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - -int test_clGetProgramBuildInfo(const struct clGetProgramBuildInfo_st *data) -{ - test_icd_app_log("clGetProgramBuildInfo(%p, %p, %u, %u, %p, %p)\n", - program, - data->device, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - ret_val=clGetProgramBuildInfo(program, - data->device, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; - -} - -int test_program_objects() -{ - int i; - - for (i=0;i -#include "param_struct.h" -#include - -extern cl_sampler sampler; -int ret_val; - -const struct clRetainSampler_st clRetainSamplerData[NUM_ITEMS_clRetainSampler]= -{ - { NULL } -}; - -const struct clGetSamplerInfo_st clGetSamplerInfoData[NUM_ITEMS_clGetSamplerInfo]= -{ - { NULL, 0, 0, NULL, NULL } -}; - - -int test_clRetainSampler(const struct clRetainSampler_st *data) -{ - test_icd_app_log("clRetainSampler(%p)\n", sampler); - - ret_val=clRetainSampler(sampler); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; -} - -int test_clGetSamplerInfo(const struct clGetSamplerInfo_st *data) -{ - test_icd_app_log("clGetSamplerInfo(%p, %u, %u, %p, %p)\n", - sampler, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - ret_val=clGetSamplerInfo(sampler, - data->param_name, - data->param_value_size, - data->param_value, - data->param_value_size_ret); - - test_icd_app_log("Value returned: %d\n", ret_val); - - return 0; -} - -int test_sampler_objects() -{ - int i; - - for (i=0;i -#include -#include -#include -#include -#include - -#define APP_LOG_FILE "icd_test_app_log.txt" -#define STUB_LOG_FILE "icd_test_stub_log.txt" - -static FILE *app_log_file; -static FILE *stub_log_file; - -int test_icd_initialize_app_log(void) -{ - app_log_file = fopen(APP_LOG_FILE, "w"); - if (!app_log_file) { - printf("Unable to open file %s\n", APP_LOG_FILE); - return -1; - } -} - -void test_icd_close_app_log(void) -{ - fclose(app_log_file); -} - -void test_icd_app_log(const char *format, ...) -{ - va_list args; - va_start(args, format); - vfprintf(app_log_file, format, args); - va_end(args); -} - -int test_icd_initialize_stub_log(void) -{ - stub_log_file = fopen(STUB_LOG_FILE, "w"); - if (!stub_log_file) { - printf("Unable to open file %s\n", STUB_LOG_FILE); - return -1; - } -} - -void test_icd_close_stub_log(void) -{ - fclose(stub_log_file); -} - -void test_icd_stub_log(const char *format, ...) -{ - va_list args; - va_start(args, format); - vfprintf(stub_log_file, format, args); - va_end(args); -} - -static char *test_icd_get_log(const char *filename) -{ - struct stat statbuf; - FILE *fp; - char *source = NULL; - - fp = fopen(filename, "rb"); - - if (fp) { - size_t fsize = 0; - stat(filename, &statbuf); - fsize = statbuf.st_size; - source = (char *)malloc(fsize+1); // +1 for NULL terminator - if (source) { - if (fsize) { - if (fread(source, fsize, 1, fp) != 1) { - free(source); - source = NULL; - } else { - source[fsize] = '\0'; - } - } else { - // Don't fail when fsize = 0, just return empty string - source[fsize] = '\0'; - } - } - fclose(fp); - } - - return source; -} - -char *test_icd_get_app_log(void) -{ - return test_icd_get_log(APP_LOG_FILE); -} - -char *test_icd_get_stub_log(void) -{ - return test_icd_get_log(STUB_LOG_FILE); -} From 59e46ce19e81abba15c1e1b56940dcfc09fc9e1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Wed, 15 Jul 2015 20:46:14 +0200 Subject: [PATCH 21/62] cmake: Fix icd_exports.map path. --- khronos_icd/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/khronos_icd/CMakeLists.txt b/khronos_icd/CMakeLists.txt index 8ec311d36..c9a605ea4 100644 --- a/khronos_icd/CMakeLists.txt +++ b/khronos_icd/CMakeLists.txt @@ -12,6 +12,7 @@ set (OPENCL_ICD_LOADER_SOURCES icd.c icd_dispatch.c) if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") list (APPEND OPENCL_ICD_LOADER_SOURCES icd_linux.c icd_exports.map) + get_filename_component(ICD_EXPORTS_MAP_FILE icd_exports.map ABSOLUTE) else () list (APPEND OPENCL_ICD_LOADER_SOURCES icd_windows.c OpenCL.def) include_directories ($ENV{DXSDK_DIR}/Include) @@ -25,7 +26,7 @@ add_library (OpenCL_ICD SHARED ${OPENCL_ICD_LOADER_SOURCES}) set_target_properties (OpenCL_ICD PROPERTIES VERSION "1.2" SOVERSION "1") if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") - set_target_properties (OpenCL_ICD PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,../../khronos_icd/icd_exports.map") + set_target_properties (OpenCL_ICD PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${ICD_EXPORTS_MAP_FILE}") endif () target_link_libraries (OpenCL_ICD ${CMAKE_DL_LIBS}) From 8074ed9350caa35fedf8f9216f747a2e731be372 Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Wed, 15 Jul 2015 20:52:37 +0200 Subject: [PATCH 22/62] updated test p2p/host --- test/libp2p/peer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/libp2p/peer.cpp b/test/libp2p/peer.cpp index 5417450b4..807ccec6b 100644 --- a/test/libp2p/peer.cpp +++ b/test/libp2p/peer.cpp @@ -57,12 +57,12 @@ BOOST_AUTO_TEST_CASE(host) this_thread::sleep_for(chrono::milliseconds(step)); BOOST_REQUIRE(host1.isStarted() && host2.isStarted()); - host1.addNode(node2, NodeIPEndpoint(bi::address::from_string("127.0.0.1"), host2prefs.listenPort, host2prefs.listenPort)); for (int i = 0; i < 3000 && (!host1.haveNetwork() || !host2.haveNetwork()); i += step) this_thread::sleep_for(chrono::milliseconds(step)); BOOST_REQUIRE(host1.haveNetwork() && host2.haveNetwork()); + host1.addNode(node2, NodeIPEndpoint(bi::address::from_string("127.0.0.1"), host2prefs.listenPort, host2prefs.listenPort)); for (int i = 0; i < 3000 && (!host1.peerCount() || !host2.peerCount()); i += step) this_thread::sleep_for(chrono::milliseconds(step)); From 77c5724afef6400e20e9bc4134d1c2742bfa575b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Wed, 15 Jul 2015 21:20:57 +0200 Subject: [PATCH 23/62] Fix --vm command line option. --- eth/main.cpp | 2 -- neth/main.cpp | 4 +--- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/eth/main.cpp b/eth/main.cpp index 24520d8c4..bd8fbc743 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -1085,7 +1085,6 @@ int main(int argc, char** argv) string jsonAdmin; bool upnp = true; WithExisting withExisting = WithExisting::Trust; - bool jit = false; string sentinel; /// Networking params. @@ -1525,7 +1524,6 @@ int main(int argc, char** argv) }; StructuredLogger::get().initialize(structuredLogging, structuredLoggingFormat, structuredLoggingURL); - VMFactory::setKind(jit ? VMKind::JIT : VMKind::Interpreter); auto netPrefs = publicIP.empty() ? NetworkPreferences(listenIP ,listenPort, upnp) : NetworkPreferences(publicIP, listenIP ,listenPort, upnp); netPrefs.discovery = !disableDiscovery; netPrefs.pin = pinning; diff --git a/neth/main.cpp b/neth/main.cpp index 5ec253440..c3dc65715 100644 --- a/neth/main.cpp +++ b/neth/main.cpp @@ -339,7 +339,6 @@ int main(int argc, char** argv) bool upnp = true; bool forceMining = false; bool killChain = false; - bool jit = false; bool structuredLogging = false; string structuredLoggingFormat = "%Y-%m-%dT%H:%M:%S"; string clientName; @@ -544,10 +543,9 @@ int main(int argc, char** argv) cout << credits(); StructuredLogger::get().initialize(structuredLogging, structuredLoggingFormat); - VMFactory::setKind(jit ? VMKind::JIT : VMKind::Interpreter); auto netPrefs = publicIP.empty() ? NetworkPreferences(listenIP ,listenPort, upnp) : NetworkPreferences(publicIP, listenIP ,listenPort, upnp); auto nodesState = contents((dbPath.size() ? dbPath : getDataDir()) + "/network.rlp"); - std::string clientImplString = "N++eth/" + clientName + "v" + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM) + (jit ? "/JIT" : ""); + std::string clientImplString = "N++eth/" + clientName + "v" + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM)); dev::WebThreeDirect web3( clientImplString, dbPath, From e457d74d1ce748ecf5045086d171b6267e25cfcf Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 15 Jul 2015 16:32:47 +0200 Subject: [PATCH 24/62] Allow one additional stack slot. Fixes: #2478 --- libsolidity/LValue.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsolidity/LValue.cpp b/libsolidity/LValue.cpp index c754bbfca..5c43fb82a 100644 --- a/libsolidity/LValue.cpp +++ b/libsolidity/LValue.cpp @@ -41,7 +41,7 @@ StackVariable::StackVariable(CompilerContext& _compilerContext, Declaration cons void StackVariable::retrieveValue(SourceLocation const& _location, bool) const { unsigned stackPos = m_context.baseToCurrentStackOffset(m_baseStackOffset); - if (stackPos >= 15) //@todo correct this by fetching earlier or moving to memory + if (stackPos + 1 > 16) //@todo correct this by fetching earlier or moving to memory BOOST_THROW_EXCEPTION( CompilerError() << errinfo_sourceLocation(_location) << From aa4f6bb6f1edbba05a363f275f3cd8b0759120bb Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 15 Jul 2015 19:13:42 +0200 Subject: [PATCH 25/62] Fix for initialising storage strings. --- libsolidity/ExpressionCompiler.cpp | 17 ++++++++++++++--- test/libsolidity/SolidityEndToEndTest.cpp | 15 +++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/libsolidity/ExpressionCompiler.cpp b/libsolidity/ExpressionCompiler.cpp index 6a2e185c5..470fd7c58 100644 --- a/libsolidity/ExpressionCompiler.cpp +++ b/libsolidity/ExpressionCompiler.cpp @@ -48,12 +48,23 @@ void ExpressionCompiler::appendStateVariableInitialization(VariableDeclaration c { if (!_varDecl.getValue()) return; - solAssert(!!_varDecl.getValue()->getType(), "Type information not available."); + TypePointer type = _varDecl.getValue()->getType(); + solAssert(!!type, "Type information not available."); CompilerContext::LocationSetter locationSetter(m_context, _varDecl); _varDecl.getValue()->accept(*this); - utils().convertType(*_varDecl.getValue()->getType(), *_varDecl.getType(), true); - StorageItem(m_context, _varDecl).storeValue(*_varDecl.getType(), _varDecl.getLocation(), true); + if (_varDecl.getType()->dataStoredIn(DataLocation::Storage)) + { + // reference type, only convert value to mobile type and do final conversion in storeValue. + utils().convertType(*type, *type->mobileType()); + type = type->mobileType(); + } + else + { + utils().convertType(*type, *_varDecl.getType()); + type = _varDecl.getType(); + } + StorageItem(m_context, _varDecl).storeValue(*type, _varDecl.getLocation(), true); } void ExpressionCompiler::appendStateVariableAccessor(VariableDeclaration const& _varDecl) diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 9f806347e..113c76a08 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -5033,6 +5033,21 @@ BOOST_AUTO_TEST_CASE(literal_strings) BOOST_CHECK(callContractFunction("empty()") == encodeDyn(string())); } +BOOST_AUTO_TEST_CASE(initialise_string_constant) +{ + char const* sourceCode = R"( + contract Test { + string public short = "abcdef"; + string public long = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789001234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678900123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789001234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"; + } + )"; + compileAndRun(sourceCode, 0, "Test"); + string longStr = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789001234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678900123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789001234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"; + string shortStr = "abcdef"; + + BOOST_CHECK(callContractFunction("long()") == encodeDyn(longStr)); + BOOST_CHECK(callContractFunction("short()") == encodeDyn(shortStr)); +} BOOST_AUTO_TEST_SUITE_END() From 72f8b3cd5e158571611024b93ca4a8acd1b9c231 Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Thu, 16 Jul 2015 00:39:41 +0200 Subject: [PATCH 26/62] a minor update --- libwhisper/WhisperDB.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libwhisper/WhisperDB.cpp b/libwhisper/WhisperDB.cpp index dbafc9365..7104723d7 100644 --- a/libwhisper/WhisperDB.cpp +++ b/libwhisper/WhisperDB.cpp @@ -126,7 +126,7 @@ void WhisperDB::loadAll(std::map& o_dst) cdebug << "WhisperDB::loadAll(): loaded " << o_dst.size() << ", deleted " << wasted.size() << "messages"; - for (auto k: wasted) + for (auto const& k: wasted) { leveldb::Status status = m_db->Delete(m_writeOptions, k); if (!status.ok()) From 63730439b81fe85e59ac218cfbe19ab8b912d9e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Wed, 15 Jul 2015 23:53:12 +0200 Subject: [PATCH 27/62] Disable OpenCL_ICD on OSX. --- CMakeLists.txt | 15 +++++++++++---- exp/CMakeLists.txt | 2 +- libethash-cl/CMakeLists.txt | 3 +-- libethash-cl/ethash_cl_miner.cpp | 6 ++++-- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ffe98617e..55aff81e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,7 +131,7 @@ function(createBuildInfo) add_custom_target(BuildInfo.h ALL WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${CMAKE_COMMAND} -DETH_SOURCE_DIR="${CMAKE_SOURCE_DIR}" -DETH_DST_DIR="${CMAKE_BINARY_DIR}" - -DETH_BUILD_TYPE="${_cmake_build_type}" -DETH_BUILD_PLATFORM="${ETH_BUILD_PLATFORM}" + -DETH_BUILD_TYPE="${_cmake_build_type}" -DETH_BUILD_PLATFORM="${ETH_BUILD_PLATFORM}" -P "${ETH_SCRIPTS_DIR}/buildinfo.cmake" ) include_directories(${CMAKE_CURRENT_BINARY_DIR}) @@ -175,9 +175,9 @@ endif () macro(eth_format_option O) if (${${O}}) - set(${O} ON) + set(${O} ON) else() - set(${O} OFF) + set(${O} OFF) endif() endmacro() @@ -426,7 +426,14 @@ if (GENERAL OR MINER) add_subdirectory(libethash) if (ETHASHCL) add_subdirectory(libethash-cl) - add_subdirectory(khronos_icd) + if (APPLE) + add_library(OpenCL SHARED IMPORTED) + set_property(TARGET OpenCL PROPERTY IMPORTED_LOCATION ${OpenCL_LIBRARY}) + set(OpenCL_TARGET OpenCL) + else() + add_subdirectory(khronos_icd) + set(OpenCL_TARGET OpenCL_ICD) + endif() endif () endif () diff --git a/exp/CMakeLists.txt b/exp/CMakeLists.txt index 41940beef..b0e7a9951 100644 --- a/exp/CMakeLists.txt +++ b/exp/CMakeLists.txt @@ -27,6 +27,6 @@ target_link_libraries(${EXECUTABLE} p2p) if (ETHASHCL) target_link_libraries(${EXECUTABLE} ethash-cl) target_link_libraries(${EXECUTABLE} ethash) - target_link_libraries(${EXECUTABLE} OpenCL_ICD) + target_link_libraries(${EXECUTABLE} ${OpenCL_TARGET}) endif() install( TARGETS ${EXECUTABLE} DESTINATION bin) diff --git a/libethash-cl/CMakeLists.txt b/libethash-cl/CMakeLists.txt index 70f711a76..8688648bd 100644 --- a/libethash-cl/CMakeLists.txt +++ b/libethash-cl/CMakeLists.txt @@ -23,8 +23,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${Boost_INCLUDE_DIRS}) include_directories(..) add_library(${EXECUTABLE} ${SRC_LIST} ${HEADERS}) -TARGET_LINK_LIBRARIES(${EXECUTABLE} OpenCL_ICD ethash) +TARGET_LINK_LIBRARIES(${EXECUTABLE} ${OpenCL_TARGET} ethash) install( TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib ) install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} ) - diff --git a/libethash-cl/ethash_cl_miner.cpp b/libethash-cl/ethash_cl_miner.cpp index 35700767c..3cdb12125 100644 --- a/libethash-cl/ethash_cl_miner.cpp +++ b/libethash-cl/ethash_cl_miner.cpp @@ -87,9 +87,11 @@ std::vector ethash_cl_miner::getPlatforms() } catch(cl::Error const& err) { + #if !defined(CL_PLATFORM_NOT_FOUND_KHR) if (err.err() == CL_PLATFORM_NOT_FOUND_KHR) ETHCL_LOG("No OpenCL platforms found"); else + #endif throw err; } return platforms; @@ -190,7 +192,7 @@ bool ethash_cl_miner::configureGPU( ); return true; } - + ETHCL_LOG( "OpenCL device " << _device.getInfo() << " has insufficient GPU memory." << result << @@ -231,7 +233,7 @@ bool ethash_cl_miner::searchForAllDevices(unsigned _platformId, function Date: Thu, 16 Jul 2015 00:44:26 +0200 Subject: [PATCH 28/62] Ping buildbot. --- libethash-cl/ethash_cl_miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libethash-cl/ethash_cl_miner.cpp b/libethash-cl/ethash_cl_miner.cpp index 3cdb12125..f463fc939 100644 --- a/libethash-cl/ethash_cl_miner.cpp +++ b/libethash-cl/ethash_cl_miner.cpp @@ -101,7 +101,7 @@ string ethash_cl_miner::platform_info(unsigned _platformId, unsigned _deviceId) { vector platforms = getPlatforms(); if (platforms.empty()) - return string(); + return {}; // get GPU device of the selected platform unsigned platform_num = min(_platformId, platforms.size() - 1); vector devices = getDevices(platforms, _platformId); From 8221a3c4cd4fc3da452a52e1543d4a7f09c89e2c Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 16 Jul 2015 01:06:19 +0200 Subject: [PATCH 29/62] Allow structs containing mappings in memory. --- libsolidity/AST.cpp | 30 +++++++++++++++++-- libsolidity/Types.cpp | 26 +++++++++------- libsolidity/Types.h | 9 ++++-- test/libsolidity/SolidityEndToEndTest.cpp | 23 ++++++++++++++ .../SolidityNameAndTypeResolution.cpp | 15 ++++++++++ 5 files changed, 86 insertions(+), 17 deletions(-) diff --git a/libsolidity/AST.cpp b/libsolidity/AST.cpp index 0cca63a80..3a83058c1 100644 --- a/libsolidity/AST.cpp +++ b/libsolidity/AST.cpp @@ -830,11 +830,14 @@ void FunctionCall::checkTypeRequirements(TypePointers const*) return; } + /// For error message: Struct members that were removed during conversion to memory. + set membersRemovedForStructConstructor; if (isStructConstructorCall()) { TypeType const& type = dynamic_cast(*expressionType); auto const& structType = dynamic_cast(*type.getActualType()); functionType = structType.constructorType(); + membersRemovedForStructConstructor = structType.membersMissingInMemory(); } else functionType = dynamic_pointer_cast(expressionType); @@ -847,13 +850,22 @@ void FunctionCall::checkTypeRequirements(TypePointers const*) // function parameters TypePointers const& parameterTypes = functionType->getParameterTypes(); if (!functionType->takesArbitraryParameters() && parameterTypes.size() != m_arguments.size()) - BOOST_THROW_EXCEPTION(createTypeError( + { + string msg = "Wrong argument count for function call: " + toString(m_arguments.size()) + " arguments given but expected " + toString(parameterTypes.size()) + - "." - )); + "."; + // Extend error message in case we try to construct a struct with mapping member. + if (isStructConstructorCall() && !membersRemovedForStructConstructor.empty()) + { + msg += " Members that have to be skipped in memory:"; + for (auto const& member: membersRemovedForStructConstructor) + msg += " " + member; + } + BOOST_THROW_EXCEPTION(createTypeError(msg)); + } if (isPositionalCall) { @@ -972,10 +984,22 @@ void MemberAccess::checkTypeRequirements(TypePointers const* _argumentTypes) ++it; } if (possibleMembers.size() == 0) + { + auto storageType = ReferenceType::copyForLocationIfReference( + DataLocation::Storage, + m_expression->getType() + ); + if (!storageType->getMembers().membersByName(*m_memberName).empty()) + BOOST_THROW_EXCEPTION(createTypeError( + "Member \"" + *m_memberName + "\" is not available in " + + type.toString() + + " outside of storage." + )); BOOST_THROW_EXCEPTION(createTypeError( "Member \"" + *m_memberName + "\" not found or not visible " "after argument-dependent lookup in " + type.toString() )); + } else if (possibleMembers.size() > 1) BOOST_THROW_EXCEPTION(createTypeError( "Member \"" + *m_memberName + "\" not unique " diff --git a/libsolidity/Types.cpp b/libsolidity/Types.cpp index 91ef16b50..d85c0511f 100644 --- a/libsolidity/Types.cpp +++ b/libsolidity/Types.cpp @@ -1040,14 +1040,6 @@ u256 StructType::getStorageSize() const return max(1, getMembers().getStorageSize()); } -bool StructType::canLiveOutsideStorage() const -{ - for (auto const& member: getMembers()) - if (!member.type->canLiveOutsideStorage()) - return false; - return true; -} - string StructType::toString(bool _short) const { string ret = "struct " + m_struct.getName(); @@ -1064,9 +1056,13 @@ MemberList const& StructType::getMembers() const MemberList::MemberMap members; for (ASTPointer const& variable: m_struct.getMembers()) { + TypePointer type = variable->getType(); + // Skip all mapping members if we are not in storage. + if (location() != DataLocation::Storage && !type->canLiveOutsideStorage()) + continue; members.push_back(MemberList::Member( variable->getName(), - copyForLocationIfReference(variable->getType()), + copyForLocationIfReference(type), variable.get()) ); } @@ -1077,8 +1073,7 @@ MemberList const& StructType::getMembers() const TypePointer StructType::copyForLocation(DataLocation _location, bool _isPointer) const { - auto copy = make_shared(m_struct); - copy->m_location = _location; + auto copy = make_shared(m_struct, _location); copy->m_isPointer = _isPointer; return copy; } @@ -1122,6 +1117,15 @@ u256 StructType::memoryOffsetOfMember(string const& _name) const return 0; } +set StructType::membersMissingInMemory() const +{ + set missing; + for (ASTPointer const& variable: m_struct.getMembers()) + if (!variable->getType()->canLiveOutsideStorage()) + missing.insert(variable->getName()); + return missing; +} + TypePointer EnumType::unaryOperatorResult(Token::Value _operator) const { return _operator == Token::Delete ? make_shared() : TypePointer(); diff --git a/libsolidity/Types.h b/libsolidity/Types.h index 8bdfc5e69..f18855b26 100644 --- a/libsolidity/Types.h +++ b/libsolidity/Types.h @@ -574,14 +574,14 @@ class StructType: public ReferenceType { public: virtual Category getCategory() const override { return Category::Struct; } - explicit StructType(StructDefinition const& _struct): - ReferenceType(DataLocation::Storage), m_struct(_struct) {} + explicit StructType(StructDefinition const& _struct, DataLocation _location = DataLocation::Storage): + ReferenceType(_location), m_struct(_struct) {} virtual bool isImplicitlyConvertibleTo(const Type& _convertTo) const override; virtual bool operator==(Type const& _other) const override; virtual unsigned getCalldataEncodedSize(bool _padded) const override; u256 memorySize() const; virtual u256 getStorageSize() const override; - virtual bool canLiveOutsideStorage() const override; + virtual bool canLiveOutsideStorage() const override { return true; } virtual std::string toString(bool _short) const override; virtual MemberList const& getMembers() const override; @@ -597,6 +597,9 @@ public: StructDefinition const& structDefinition() const { return m_struct; } + /// @returns the set of all members that are removed in the memory version (typically mappings). + std::set membersMissingInMemory() const; + private: StructDefinition const& m_struct; /// List of member types, will be lazy-initialized because of recursive references. diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 9f806347e..b5c786564 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -5034,6 +5034,29 @@ BOOST_AUTO_TEST_CASE(literal_strings) } +BOOST_AUTO_TEST_CASE(memory_structs_with_mappings) +{ + char const* sourceCode = R"( + contract Test { + struct S { uint8 a; mapping(uint => uint) b; uint8 c; } + S s; + function f() returns (uint) { + S memory x; + if (x.a != 0 || x.c != 0) return 1; + x.a = 4; x.c = 5; + s = x; + if (s.a != 4 || s.c != 5) return 2; + x = S(2, 3); + if (x.a != 2 || x.c != 3) return 3; + x = s; + if (s.a != 4 || s.c != 5) return 4; + } + } + )"; + compileAndRun(sourceCode, 0, "Test"); + BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(0))); +} + BOOST_AUTO_TEST_SUITE_END() } diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 0f5e4800f..cfc43df91 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -2134,6 +2134,21 @@ BOOST_AUTO_TEST_CASE(invalid_integer_literal_exp) BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError); } +BOOST_AUTO_TEST_CASE(memory_structs_with_mappings) +{ + char const* text = R"( + contract Test { + struct S { uint8 a; mapping(uint => uint) b; uint8 c; } + S s; + function f() { + S memory x; + x.b[1]; + } + } + )"; + BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError); +} + BOOST_AUTO_TEST_SUITE_END() } From 201d2fff0d49877440ef6a867bafd61bbc115565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 16 Jul 2015 01:32:45 +0200 Subject: [PATCH 30/62] Ping buildbot. --- libethash-cl/ethash_cl_miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libethash-cl/ethash_cl_miner.cpp b/libethash-cl/ethash_cl_miner.cpp index f463fc939..3380f9379 100644 --- a/libethash-cl/ethash_cl_miner.cpp +++ b/libethash-cl/ethash_cl_miner.cpp @@ -108,7 +108,7 @@ string ethash_cl_miner::platform_info(unsigned _platformId, unsigned _deviceId) if (devices.empty()) { ETHCL_LOG("No OpenCL devices found."); - return string(); + return {}; } // use selected default device From fa2f3f2e14cf7295f7f909354f361202a59e9fc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 16 Jul 2015 01:36:20 +0200 Subject: [PATCH 31/62] I really need to get some sleep. --- libethash-cl/ethash_cl_miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libethash-cl/ethash_cl_miner.cpp b/libethash-cl/ethash_cl_miner.cpp index 3380f9379..15e0847a4 100644 --- a/libethash-cl/ethash_cl_miner.cpp +++ b/libethash-cl/ethash_cl_miner.cpp @@ -87,7 +87,7 @@ std::vector ethash_cl_miner::getPlatforms() } catch(cl::Error const& err) { - #if !defined(CL_PLATFORM_NOT_FOUND_KHR) + #if defined(CL_PLATFORM_NOT_FOUND_KHR) if (err.err() == CL_PLATFORM_NOT_FOUND_KHR) ETHCL_LOG("No OpenCL platforms found"); else From 502cec737a1d24e8123556b90204d536e81937d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 16 Jul 2015 01:50:25 +0200 Subject: [PATCH 32/62] Another try for OSX. --- CMakeLists.txt | 3 --- libethash-cl/CMakeLists.txt | 6 +++++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 55aff81e7..7edaf8401 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -427,9 +427,6 @@ if (GENERAL OR MINER) if (ETHASHCL) add_subdirectory(libethash-cl) if (APPLE) - add_library(OpenCL SHARED IMPORTED) - set_property(TARGET OpenCL PROPERTY IMPORTED_LOCATION ${OpenCL_LIBRARY}) - set(OpenCL_TARGET OpenCL) else() add_subdirectory(khronos_icd) set(OpenCL_TARGET OpenCL_ICD) diff --git a/libethash-cl/CMakeLists.txt b/libethash-cl/CMakeLists.txt index 8688648bd..b76eabfb5 100644 --- a/libethash-cl/CMakeLists.txt +++ b/libethash-cl/CMakeLists.txt @@ -23,7 +23,11 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${Boost_INCLUDE_DIRS}) include_directories(..) add_library(${EXECUTABLE} ${SRC_LIST} ${HEADERS}) -TARGET_LINK_LIBRARIES(${EXECUTABLE} ${OpenCL_TARGET} ethash) +if (APPLE) + TARGET_LINK_LIBRARIES(${EXECUTABLE} ${OpenCL_LIBRARY} ethash) +else() + TARGET_LINK_LIBRARIES(${EXECUTABLE} OpenCL_ICD ethash) +endif() install( TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib ) install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} ) From 7a10f55f131564fc0819ba3863d21c77228d0519 Mon Sep 17 00:00:00 2001 From: arkpar Date: Thu, 16 Jul 2015 09:59:25 +0200 Subject: [PATCH 33/62] Prevent sync from downloading unknown blocks that are already in the queue --- libethereum/BlockChainSync.cpp | 40 ++++++++++++++++------------------ libethereum/BlockChainSync.h | 17 ++++++++++----- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/libethereum/BlockChainSync.cpp b/libethereum/BlockChainSync.cpp index 6aede0c16..2cf2a7583 100644 --- a/libethereum/BlockChainSync.cpp +++ b/libethereum/BlockChainSync.cpp @@ -916,26 +916,23 @@ void PV61Sync::requestSubchain(std::shared_ptr _peer) if (syncPeer != m_chainSyncPeers.end()) { // Already downoading, request next batch - h256s& d = m_downloadingChainMap.at(syncPeer->second); - _peer->requestHashes(d.back()); + SubChain const& s = m_downloadingChainMap.at(syncPeer->second); + _peer->requestHashes(s.lastHash); } else if (needsSyncing(_peer)) { if (!m_readyChainMap.empty()) { clog(NetAllDetail) << "Helping with hashchin download"; - h256s& d = m_readyChainMap.begin()->second; - _peer->requestHashes(d.back()); - m_downloadingChainMap[m_readyChainMap.begin()->first] = move(d); + SubChain& s = m_readyChainMap.begin()->second; + _peer->requestHashes(s.lastHash); + m_downloadingChainMap[m_readyChainMap.begin()->first] = move(s); m_chainSyncPeers[_peer] = m_readyChainMap.begin()->first; m_readyChainMap.erase(m_readyChainMap.begin()); } else if (!m_downloadingChainMap.empty() && m_hashScanComplete) - { // Lead syncer is done, just grab whatever we can - h256s& d = m_downloadingChainMap.begin()->second; - _peer->requestHashes(d.back()); - } + _peer->requestHashes(m_downloadingChainMap.begin()->second.lastHash); } } @@ -974,7 +971,7 @@ void PV61Sync::completeSubchain(std::shared_ptr _peer, unsigned _n //Done chain-get m_syncingNeededBlocks.clear(); for (auto h = m_completeChainMap.rbegin(); h != m_completeChainMap.rend(); ++h) - m_syncingNeededBlocks.insert(m_syncingNeededBlocks.end(), h->second.begin(), h->second.end()); + m_syncingNeededBlocks.insert(m_syncingNeededBlocks.end(), h->second.hashes.begin(), h->second.hashes.end()); m_completeChainMap.clear(); m_knownHashes.clear(); m_syncingBlockNumber = 0; @@ -1010,7 +1007,7 @@ void PV61Sync::onPeerHashes(std::shared_ptr _peer, h256s const& _h if (isSyncing(_peer) && _peer->m_syncHashNumber == m_syncingBlockNumber) { // End of hash chain, add last chunk to download - m_readyChainMap.insert(make_pair(m_syncingBlockNumber, h256s { _peer->m_latestHash })); + m_readyChainMap.insert(make_pair(m_syncingBlockNumber, SubChain{ h256s{ _peer->m_latestHash }, _peer->m_latestHash })); m_hashScanComplete = true; _peer->m_syncHashNumber = 0; requestSubchain(_peer); @@ -1038,7 +1035,7 @@ void PV61Sync::onPeerHashes(std::shared_ptr _peer, h256s const& _h // Got new subchain marker assert(_hashes.size() == 1); m_knownHashes.insert(_hashes[0]); - m_readyChainMap.insert(make_pair(m_syncingBlockNumber, h256s { _hashes[0] })); + m_readyChainMap.insert(make_pair(m_syncingBlockNumber, SubChain{ h256s{ _hashes[0] }, _hashes[0] })); if ((m_readyChainMap.size() + m_downloadingChainMap.size() + m_completeChainMap.size()) * c_hashSubchainSize > _peer->m_expectedHashes) { _peer->disable("Too many hashes from lead peer"); @@ -1056,7 +1053,7 @@ void PV61Sync::onPeerHashes(std::shared_ptr _peer, h256s const& _h { //check downlading peers for (auto const& downloader: m_downloadingChainMap) - if (downloader.second.back() == _peer->m_syncHash) + if (downloader.second.lastHash == _peer->m_syncHash) { number = downloader.first; break; @@ -1071,7 +1068,7 @@ void PV61Sync::onPeerHashes(std::shared_ptr _peer, h256s const& _h } auto downloadingPeer = m_downloadingChainMap.find(number); - if (downloadingPeer == m_downloadingChainMap.end() || downloadingPeer->second.back() != _peer->m_syncHash) + if (downloadingPeer == m_downloadingChainMap.end() || downloadingPeer->second.lastHash != _peer->m_syncHash) { // Too late, other peer has already downloaded our hashes m_chainSyncPeers.erase(_peer); @@ -1079,7 +1076,7 @@ void PV61Sync::onPeerHashes(std::shared_ptr _peer, h256s const& _h return; } - h256s& hashes = downloadingPeer->second; + SubChain& subChain = downloadingPeer->second; unsigned knowns = 0; unsigned unknowns = 0; for (unsigned i = 0; i < _hashes.size(); ++i) @@ -1111,13 +1108,14 @@ void PV61Sync::onPeerHashes(std::shared_ptr _peer, h256s const& _h else if (status == QueueStatus::Unknown) { unknowns++; - hashes.push_back(h); + subChain.hashes.push_back(h); } else knowns++; + subChain.lastHash = h; } - clog(NetMessageSummary) << knowns << "knowns," << unknowns << "unknowns; now at" << hashes.back(); - if (hashes.size() > c_hashSubchainSize) + clog(NetMessageSummary) << knowns << "knowns," << unknowns << "unknowns; now at" << subChain.lastHash; + if (subChain.hashes.size() > c_hashSubchainSize) { _peer->disable("Too many subchain hashes"); restartSync(); @@ -1175,11 +1173,11 @@ SyncStatus PV61Sync::status() const { res.hashesReceived = 0; for (auto const& d : m_readyChainMap) - res.hashesReceived += d.second.size(); + res.hashesReceived += d.second.hashes.size(); for (auto const& d : m_downloadingChainMap) - res.hashesReceived += d.second.size(); + res.hashesReceived += d.second.hashes.size(); for (auto const& d : m_completeChainMap) - res.hashesReceived += d.second.size(); + res.hashesReceived += d.second.hashes.size(); } return res; } diff --git a/libethereum/BlockChainSync.h b/libethereum/BlockChainSync.h index 6be17bc74..23c122bff 100644 --- a/libethereum/BlockChainSync.h +++ b/libethereum/BlockChainSync.h @@ -126,7 +126,6 @@ private: void logNewBlock(h256 const& _h); EthereumHost& m_host; - HashDownloadMan m_hashMan; }; @@ -308,12 +307,18 @@ private: /// Check if downloading hashes in parallel bool isPV61Syncing() const; - std::map m_completeChainMap; ///< Fully downloaded subchains - std::map m_readyChainMap; ///< Subchains ready for download - std::map m_downloadingChainMap; ///< Subchains currently being downloading. In sync with m_chainSyncPeers + struct SubChain + { + h256s hashes; ///< List of subchain hashes + h256 lastHash; ///< Last requested subchain hash + }; + + std::map m_completeChainMap; ///< Fully downloaded subchains + std::map m_readyChainMap; ///< Subchains ready for download + std::map m_downloadingChainMap; ///< Subchains currently being downloading. In sync with m_chainSyncPeers std::map, unsigned, std::owner_less>> m_chainSyncPeers; ///< Peers to m_downloadingSubchain number map - h256Hash m_knownHashes; ///< Subchain start markers. Used to track suchain completion - unsigned m_syncingBlockNumber = 0; ///< Current subchain marker + h256Hash m_knownHashes; ///< Subchain start markers. Used to track suchain completion + unsigned m_syncingBlockNumber = 0; ///< Current subchain marker bool m_hashScanComplete = false; ///< True if leading peer completed hashchain scan and we have a list of subchains ready }; From 924ea156b196fcc7e0fdad2f58486f6560278b42 Mon Sep 17 00:00:00 2001 From: arkpar Date: Thu, 16 Jul 2015 12:00:38 +0200 Subject: [PATCH 34/62] Fixed maxNonce calculation for empty transaction list --- libethereum/TransactionQueue.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libethereum/TransactionQueue.cpp b/libethereum/TransactionQueue.cpp index 2554544a3..227674b66 100644 --- a/libethereum/TransactionQueue.cpp +++ b/libethereum/TransactionQueue.cpp @@ -201,11 +201,11 @@ u256 TransactionQueue::maxNonce_WITH_LOCK(Address const& _a) const u256 ret = 0; auto cs = m_currentByAddressAndNonce.find(_a); if (cs != m_currentByAddressAndNonce.end() && !cs->second.empty()) - ret = cs->second.rbegin()->first; + ret = cs->second.rbegin()->first + 1; auto fs = m_future.find(_a); if (fs != m_future.end() && !fs->second.empty()) - ret = std::max(ret, fs->second.rbegin()->first); - return ret + 1; + ret = std::max(ret, fs->second.rbegin()->first + 1); + return ret; } void TransactionQueue::insertCurrent_WITH_LOCK(std::pair const& _p) From d19258ef6a0544ab1279ec11fadbf55aa8230b9e Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Thu, 16 Jul 2015 12:47:56 +0200 Subject: [PATCH 35/62] OpenCL_ICD added to getstuff.bat --- extdep/getstuff.bat | 1 + 1 file changed, 1 insertion(+) diff --git a/extdep/getstuff.bat b/extdep/getstuff.bat index a718650b7..072aacfe6 100644 --- a/extdep/getstuff.bat +++ b/extdep/getstuff.bat @@ -13,6 +13,7 @@ call :download json-rpc-cpp 0.5.0 call :download leveldb 1.2 call :download llvm 3.7svn call :download microhttpd 0.9.2 +call :download OpenCL_ICD 1 call :download qt 5.4.1 call :download miniupnpc 1.9 call :download v8 3.15.9 From e4111c2270de54e29a0743e1dac3ecc324460020 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 16 Jul 2015 12:42:59 +0200 Subject: [PATCH 36/62] Add BuildInfo.h as dependency. --- libsolidity/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/libsolidity/CMakeLists.txt b/libsolidity/CMakeLists.txt index 10c7bc2d2..30b17c093 100644 --- a/libsolidity/CMakeLists.txt +++ b/libsolidity/CMakeLists.txt @@ -20,6 +20,7 @@ set(EXECUTABLE solidity) file(GLOB HEADERS "*.h") add_library(${EXECUTABLE} ${SRC_LIST} ${HEADERS}) +add_dependencies(${EXECUTABLE} BuildInfo.h) target_link_libraries(${EXECUTABLE} ${JSONCPP_LIBRARIES}) target_link_libraries(${EXECUTABLE} evmasm) From e8bc2e766785157de143ac2acffe33fc2a907154 Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Mon, 15 Jun 2015 15:21:23 +0200 Subject: [PATCH 37/62] contract documentation is now parsing during compilation and not by request. --- libsolidity/AST.cpp | 21 +++++++++++++++++++++ libsolidity/AST.h | 10 ++++++++++ libsolidity/CompilerStack.cpp | 8 ++++++++ libsolidity/CompilerStack.h | 3 +++ libsolidity/InterfaceHandler.cpp | 24 +++++++++++++++++------- libsolidity/InterfaceHandler.h | 12 +++++++++--- libsolidity/Parser.cpp | 2 ++ solc/CommandLineInterface.cpp | 5 +++++ solc/jsonCompiler.cpp | 4 ++++ 9 files changed, 79 insertions(+), 10 deletions(-) diff --git a/libsolidity/AST.cpp b/libsolidity/AST.cpp index 3a83058c1..270ec3ed7 100644 --- a/libsolidity/AST.cpp +++ b/libsolidity/AST.cpp @@ -382,6 +382,27 @@ vector, FunctionTypePointer>> const& ContractDefinition::getIn return *m_interfaceFunctionList; } +unique_ptr ContractDefinition::devDocumentation() const +{ + return unique_ptr(new string(m_devDocumentation)); +} + +void ContractDefinition::setDevDocumentation(string const& _devDocumentation) +{ + m_devDocumentation = _devDocumentation; +} + +std::unique_ptr ContractDefinition::userDocumentation() const +{ + return unique_ptr(new string(m_userDocumentation)); +} + +void ContractDefinition::setUserDocumentation(string const& _userDocumentation) +{ + m_userDocumentation = _userDocumentation; +} + + vector const& ContractDefinition::getInheritableMembers() const { if (!m_inheritableMembers) diff --git a/libsolidity/AST.h b/libsolidity/AST.h index 658b3de9f..38262d009 100644 --- a/libsolidity/AST.h +++ b/libsolidity/AST.h @@ -281,6 +281,12 @@ public: /// Returns the fallback function or nullptr if no fallback function was specified. FunctionDefinition const* getFallbackFunction() const; + std::unique_ptr userDocumentation() const; + void setUserDocumentation(std::string const& _userDocumentation); + + std::unique_ptr devDocumentation() const; + void setDevDocumentation(std::string const& _devDocumentation); + private: /// Checks that two functions defined in this contract with the same name have different /// arguments and that there is at most one constructor. @@ -302,6 +308,10 @@ private: std::vector> m_functionModifiers; std::vector> m_events; + // parsed Natspec documentation of the contract. + std::string m_userDocumentation; + std::string m_devDocumentation; + std::vector m_linearizedBaseContracts; mutable std::unique_ptr, FunctionTypePointer>>> m_interfaceFunctionList; mutable std::unique_ptr>> m_interfaceEvents; diff --git a/libsolidity/CompilerStack.cpp b/libsolidity/CompilerStack.cpp index a3399823e..7cd8316c7 100644 --- a/libsolidity/CompilerStack.cpp +++ b/libsolidity/CompilerStack.cpp @@ -124,10 +124,18 @@ void CompilerStack::parse() resolver.updateDeclaration(*m_globalContext->getCurrentThis()); resolver.checkTypeRequirements(*contract); m_contracts[contract->getName()].contract = contract; + parseNatspecDocumentation(*contract); } m_parseSuccessful = true; } +void CompilerStack::parseNatspecDocumentation(ContractDefinition& _contract) +{ + InterfaceHandler interfaceHandler; + interfaceHandler.generateDevDocumentation(_contract); + interfaceHandler.generateUserDocumentation(_contract); +} + void CompilerStack::parse(string const& _sourceCode) { setSource(_sourceCode); diff --git a/libsolidity/CompilerStack.h b/libsolidity/CompilerStack.h index a7c6ea3ba..fdf2562bc 100644 --- a/libsolidity/CompilerStack.h +++ b/libsolidity/CompilerStack.h @@ -148,6 +148,9 @@ public: /// start line, start column, end line, end column std::tuple positionFromSourceLocation(SourceLocation const& _sourceLocation) const; + /// Parses Natspec documentations. Throws exceptions in case of wrong documented contract + void parseNatspecDocumentation(dev::solidity::ContractDefinition& _contract); + private: /** * Information pertaining to one source unit, filled gradually during parsing and compilation. diff --git a/libsolidity/InterfaceHandler.cpp b/libsolidity/InterfaceHandler.cpp index 23b7ff82f..36940d278 100644 --- a/libsolidity/InterfaceHandler.cpp +++ b/libsolidity/InterfaceHandler.cpp @@ -24,9 +24,9 @@ unique_ptr InterfaceHandler::getDocumentation( switch(_type) { case DocumentationType::NatspecUser: - return getUserDocumentation(_contractDef); + return userDocumentation(_contractDef); case DocumentationType::NatspecDev: - return getDevDocumentation(_contractDef); + return devDocumentation(_contractDef); case DocumentationType::ABIInterface: return getABIInterface(_contractDef); case DocumentationType::ABISolidityInterface: @@ -143,7 +143,7 @@ unique_ptr InterfaceHandler::getABISolidityInterface(ContractDefinition return unique_ptr(new string(ret + "}")); } -unique_ptr InterfaceHandler::getUserDocumentation(ContractDefinition const& _contractDef) +void InterfaceHandler::generateUserDocumentation(ContractDefinition& _contractDef) { Json::Value doc; Json::Value methods(Json::objectValue); @@ -165,10 +165,20 @@ unique_ptr InterfaceHandler::getUserDocumentation(ContractDefinition con } doc["methods"] = methods; - return unique_ptr(new string(Json::FastWriter().write(doc))); + _contractDef.setUserDocumentation(string(Json::FastWriter().write(doc))); } -unique_ptr InterfaceHandler::getDevDocumentation(ContractDefinition const& _contractDef) +unique_ptr InterfaceHandler::userDocumentation(ContractDefinition const& _contractDef) +{ + return _contractDef.userDocumentation(); +} + +unique_ptr InterfaceHandler::devDocumentation(ContractDefinition const& _contractDef) +{ + return _contractDef.devDocumentation(); +} + +void InterfaceHandler::generateDevDocumentation(ContractDefinition& _contractDef) { // LTODO: Somewhere in this function warnings for mismatch of param names // should be thrown @@ -212,7 +222,7 @@ unique_ptr InterfaceHandler::getDevDocumentation(ContractDefinition cons // LTODO: mismatching parameter name, throw some form of warning and not just an exception BOOST_THROW_EXCEPTION( DocstringParsingError() << - errinfo_comment("documented parameter \"" + pair.first + "\" not found found in the function") + errinfo_comment("documented parameter \"" + pair.first + "\" not found in the parameter list of the function.") ); params[pair.first] = pair.second; } @@ -229,7 +239,7 @@ unique_ptr InterfaceHandler::getDevDocumentation(ContractDefinition cons } doc["methods"] = methods; - return unique_ptr(new string(Json::FastWriter().write(doc))); + _contractDef.setDevDocumentation(string(Json::FastWriter().write(doc))); } /* -- private -- */ diff --git a/libsolidity/InterfaceHandler.h b/libsolidity/InterfaceHandler.h index ca9807d7e..1cc20c444 100644 --- a/libsolidity/InterfaceHandler.h +++ b/libsolidity/InterfaceHandler.h @@ -77,16 +77,22 @@ public: /// representation of the contract's ABI Interface std::unique_ptr getABIInterface(ContractDefinition const& _contractDef); std::unique_ptr getABISolidityInterface(ContractDefinition const& _contractDef); + /// Generate the User documentation of the contract + /// @param _contractDef The contract definition + void generateUserDocumentation(ContractDefinition& _contractDef); /// Get the User documentation of the contract /// @param _contractDef The contract definition /// @return A unique pointer contained string with the json /// representation of the contract's user documentation - std::unique_ptr getUserDocumentation(ContractDefinition const& _contractDef); - /// Get the Developer's documentation of the contract + std::unique_ptr userDocumentation(ContractDefinition const& _contractDef); + /// Genereates the Developer's documentation of the contract + /// @param _contractDef The contract definition + void generateDevDocumentation(ContractDefinition& _contractDef); + /// Genereates the Developer's documentation of the contract /// @param _contractDef The contract definition /// @return A unique pointer contained string with the json /// representation of the contract's developer documentation - std::unique_ptr getDevDocumentation(ContractDefinition const& _contractDef); + std::unique_ptr devDocumentation(ContractDefinition const& _contractDef); private: void resetUser(); diff --git a/libsolidity/Parser.cpp b/libsolidity/Parser.cpp index 548b7dc21..7ca1a40d3 100644 --- a/libsolidity/Parser.cpp +++ b/libsolidity/Parser.cpp @@ -26,6 +26,8 @@ #include #include #include +#include + using namespace std; diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 00bf2ab33..1b1dbd3eb 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -449,6 +449,11 @@ bool CommandLineInterface::processInput() << boost::diagnostic_information(_exception); return false; } + catch (DocstringParsingError const& _exception) + { + cerr << "Documentation parsing error: " << *boost::get_error_info(_exception) << endl; + return false; + } catch (Exception const& _exception) { cerr << "Exception during compilation: " << boost::diagnostic_information(_exception) << endl; diff --git a/solc/jsonCompiler.cpp b/solc/jsonCompiler.cpp index 340713b1d..bde13762a 100644 --- a/solc/jsonCompiler.cpp +++ b/solc/jsonCompiler.cpp @@ -147,6 +147,10 @@ string compile(string _input, bool _optimize) { return formatError(exception, "Internal compiler error", compiler); } + catch (DocstringParsingError const& exception) + { + return formatError(exception, "Documentation parsing error", compiler); + } catch (Exception const& exception) { output["error"] = "Exception during compilation: " + boost::diagnostic_information(exception); From 62c43a2db0a145426f4d3ceee757a75f21a6522d Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Wed, 17 Jun 2015 15:05:52 +0200 Subject: [PATCH 38/62] modified test network to test exceptions during parsing of documentation todo: - change to work wirh all exceptions - fix white space problems in the output text for Natspec Conflicts: test/libsolidity/SolidityEndToEndTest.cpp --- libsolidity/Parser.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/libsolidity/Parser.cpp b/libsolidity/Parser.cpp index 7ca1a40d3..fbf8478df 100644 --- a/libsolidity/Parser.cpp +++ b/libsolidity/Parser.cpp @@ -28,7 +28,6 @@ #include #include - using namespace std; namespace dev From dadcb7baa32f90cfd57285712413a4e59f42d515 Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Wed, 17 Jun 2015 11:47:29 +0200 Subject: [PATCH 39/62] modified test network to test exceptions during parsing of documentation todo: - change to work wirh all exceptions - fix white space problems in the output text for Natspec --- libsolidity/CompilerStack.h | 2 +- test/libsolidity/SolidityEndToEndTest.cpp | 27 ++++++++++++ test/libsolidity/SolidityNatspecJSON.cpp | 41 +++++-------------- test/libsolidity/solidityExecutionFramework.h | 8 ++++ 4 files changed, 46 insertions(+), 32 deletions(-) diff --git a/libsolidity/CompilerStack.h b/libsolidity/CompilerStack.h index fdf2562bc..ff2b0069c 100644 --- a/libsolidity/CompilerStack.h +++ b/libsolidity/CompilerStack.h @@ -149,7 +149,7 @@ public: std::tuple positionFromSourceLocation(SourceLocation const& _sourceLocation) const; /// Parses Natspec documentations. Throws exceptions in case of wrong documented contract - void parseNatspecDocumentation(dev::solidity::ContractDefinition& _contract); + void parseNatspecDocumentation(ContractDefinition& _contract); private: /** diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index f4b74a37d..70de7be56 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include using namespace std; @@ -4657,6 +4658,32 @@ BOOST_AUTO_TEST_CASE(bytes_memory_index_access) ) == encodeArgs(u256(data.size()), string("d"))); } +BOOST_AUTO_TEST_CASE(dev_title_at_function_error) +{ + char const* sourceCode = " /// @author Lefteris\n" + " /// @title Just a test contract\n" + "contract test {\n" + " /// @dev Mul function\n" + " /// @title I really should not be here\n" + " function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n" + "}\n"; + + compileRequireThrow(sourceCode); +} + +BOOST_AUTO_TEST_CASE(dev_documenting_nonexistant_param) +{ + char const* sourceCode = "contract test {\n" + " /// @dev Multiplies a number by 7 and adds second parameter\n" + " /// @param a Documentation for the first parameter\n" + " /// @param not_existing Documentation for the second parameter\n" + " function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n" + "}\n"; + + compileRequireThrow(sourceCode); +} + + BOOST_AUTO_TEST_CASE(storage_array_ref) { char const* sourceCode = R"( diff --git a/test/libsolidity/SolidityNatspecJSON.cpp b/test/libsolidity/SolidityNatspecJSON.cpp index d2c1ec186..e7e39a0ba 100644 --- a/test/libsolidity/SolidityNatspecJSON.cpp +++ b/test/libsolidity/SolidityNatspecJSON.cpp @@ -38,9 +38,11 @@ class DocumentationChecker public: DocumentationChecker(): m_compilerStack(false) {} - void checkNatspec(std::string const& _code, - std::string const& _expectedDocumentationString, - bool _userDocumentation) + void checkNatspec( + std::string const& _code, + std::string const& _expectedDocumentationString, + bool _userDocumentation + ) { std::string generatedDocumentationString; ETH_TEST_REQUIRE_NO_THROW(m_compilerStack.parse(_code), "Parsing failed"); @@ -53,9 +55,11 @@ public: m_reader.parse(generatedDocumentationString, generatedDocumentation); Json::Value expectedDocumentation; m_reader.parse(_expectedDocumentationString, expectedDocumentation); - BOOST_CHECK_MESSAGE(expectedDocumentation == generatedDocumentation, - "Expected " << _expectedDocumentationString << - "\n but got:\n" << generatedDocumentationString); + BOOST_CHECK_MESSAGE( + expectedDocumentation == generatedDocumentation, + "Expected " << _expectedDocumentationString << + "\n but got:\n" << generatedDocumentationString + ); } private: @@ -229,18 +233,6 @@ BOOST_AUTO_TEST_CASE(dev_multiple_params) checkNatspec(sourceCode, natspec, false); } -BOOST_AUTO_TEST_CASE(dev_documenting_nonexistant_param) -{ - char const* sourceCode = "contract test {\n" - " /// @dev Multiplies a number by 7 and adds second parameter\n" - " /// @param a Documentation for the first parameter\n" - " /// @param not_existing Documentation for the second parameter\n" - " function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n" - "}\n"; - - BOOST_CHECK_THROW(checkNatspec(sourceCode, "", false), DocstringParsingError); -} - BOOST_AUTO_TEST_CASE(dev_mutiline_param_description) { char const* sourceCode = "contract test {\n" @@ -488,19 +480,6 @@ BOOST_AUTO_TEST_CASE(dev_author_at_function) checkNatspec(sourceCode, natspec, false); } -BOOST_AUTO_TEST_CASE(dev_title_at_function_error) -{ - char const* sourceCode = " /// @author Lefteris\n" - " /// @title Just a test contract\n" - "contract test {\n" - " /// @dev Mul function\n" - " /// @title I really should not be here\n" - " function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n" - "}\n"; - - BOOST_CHECK_THROW(checkNatspec(sourceCode, "", false), DocstringParsingError); -} - BOOST_AUTO_TEST_CASE(natspec_notice_without_tag) { char const* sourceCode = "contract test {\n" diff --git a/test/libsolidity/solidityExecutionFramework.h b/test/libsolidity/solidityExecutionFramework.h index 03a201c72..c09d80a6e 100644 --- a/test/libsolidity/solidityExecutionFramework.h +++ b/test/libsolidity/solidityExecutionFramework.h @@ -28,6 +28,7 @@ #include #include #include +#include namespace dev { @@ -57,6 +58,13 @@ public: return m_output; } + void compileRequireThrow(std::string const& _sourceCode) + { + m_compiler.reset(false, m_addStandardSources); + m_compiler.addSource("", _sourceCode); + BOOST_REQUIRE_THROW(m_compiler.compile(m_optimize, m_optimizeRuns), DocstringParsingError); + } + bytes const& compileAndRun( std::string const& _sourceCode, u256 const& _value = 0, From 3d44ae2665f2dfcacc2bf6d4b002f1360bf1ff67 Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Wed, 17 Jun 2015 12:06:29 +0200 Subject: [PATCH 40/62] now for SolidityEndToEndTest we can use compileRequireThrow --- libsolidity/InterfaceHandler.cpp | 4 ++-- test/libsolidity/SolidityEndToEndTest.cpp | 4 ++-- test/libsolidity/solidityExecutionFramework.h | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libsolidity/InterfaceHandler.cpp b/libsolidity/InterfaceHandler.cpp index 36940d278..3b87032bc 100644 --- a/libsolidity/InterfaceHandler.cpp +++ b/libsolidity/InterfaceHandler.cpp @@ -165,7 +165,7 @@ void InterfaceHandler::generateUserDocumentation(ContractDefinition& _contractDe } doc["methods"] = methods; - _contractDef.setUserDocumentation(string(Json::FastWriter().write(doc))); + _contractDef.setUserDocumentation(Json::FastWriter().write(doc)); } unique_ptr InterfaceHandler::userDocumentation(ContractDefinition const& _contractDef) @@ -239,7 +239,7 @@ void InterfaceHandler::generateDevDocumentation(ContractDefinition& _contractDef } doc["methods"] = methods; - _contractDef.setDevDocumentation(string(Json::FastWriter().write(doc))); + _contractDef.setDevDocumentation(Json::FastWriter().write(doc)); } /* -- private -- */ diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 70de7be56..d44545145 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -4668,7 +4668,7 @@ BOOST_AUTO_TEST_CASE(dev_title_at_function_error) " function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n" "}\n"; - compileRequireThrow(sourceCode); + compileRequireThrow(sourceCode); } BOOST_AUTO_TEST_CASE(dev_documenting_nonexistant_param) @@ -4680,7 +4680,7 @@ BOOST_AUTO_TEST_CASE(dev_documenting_nonexistant_param) " function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n" "}\n"; - compileRequireThrow(sourceCode); + compileRequireThrow(sourceCode); } diff --git a/test/libsolidity/solidityExecutionFramework.h b/test/libsolidity/solidityExecutionFramework.h index c09d80a6e..f4dbbcb97 100644 --- a/test/libsolidity/solidityExecutionFramework.h +++ b/test/libsolidity/solidityExecutionFramework.h @@ -58,11 +58,12 @@ public: return m_output; } + template void compileRequireThrow(std::string const& _sourceCode) { m_compiler.reset(false, m_addStandardSources); m_compiler.addSource("", _sourceCode); - BOOST_REQUIRE_THROW(m_compiler.compile(m_optimize, m_optimizeRuns), DocstringParsingError); + BOOST_REQUIRE_THROW(m_compiler.compile(m_optimize, m_optimizeRuns), Exceptiontype); } bytes const& compileAndRun( From 42913a135e9c6c85b4847661f747b98b603e5aea Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Thu, 18 Jun 2015 14:57:43 +0200 Subject: [PATCH 41/62] changedthe output style of the Natspec docstring --- libsolidity/InterfaceHandler.cpp | 4 +- test/libsolidity/SolidityNatspecJSON.cpp | 51 ++++++++++++++++-------- 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/libsolidity/InterfaceHandler.cpp b/libsolidity/InterfaceHandler.cpp index 3b87032bc..fecdb3ece 100644 --- a/libsolidity/InterfaceHandler.cpp +++ b/libsolidity/InterfaceHandler.cpp @@ -165,7 +165,7 @@ void InterfaceHandler::generateUserDocumentation(ContractDefinition& _contractDe } doc["methods"] = methods; - _contractDef.setUserDocumentation(Json::FastWriter().write(doc)); + _contractDef.setUserDocumentation(Json::StyledWriter().write(doc)); } unique_ptr InterfaceHandler::userDocumentation(ContractDefinition const& _contractDef) @@ -239,7 +239,7 @@ void InterfaceHandler::generateDevDocumentation(ContractDefinition& _contractDef } doc["methods"] = methods; - _contractDef.setDevDocumentation(Json::FastWriter().write(doc)); + _contractDef.setDevDocumentation(Json::StyledWriter().write(doc)); } /* -- private -- */ diff --git a/test/libsolidity/SolidityNatspecJSON.cpp b/test/libsolidity/SolidityNatspecJSON.cpp index e7e39a0ba..2fc4f77b9 100644 --- a/test/libsolidity/SolidityNatspecJSON.cpp +++ b/test/libsolidity/SolidityNatspecJSON.cpp @@ -21,6 +21,7 @@ */ #include "../TestHelper.h" +#include #include #include #include @@ -482,31 +483,47 @@ BOOST_AUTO_TEST_CASE(dev_author_at_function) BOOST_AUTO_TEST_CASE(natspec_notice_without_tag) { - char const* sourceCode = "contract test {\n" - " /// I do something awesome\n" - " function mul(uint a) returns(uint d) { return a * 7; }\n" - "}\n"; + char const* sourceCode = R"( + contract test { + /// I do something awesome + function mul(uint a) returns(uint d) { return a * 7; } + } + )"; - char const* natspec = "{" - "\"methods\":{" - " \"mul(uint256)\":{ \"notice\": \"I do something awesome\"}" - "}}"; + + char const* natspec = R"ABCDEF( + { + "methods" : { + "mul(uint256)" : { + "notice" : " I do something awesome" + } + } + } + )ABCDEF"; checkNatspec(sourceCode, natspec, true); } BOOST_AUTO_TEST_CASE(natspec_multiline_notice_without_tag) { - char const* sourceCode = "contract test {\n" - " /// I do something awesome\n" - " /// which requires two lines to explain\n" - " function mul(uint a) returns(uint d) { return a * 7; }\n" - "}\n"; + char const* sourceCode = R"( + contract test { + /// I do something awesome + /// which requires two lines to explain + function mul(uint a) returns(uint d) { return a * 7; } + } + )"; + + char const* natspec = R"ABCDEF( + { + "methods" : { + "mul(uint256)" : { + "notice" : " I do something awesome which requires two lines to explain" + } + } + } - char const* natspec = "{" - "\"methods\":{" - " \"mul(uint256)\":{ \"notice\": \"I do something awesome which requires two lines to explain\"}" - "}}"; + )ABCDEF"; checkNatspec(sourceCode, natspec, true); } From e5ffefeab84229a74dd00a66e986252df3a1288a Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Fri, 19 Jun 2015 15:40:09 +0200 Subject: [PATCH 42/62] changed implementation according to notes from code review --- libsolidity/AST.cpp | 12 ++++++------ libsolidity/AST.h | 4 ++-- libsolidity/CompilerStack.cpp | 12 ++++++++---- libsolidity/CompilerStack.h | 2 +- libsolidity/InterfaceHandler.cpp | 30 ++++++++++-------------------- libsolidity/InterfaceHandler.h | 19 ++++++------------- mix/CodeModel.cpp | 2 +- 7 files changed, 34 insertions(+), 47 deletions(-) diff --git a/libsolidity/AST.cpp b/libsolidity/AST.cpp index 270ec3ed7..5b85989b9 100644 --- a/libsolidity/AST.cpp +++ b/libsolidity/AST.cpp @@ -382,19 +382,19 @@ vector, FunctionTypePointer>> const& ContractDefinition::getIn return *m_interfaceFunctionList; } -unique_ptr ContractDefinition::devDocumentation() const +string const& ContractDefinition::devDocumentation() const { - return unique_ptr(new string(m_devDocumentation)); + return m_devDocumentation; } -void ContractDefinition::setDevDocumentation(string const& _devDocumentation) +string const& ContractDefinition::userDocumentation() const { - m_devDocumentation = _devDocumentation; + return m_userDocumentation; } -std::unique_ptr ContractDefinition::userDocumentation() const +void ContractDefinition::setDevDocumentation(string const& _devDocumentation) { - return unique_ptr(new string(m_userDocumentation)); + m_devDocumentation = _devDocumentation; } void ContractDefinition::setUserDocumentation(string const& _userDocumentation) diff --git a/libsolidity/AST.h b/libsolidity/AST.h index 38262d009..fb83d4e11 100644 --- a/libsolidity/AST.h +++ b/libsolidity/AST.h @@ -281,10 +281,10 @@ public: /// Returns the fallback function or nullptr if no fallback function was specified. FunctionDefinition const* getFallbackFunction() const; - std::unique_ptr userDocumentation() const; + std::string const& userDocumentation() const; void setUserDocumentation(std::string const& _userDocumentation); - std::unique_ptr devDocumentation() const; + std::string const& devDocumentation() const; void setDevDocumentation(std::string const& _devDocumentation); private: diff --git a/libsolidity/CompilerStack.cpp b/libsolidity/CompilerStack.cpp index 7cd8316c7..6013c00d1 100644 --- a/libsolidity/CompilerStack.cpp +++ b/libsolidity/CompilerStack.cpp @@ -129,11 +129,12 @@ void CompilerStack::parse() m_parseSuccessful = true; } -void CompilerStack::parseNatspecDocumentation(ContractDefinition& _contract) +void CompilerStack::parseNatspecDocumentation(ContractDefinition const& _contract) { InterfaceHandler interfaceHandler; - interfaceHandler.generateDevDocumentation(_contract); - interfaceHandler.generateUserDocumentation(_contract); + string devDoc =_contract.devDocumentation(); + devDoc = interfaceHandler.devDocumentation(_contract); + //interfaceHandler.generateUserDocumentation(_contract); } void CompilerStack::parse(string const& _sourceCode) @@ -256,8 +257,11 @@ string const& CompilerStack::getMetadata(string const& _contractName, Documentat default: BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Illegal documentation type.")); } + auto resPtr = ((*doc) ? *(*doc) : contract.interfaceHandler->getDocumentation(*contract.contract, _type)); + if (!*doc) - *doc = contract.interfaceHandler->getDocumentation(*contract.contract, _type); + *doc = (unique_ptr(new string(contract.interfaceHandler->getDocumentation(*contract.contract, _type)))); + return *(*doc); } diff --git a/libsolidity/CompilerStack.h b/libsolidity/CompilerStack.h index ff2b0069c..dd0498854 100644 --- a/libsolidity/CompilerStack.h +++ b/libsolidity/CompilerStack.h @@ -149,7 +149,7 @@ public: std::tuple positionFromSourceLocation(SourceLocation const& _sourceLocation) const; /// Parses Natspec documentations. Throws exceptions in case of wrong documented contract - void parseNatspecDocumentation(ContractDefinition& _contract); + void parseNatspecDocumentation(dev::solidity::ContractDefinition const& _contract); private: /** diff --git a/libsolidity/InterfaceHandler.cpp b/libsolidity/InterfaceHandler.cpp index fecdb3ece..c6f8553d8 100644 --- a/libsolidity/InterfaceHandler.cpp +++ b/libsolidity/InterfaceHandler.cpp @@ -16,7 +16,7 @@ InterfaceHandler::InterfaceHandler() m_lastTag = DocTagType::None; } -unique_ptr InterfaceHandler::getDocumentation( +string InterfaceHandler::getDocumentation( ContractDefinition const& _contractDef, DocumentationType _type ) @@ -34,10 +34,10 @@ unique_ptr InterfaceHandler::getDocumentation( } BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown documentation type")); - return nullptr; + return ""; } -unique_ptr InterfaceHandler::getABIInterface(ContractDefinition const& _contractDef) +string InterfaceHandler::getABIInterface(ContractDefinition const& _contractDef) { Json::Value abi(Json::arrayValue); @@ -103,10 +103,10 @@ unique_ptr InterfaceHandler::getABIInterface(ContractDefinition const& _ event["inputs"] = params; abi.append(event); } - return unique_ptr(new string(Json::FastWriter().write(abi))); + return Json::FastWriter().write(abi); } -unique_ptr InterfaceHandler::getABISolidityInterface(ContractDefinition const& _contractDef) +string InterfaceHandler::getABISolidityInterface(ContractDefinition const& _contractDef) { string ret = "contract " + _contractDef.getName() + "{"; @@ -140,10 +140,10 @@ unique_ptr InterfaceHandler::getABISolidityInterface(ContractDefinition ret += ";"; } - return unique_ptr(new string(ret + "}")); + return ret + "}"; } -void InterfaceHandler::generateUserDocumentation(ContractDefinition& _contractDef) +string InterfaceHandler::userDocumentation(ContractDefinition const& _contractDef) { Json::Value doc; Json::Value methods(Json::objectValue); @@ -165,20 +165,10 @@ void InterfaceHandler::generateUserDocumentation(ContractDefinition& _contractDe } doc["methods"] = methods; - _contractDef.setUserDocumentation(Json::StyledWriter().write(doc)); + return Json::StyledWriter().write(doc); } -unique_ptr InterfaceHandler::userDocumentation(ContractDefinition const& _contractDef) -{ - return _contractDef.userDocumentation(); -} - -unique_ptr InterfaceHandler::devDocumentation(ContractDefinition const& _contractDef) -{ - return _contractDef.devDocumentation(); -} - -void InterfaceHandler::generateDevDocumentation(ContractDefinition& _contractDef) +string InterfaceHandler::devDocumentation(ContractDefinition const& _contractDef) { // LTODO: Somewhere in this function warnings for mismatch of param names // should be thrown @@ -239,7 +229,7 @@ void InterfaceHandler::generateDevDocumentation(ContractDefinition& _contractDef } doc["methods"] = methods; - _contractDef.setDevDocumentation(Json::StyledWriter().write(doc)); + return Json::StyledWriter().write(doc); } /* -- private -- */ diff --git a/libsolidity/InterfaceHandler.h b/libsolidity/InterfaceHandler.h index 1cc20c444..222db5a0e 100644 --- a/libsolidity/InterfaceHandler.h +++ b/libsolidity/InterfaceHandler.h @@ -65,9 +65,8 @@ public: /// @param _contractDef The contract definition /// @param _type The type of the documentation. Can be one of the /// types provided by @c DocumentationType - /// @return A unique pointer contained string with the json - /// representation of provided type - std::unique_ptr getDocumentation( + /// @return A string with the json representation of provided type + std::string getDocumentation( ContractDefinition const& _contractDef, DocumentationType _type ); @@ -75,24 +74,18 @@ public: /// @param _contractDef The contract definition /// @return A unique pointer contained string with the json /// representation of the contract's ABI Interface - std::unique_ptr getABIInterface(ContractDefinition const& _contractDef); - std::unique_ptr getABISolidityInterface(ContractDefinition const& _contractDef); - /// Generate the User documentation of the contract - /// @param _contractDef The contract definition - void generateUserDocumentation(ContractDefinition& _contractDef); + std::string getABIInterface(ContractDefinition const& _contractDef); + std::string getABISolidityInterface(ContractDefinition const& _contractDef); /// Get the User documentation of the contract /// @param _contractDef The contract definition /// @return A unique pointer contained string with the json /// representation of the contract's user documentation - std::unique_ptr userDocumentation(ContractDefinition const& _contractDef); - /// Genereates the Developer's documentation of the contract - /// @param _contractDef The contract definition - void generateDevDocumentation(ContractDefinition& _contractDef); + std::string userDocumentation(ContractDefinition const& _contractDef); /// Genereates the Developer's documentation of the contract /// @param _contractDef The contract definition /// @return A unique pointer contained string with the json /// representation of the contract's developer documentation - std::unique_ptr devDocumentation(ContractDefinition const& _contractDef); + std::string devDocumentation(ContractDefinition const& _contractDef); private: void resetUser(); diff --git a/mix/CodeModel.cpp b/mix/CodeModel.cpp index 082745cfe..213c1c1ee 100644 --- a/mix/CodeModel.cpp +++ b/mix/CodeModel.cpp @@ -157,7 +157,7 @@ CompiledContract::CompiledContract(const dev::solidity::CompilerStack& _compiler m_bytes = _compiler.getBytecode(_contractName.toStdString()); dev::solidity::InterfaceHandler interfaceHandler; - m_contractInterface = QString::fromStdString(*interfaceHandler.getABIInterface(contractDefinition)); + m_contractInterface = QString::fromStdString(interfaceHandler.getABIInterface(contractDefinition)); if (m_contractInterface.isEmpty()) m_contractInterface = "[]"; if (contractDefinition.getLocation().sourceName.get()) From 66cb1b76580bf96461b428190dfdccf178c4451b Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Wed, 15 Jul 2015 14:45:35 +0200 Subject: [PATCH 43/62] corrected comments --- libsolidity/InterfaceHandler.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/libsolidity/InterfaceHandler.h b/libsolidity/InterfaceHandler.h index 222db5a0e..49e92fcb0 100644 --- a/libsolidity/InterfaceHandler.h +++ b/libsolidity/InterfaceHandler.h @@ -72,19 +72,17 @@ public: ); /// Get the ABI Interface of the contract /// @param _contractDef The contract definition - /// @return A unique pointer contained string with the json - /// representation of the contract's ABI Interface + /// @return A string with the json representation of the contract's ABI Interface std::string getABIInterface(ContractDefinition const& _contractDef); std::string getABISolidityInterface(ContractDefinition const& _contractDef); /// Get the User documentation of the contract /// @param _contractDef The contract definition - /// @return A unique pointer contained string with the json - /// representation of the contract's user documentation + /// @return A string with the json representation of the contract's user documentation std::string userDocumentation(ContractDefinition const& _contractDef); /// Genereates the Developer's documentation of the contract /// @param _contractDef The contract definition - /// @return A unique pointer contained string with the json - /// representation of the contract's developer documentation + /// @return A string with the json representation + /// of the contract's developer documentation std::string devDocumentation(ContractDefinition const& _contractDef); private: From 398cc9bdb35c5b816277f7faa850c0f4dc403101 Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Wed, 15 Jul 2015 15:07:24 +0200 Subject: [PATCH 44/62] added calls of move cunstructor for returning string values. --- libsolidity/InterfaceHandler.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libsolidity/InterfaceHandler.cpp b/libsolidity/InterfaceHandler.cpp index c6f8553d8..b902de968 100644 --- a/libsolidity/InterfaceHandler.cpp +++ b/libsolidity/InterfaceHandler.cpp @@ -24,13 +24,13 @@ string InterfaceHandler::getDocumentation( switch(_type) { case DocumentationType::NatspecUser: - return userDocumentation(_contractDef); + return move(userDocumentation(_contractDef)); case DocumentationType::NatspecDev: - return devDocumentation(_contractDef); + return move(devDocumentation(_contractDef)); case DocumentationType::ABIInterface: - return getABIInterface(_contractDef); + return move(getABIInterface(_contractDef)); case DocumentationType::ABISolidityInterface: - return getABISolidityInterface(_contractDef); + return move(getABISolidityInterface(_contractDef)); } BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown documentation type")); @@ -103,7 +103,7 @@ string InterfaceHandler::getABIInterface(ContractDefinition const& _contractDef) event["inputs"] = params; abi.append(event); } - return Json::FastWriter().write(abi); + return move(Json::FastWriter().write(abi)); } string InterfaceHandler::getABISolidityInterface(ContractDefinition const& _contractDef) @@ -140,7 +140,7 @@ string InterfaceHandler::getABISolidityInterface(ContractDefinition const& _cont ret += ";"; } - return ret + "}"; + return move(ret + "}"); } string InterfaceHandler::userDocumentation(ContractDefinition const& _contractDef) @@ -165,7 +165,7 @@ string InterfaceHandler::userDocumentation(ContractDefinition const& _contractDe } doc["methods"] = methods; - return Json::StyledWriter().write(doc); + return move(Json::StyledWriter().write(doc)); } string InterfaceHandler::devDocumentation(ContractDefinition const& _contractDef) @@ -229,7 +229,7 @@ string InterfaceHandler::devDocumentation(ContractDefinition const& _contractDef } doc["methods"] = methods; - return Json::StyledWriter().write(doc); + return move(Json::StyledWriter().write(doc)); } /* -- private -- */ From 04702b1fa55351c2ff8b97c83c7bde4c696911d4 Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Wed, 15 Jul 2015 16:23:10 +0200 Subject: [PATCH 45/62] removed unnecessary function --- libsolidity/CompilerStack.cpp | 18 +++++++----------- libsolidity/CompilerStack.h | 3 --- libsolidity/InterfaceHandler.h | 2 +- test/libsolidity/SolidityNatspecJSON.cpp | 5 ++--- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/libsolidity/CompilerStack.cpp b/libsolidity/CompilerStack.cpp index 6013c00d1..f056bb9b1 100644 --- a/libsolidity/CompilerStack.cpp +++ b/libsolidity/CompilerStack.cpp @@ -116,6 +116,7 @@ void CompilerStack::parse() resolver.resolveNamesAndTypes(*contract); m_contracts[contract->getName()].contract = contract; } + InterfaceHandler interfaceHandler; for (Source const* source: m_sourceOrder) for (ASTPointer const& node: source->ast->getNodes()) if (ContractDefinition* contract = dynamic_cast(node.get())) @@ -123,20 +124,13 @@ void CompilerStack::parse() m_globalContext->setCurrentContract(*contract); resolver.updateDeclaration(*m_globalContext->getCurrentThis()); resolver.checkTypeRequirements(*contract); + contract->setDevDocumentation(interfaceHandler.devDocumentation(*contract)); + contract->setUserDocumentation(interfaceHandler.userDocumentation(*contract)); m_contracts[contract->getName()].contract = contract; - parseNatspecDocumentation(*contract); } m_parseSuccessful = true; } -void CompilerStack::parseNatspecDocumentation(ContractDefinition const& _contract) -{ - InterfaceHandler interfaceHandler; - string devDoc =_contract.devDocumentation(); - devDoc = interfaceHandler.devDocumentation(_contract); - //interfaceHandler.generateUserDocumentation(_contract); -} - void CompilerStack::parse(string const& _sourceCode) { setSource(_sourceCode); @@ -240,6 +234,8 @@ string const& CompilerStack::getMetadata(string const& _contractName, Documentat Contract const& contract = getContract(_contractName); std::unique_ptr* doc; + + // checks wheather we already have the documentation switch (_type) { case DocumentationType::NatspecUser: @@ -257,10 +253,10 @@ string const& CompilerStack::getMetadata(string const& _contractName, Documentat default: BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Illegal documentation type.")); } - auto resPtr = ((*doc) ? *(*doc) : contract.interfaceHandler->getDocumentation(*contract.contract, _type)); + // caches the result if (!*doc) - *doc = (unique_ptr(new string(contract.interfaceHandler->getDocumentation(*contract.contract, _type)))); + doc->reset(new string(contract.interfaceHandler->getDocumentation(*contract.contract, _type))); return *(*doc); } diff --git a/libsolidity/CompilerStack.h b/libsolidity/CompilerStack.h index dd0498854..a7c6ea3ba 100644 --- a/libsolidity/CompilerStack.h +++ b/libsolidity/CompilerStack.h @@ -148,9 +148,6 @@ public: /// start line, start column, end line, end column std::tuple positionFromSourceLocation(SourceLocation const& _sourceLocation) const; - /// Parses Natspec documentations. Throws exceptions in case of wrong documented contract - void parseNatspecDocumentation(dev::solidity::ContractDefinition const& _contract); - private: /** * Information pertaining to one source unit, filled gradually during parsing and compilation. diff --git a/libsolidity/InterfaceHandler.h b/libsolidity/InterfaceHandler.h index 49e92fcb0..7784dbd7f 100644 --- a/libsolidity/InterfaceHandler.h +++ b/libsolidity/InterfaceHandler.h @@ -82,7 +82,7 @@ public: /// Genereates the Developer's documentation of the contract /// @param _contractDef The contract definition /// @return A string with the json representation - /// of the contract's developer documentation + /// of the contract's developer documentation std::string devDocumentation(ContractDefinition const& _contractDef); private: diff --git a/test/libsolidity/SolidityNatspecJSON.cpp b/test/libsolidity/SolidityNatspecJSON.cpp index 2fc4f77b9..73c080f70 100644 --- a/test/libsolidity/SolidityNatspecJSON.cpp +++ b/test/libsolidity/SolidityNatspecJSON.cpp @@ -495,7 +495,7 @@ BOOST_AUTO_TEST_CASE(natspec_notice_without_tag) { "methods" : { "mul(uint256)" : { - "notice" : " I do something awesome" + "notice" : "I do something awesome" } } } @@ -518,11 +518,10 @@ BOOST_AUTO_TEST_CASE(natspec_multiline_notice_without_tag) { "methods" : { "mul(uint256)" : { - "notice" : " I do something awesome which requires two lines to explain" + "notice" : "I do something awesome which requires two lines to explain" } } } - )ABCDEF"; checkNatspec(sourceCode, natspec, true); From bdd86f768c4ed819ad2a78debfd07261cfc274a1 Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Thu, 16 Jul 2015 14:05:23 +0200 Subject: [PATCH 46/62] default parameter changed --- libwhisper/WhisperHost.h | 2 +- test/libwhisper/whisperDB.cpp | 6 +++--- test/libwhisper/whisperTopic.cpp | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libwhisper/WhisperHost.h b/libwhisper/WhisperHost.h index 2470ad68a..20b2d6e7a 100644 --- a/libwhisper/WhisperHost.h +++ b/libwhisper/WhisperHost.h @@ -48,7 +48,7 @@ class WhisperHost: public HostCapability, public Interface, public friend class WhisperPeer; public: - WhisperHost(bool _useDB = true); + WhisperHost(bool _useDB = false); virtual ~WhisperHost(); unsigned protocolVersion() const { return WhisperProtocolVersion; } void cleanup(); ///< remove old messages diff --git a/test/libwhisper/whisperDB.cpp b/test/libwhisper/whisperDB.cpp index 333b7dc55..f5b74be1f 100644 --- a/test/libwhisper/whisperDB.cpp +++ b/test/libwhisper/whisperDB.cpp @@ -132,7 +132,7 @@ BOOST_AUTO_TEST_CASE(messages) { p2p::Host h("Test"); - auto wh = h.registerCapability(new WhisperHost()); + auto wh = h.registerCapability(new WhisperHost(true)); preexisting = wh->all(); cnote << preexisting.size() << "preexisting messages in DB"; @@ -144,7 +144,7 @@ BOOST_AUTO_TEST_CASE(messages) { p2p::Host h("Test"); - auto wh = h.registerCapability(new WhisperHost()); + auto wh = h.registerCapability(new WhisperHost(true)); map m2 = wh->all(); BOOST_REQUIRE_EQUAL(m1.size(), m2.size()); BOOST_REQUIRE_EQUAL(m1.size() - preexisting.size(), TestSize); @@ -188,7 +188,7 @@ BOOST_AUTO_TEST_CASE(corruptedData) { p2p::Host h("Test"); - auto wh = h.registerCapability(new WhisperHost()); + auto wh = h.registerCapability(new WhisperHost(true)); m = wh->all(); BOOST_REQUIRE(m.end() == m.find(x)); } diff --git a/test/libwhisper/whisperTopic.cpp b/test/libwhisper/whisperTopic.cpp index ad438f3ba..04f4f3f77 100644 --- a/test/libwhisper/whisperTopic.cpp +++ b/test/libwhisper/whisperTopic.cpp @@ -223,7 +223,7 @@ BOOST_AUTO_TEST_CASE(asyncforwarding) // Host must be configured not to share peers. Host host1("Forwarder", NetworkPreferences("127.0.0.1", 30305, false)); host1.setIdealPeerCount(1); - auto whost1 = host1.registerCapability(new WhisperHost(false)); + auto whost1 = host1.registerCapability(new WhisperHost()); host1.start(); while (!host1.haveNetwork()) this_thread::sleep_for(chrono::milliseconds(2)); @@ -252,7 +252,7 @@ BOOST_AUTO_TEST_CASE(asyncforwarding) { Host host2("Sender", NetworkPreferences("127.0.0.1", 30300, false)); host2.setIdealPeerCount(1); - shared_ptr whost2 = host2.registerCapability(new WhisperHost(false)); + shared_ptr whost2 = host2.registerCapability(new WhisperHost()); host2.start(); while (!host2.haveNetwork()) this_thread::sleep_for(chrono::milliseconds(2)); @@ -269,7 +269,7 @@ BOOST_AUTO_TEST_CASE(asyncforwarding) { Host ph("Listener", NetworkPreferences("127.0.0.1", 30300, false)); ph.setIdealPeerCount(1); - shared_ptr wh = ph.registerCapability(new WhisperHost(false)); + shared_ptr wh = ph.registerCapability(new WhisperHost()); ph.start(); while (!ph.haveNetwork()) this_thread::sleep_for(chrono::milliseconds(2)); From 9b45b6b571d92d89e443d847a6e4a858a68cd59f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 16 Jul 2015 14:20:44 +0200 Subject: [PATCH 47/62] Use external prebuilt OpenCL ICD DLL. --- CMakeLists.txt | 5 ----- cmake/FindOpenCL.cmake | 18 ++++++++++++++++++ eth/CMakeLists.txt | 5 +++-- ethminer/CMakeLists.txt | 1 + libethash-cl/CMakeLists.txt | 7 ++----- libethash-cl/ethash_cl_miner.cpp | 2 +- 6 files changed, 25 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7edaf8401..b926ae165 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -426,11 +426,6 @@ if (GENERAL OR MINER) add_subdirectory(libethash) if (ETHASHCL) add_subdirectory(libethash-cl) - if (APPLE) - else() - add_subdirectory(khronos_icd) - set(OpenCL_TARGET OpenCL_ICD) - endif() endif () endif () diff --git a/cmake/FindOpenCL.cmake b/cmake/FindOpenCL.cmake index a786e2e86..fe03132b1 100644 --- a/cmake/FindOpenCL.cmake +++ b/cmake/FindOpenCL.cmake @@ -124,6 +124,24 @@ endif() set(OpenCL_LIBRARIES ${OpenCL_LIBRARY}) set(OpenCL_INCLUDE_DIRS ${OpenCL_INCLUDE_DIR}) +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + + find_library( + OpenCL_LIBRARY_DEBUG + NAMES OpenCL_d + ) + + set(OpenCL_LIBRARIES optimized ${OpenCL_LIBRARY} debug ${OpenCL_LIBRARY_DEBUG}) + + # prepare dlls + string(REPLACE ".lib" ".dll" OpenCL_DLL ${OpenCL_LIBRARY}) + string(REPLACE "/lib/" "/bin/" OpenCL_DLL ${OpenCL_DLL}) + string(REPLACE ".lib" ".dll" OpenCL_DLL_DEBUG ${OpenCL_LIBRARY_DEBUG}) + string(REPLACE "/lib/" "/bin/" OpenCL_DLL_DEBUG ${OpenCL_DLL_DEBUG}) + set(OpenCL_DLLS optimized ${OpenCL_DLL} debug ${OpenCL_DLL_DEBUG}) + +endif() + include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) find_package_handle_standard_args( OpenCL diff --git a/eth/CMakeLists.txt b/eth/CMakeLists.txt index 56c0ad710..c3fe2fc6c 100644 --- a/eth/CMakeLists.txt +++ b/eth/CMakeLists.txt @@ -30,7 +30,8 @@ if (JSONRPC) target_link_libraries(${EXECUTABLE} ${JSON_RPC_CPP_CLIENT_LIBRARIES}) target_link_libraries(${EXECUTABLE} ${CURL_LIBRARIES}) if (DEFINED WIN32 AND NOT DEFINED CMAKE_COMPILER_IS_MINGW) - eth_copy_dlls(${EXECUTABLE} CURL_DLLS) + eth_copy_dlls("${EXECUTABLE}" MHD_DLLS) + eth_copy_dlls("${EXECUTABLE}" OpenCL_DLLS) endif() endif() @@ -42,7 +43,7 @@ if (JSCONSOLE) endif() #if (DEFINED WIN32 AND NOT DEFINED CMAKE_COMPILER_IS_MINGW) -# eth_copy_dlls("${EXECUTABLE}" MHD_DLLS) +# eth_copy_dlls("${EXECUTABLE}" MHD_DLLS OpenCL_DLLS) #endif() if (APPLE) diff --git a/ethminer/CMakeLists.txt b/ethminer/CMakeLists.txt index c321f0e5d..8b79afd72 100644 --- a/ethminer/CMakeLists.txt +++ b/ethminer/CMakeLists.txt @@ -33,6 +33,7 @@ target_link_libraries(${EXECUTABLE} ethash) if (DEFINED WIN32 AND NOT DEFINED CMAKE_COMPILER_IS_MINGW) eth_copy_dlls("${EXECUTABLE}" MHD_DLLS) + eth_copy_dlls("${EXECUTABLE}" OpenCL_DLLS) endif() if (APPLE) diff --git a/libethash-cl/CMakeLists.txt b/libethash-cl/CMakeLists.txt index b76eabfb5..7de2d6971 100644 --- a/libethash-cl/CMakeLists.txt +++ b/libethash-cl/CMakeLists.txt @@ -23,11 +23,8 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${Boost_INCLUDE_DIRS}) include_directories(..) add_library(${EXECUTABLE} ${SRC_LIST} ${HEADERS}) -if (APPLE) - TARGET_LINK_LIBRARIES(${EXECUTABLE} ${OpenCL_LIBRARY} ethash) -else() - TARGET_LINK_LIBRARIES(${EXECUTABLE} OpenCL_ICD ethash) -endif() +target_include_directories(${EXECUTABLE} PUBLIC ${OpenCL_INCLUDE_DIR}) +target_link_libraries(${EXECUTABLE} ${OpenCL_LIBRARIES} ethash) install( TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib ) install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} ) diff --git a/libethash-cl/ethash_cl_miner.cpp b/libethash-cl/ethash_cl_miner.cpp index 15e0847a4..50fb273b6 100644 --- a/libethash-cl/ethash_cl_miner.cpp +++ b/libethash-cl/ethash_cl_miner.cpp @@ -180,7 +180,7 @@ bool ethash_cl_miner::configureGPU( // by default let's only consider the DAG of the first epoch uint64_t dagSize = ethash_get_datasize(_currentBlock); uint64_t requiredSize = dagSize + _extraGPUMemory; - return searchForAllDevices(_platformId, [&requiredSize](cl::Device const _device) -> bool + return searchForAllDevices(_platformId, [&requiredSize](cl::Device const& _device) -> bool { cl_ulong result; _device.getInfo(CL_DEVICE_GLOBAL_MEM_SIZE, &result); From 77daf6539870784254fa6eaf9b450bc2a50ad0ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 16 Jul 2015 14:27:10 +0200 Subject: [PATCH 48/62] Remove OpenCl ICD loader source coude (khronos_icd). --- khronos_icd/CMakeLists.txt | 35 - khronos_icd/LICENSE.txt | 38 - khronos_icd/Makefile | 30 - khronos_icd/OpenCL.def | 143 -- khronos_icd/OpenCL.rc | 74 - khronos_icd/README.txt | 50 - khronos_icd/build_using_cmake.bat | 11 - khronos_icd/icd.c | 218 --- khronos_icd/icd.h | 199 --- khronos_icd/icd_dispatch.c | 2186 ----------------------------- khronos_icd/icd_dispatch.h | 1283 ----------------- khronos_icd/icd_exports.map | 153 -- khronos_icd/icd_linux.c | 178 --- khronos_icd/icd_windows.c | 152 -- khronos_icd/inc/README.txt | 14 - 15 files changed, 4764 deletions(-) delete mode 100644 khronos_icd/CMakeLists.txt delete mode 100644 khronos_icd/LICENSE.txt delete mode 100644 khronos_icd/Makefile delete mode 100644 khronos_icd/OpenCL.def delete mode 100644 khronos_icd/OpenCL.rc delete mode 100644 khronos_icd/README.txt delete mode 100644 khronos_icd/build_using_cmake.bat delete mode 100644 khronos_icd/icd.c delete mode 100644 khronos_icd/icd.h delete mode 100644 khronos_icd/icd_dispatch.c delete mode 100644 khronos_icd/icd_dispatch.h delete mode 100644 khronos_icd/icd_exports.map delete mode 100644 khronos_icd/icd_linux.c delete mode 100644 khronos_icd/icd_windows.c delete mode 100644 khronos_icd/inc/README.txt diff --git a/khronos_icd/CMakeLists.txt b/khronos_icd/CMakeLists.txt deleted file mode 100644 index c9a605ea4..000000000 --- a/khronos_icd/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -cmake_minimum_required (VERSION 2.6) -cmake_policy(SET CMP0015 NEW) -set(CMAKE_AUTOMOC OFF) - -aux_source_directory(. SRC_LIST) - -include_directories(BEFORE ..) - -project (OPENCL_ICD_LOADER) - -set (OPENCL_ICD_LOADER_SOURCES icd.c icd_dispatch.c) - -if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") - list (APPEND OPENCL_ICD_LOADER_SOURCES icd_linux.c icd_exports.map) - get_filename_component(ICD_EXPORTS_MAP_FILE icd_exports.map ABSOLUTE) -else () - list (APPEND OPENCL_ICD_LOADER_SOURCES icd_windows.c OpenCL.def) - include_directories ($ENV{DXSDK_DIR}/Include) -endif () - -# Change this to point to a directory containing OpenCL header directory "CL" -# OR copy OpenCL headers to ./inc/CL/ -include_directories (./inc) - -add_library (OpenCL_ICD SHARED ${OPENCL_ICD_LOADER_SOURCES}) -set_target_properties (OpenCL_ICD PROPERTIES VERSION "1.2" SOVERSION "1") - -if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") - set_target_properties (OpenCL_ICD PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${ICD_EXPORTS_MAP_FILE}") -endif () - -target_link_libraries (OpenCL_ICD ${CMAKE_DL_LIBS}) -target_include_directories(OpenCL_ICD PUBLIC ${OpenCL_INCLUDE_DIR}) - -install(TARGETS OpenCL_ICD RUNTIME DESTINATION bin LIBRARY DESTINATION lib) diff --git a/khronos_icd/LICENSE.txt b/khronos_icd/LICENSE.txt deleted file mode 100644 index 81a772bd4..000000000 --- a/khronos_icd/LICENSE.txt +++ /dev/null @@ -1,38 +0,0 @@ -Copyright (c) 2012 The Khronos Group Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software source and associated documentation files (the "Materials"), -to use, copy, modify and compile the Materials to create a binary under the -following terms and conditions: - -1. The Materials shall NOT be distributed to any third party; - -2. The binary may be distributed without restriction, including without -limitation the rights to use, copy, merge, publish, distribute, sublicense, -and/or sell copies, and to permit persons to whom the binary is furnished to -do so; - -3. All modifications to the Materials used to create a binary that is -distributed to third parties shall be provided to Khronos with an -unrestricted license to use for the purposes of implementing bug fixes and -enhancements to the Materials; - -4. If the binary is used as part of an OpenCL(TM) implementation, whether -binary is distributed together with or separately to that implementation, -then recipient must become an OpenCL Adopter and follow the published OpenCL -conformance process for that implementation, details at: -http://www.khronos.org/conformance/; - -5. The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Materials. - -THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN -THE MATERIALS. - -OpenCL is a trademark of Apple Inc. used under license by Khronos. - diff --git a/khronos_icd/Makefile b/khronos_icd/Makefile deleted file mode 100644 index 886c1dc59..000000000 --- a/khronos_icd/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -.PHONY: default do_cmake do_build test package -.PHONY: clean clobber - -BUILD_DIR:=build -BIN_DIR:=bin - -ICD_VERSION:=$(shell grep FileVersion OpenCL.rc | sed "s/.*\([0-9]\+\.[0-9]\+\.[0-9]\+.[0-9]\+\).*/\1/") -PACKAGE_PATH:=/tmp/opencl-icd-${ICD_VERSION}.tgz - -default: do_build - -do_build: do_cmake - ${MAKE} -C ${BUILD_DIR} - -do_cmake: - mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR} && cmake .. - -test: - ${MAKE} -C ${BUILD_DIR} test - -package: clobber - rm -f ${PACKAGE_PATH} - tar -C .. -czf ${PACKAGE_PATH} --exclude .svn icd - @echo "Package created at ${PACKAGE_PATH}" - -clean: - ${MAKE} -C ${BUILD_DIR} clean - -clobber: - rm -rf ${BUILD_DIR} ${BIN_DIR} diff --git a/khronos_icd/OpenCL.def b/khronos_icd/OpenCL.def deleted file mode 100644 index de92e385a..000000000 --- a/khronos_icd/OpenCL.def +++ /dev/null @@ -1,143 +0,0 @@ -; Copyright (c) 2012 The Khronos Group Inc. -; -; Permission is hereby granted, free of charge, to any person obtaining a copy -; of this software source and associated documentation files (the "Materials"), -; to use, copy, modify and compile the Materials to create a binary under the -; following terms and conditions: -; -; 1. The Materials shall NOT be distributed to any third party; -; -; 2. The binary may be distributed without restriction, including without -; limitation the rights to use, copy, merge, publish, distribute, sublicense, -; and/or sell copies, and to permit persons to whom the binary is furnished to -; do so; -; -; 3. All modifications to the Materials used to create a binary that is -; distributed to third parties shall be provided to Khronos with an -; unrestricted license to use for the purposes of implementing bug fixes and -; enhancements to the Materials; -; -; 4. If the binary is used as part of an OpenCL(TM) implementation, whether -; binary is distributed together with or separately to that implementation, -; then recipient must become an OpenCL Adopter and follow the published OpenCL -; conformance process for that implementation, details at: -; http://www.khronos.org/conformance/; -; -; 5. The above copyright notice and this permission notice shall be included in -; all copies or substantial portions of the Materials. -; -; THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -; OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN -; THE MATERIALS. -; -; OpenCL is a trademark of Apple Inc. used under license by Khronos. - -EXPORTS - -; OpenCL 1.0 -clBuildProgram -clCreateBuffer -clCreateCommandQueue -clCreateContext -clCreateContextFromType -clCreateFromGLBuffer -clCreateFromGLRenderbuffer -clCreateFromGLTexture2D -clCreateFromGLTexture3D -clCreateImage2D -clCreateImage3D -clCreateKernel -clCreateKernelsInProgram -clCreateProgramWithBinary -clCreateProgramWithSource -clCreateSampler -clEnqueueAcquireGLObjects -clEnqueueBarrier -clEnqueueCopyBuffer -clEnqueueCopyBufferToImage -clEnqueueCopyImage -clEnqueueCopyImageToBuffer -clEnqueueMapBuffer -clEnqueueMapImage -clEnqueueMarker -clEnqueueNDRangeKernel -clEnqueueNativeKernel -clEnqueueReadBuffer -clEnqueueReadImage -clEnqueueReleaseGLObjects -clEnqueueTask -clEnqueueUnmapMemObject -clEnqueueWaitForEvents -clEnqueueWriteBuffer -clEnqueueWriteImage -clFinish -clFlush -clGetCommandQueueInfo -clGetContextInfo -clGetDeviceIDs -clGetDeviceInfo -clGetEventInfo -clGetEventProfilingInfo -clGetExtensionFunctionAddress -clGetGLObjectInfo -clGetGLTextureInfo -clGetImageInfo -clGetKernelInfo -clGetKernelWorkGroupInfo -clGetMemObjectInfo -clGetPlatformIDs -clGetPlatformInfo -clGetProgramBuildInfo -clGetProgramInfo -clGetSamplerInfo -clGetSupportedImageFormats -clReleaseCommandQueue -clReleaseContext -clReleaseEvent -clReleaseKernel -clReleaseMemObject -clReleaseProgram -clReleaseSampler -clRetainCommandQueue -clRetainContext -clRetainEvent -clRetainKernel -clRetainMemObject -clRetainProgram -clRetainSampler -clSetCommandQueueProperty -clSetKernelArg -clUnloadCompiler -clWaitForEvents - -; OpenCL 1.1 API -clCreateSubBuffer -clCreateUserEvent -clEnqueueCopyBufferRect -clEnqueueReadBufferRect -clEnqueueWriteBufferRect -clSetEventCallback -clSetMemObjectDestructorCallback -clSetUserEventStatus - -; OpenCL 1.2 API -clCompileProgram -clCreateFromGLTexture -clCreateImage -clCreateProgramWithBuiltInKernels -clCreateSubDevices -clEnqueueBarrierWithWaitList -clEnqueueFillBuffer -clEnqueueFillImage -clEnqueueMarkerWithWaitList -clEnqueueMigrateMemObjects -clGetExtensionFunctionAddressForPlatform -clGetKernelArgInfo -clLinkProgram -clReleaseDevice -clRetainDevice -clUnloadPlatformCompiler diff --git a/khronos_icd/OpenCL.rc b/khronos_icd/OpenCL.rc deleted file mode 100644 index 5cddfe553..000000000 --- a/khronos_icd/OpenCL.rc +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2012 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software source and associated documentation files (the "Materials"), - * to use, copy, modify and compile the Materials to create a binary under the - * following terms and conditions: - * - * 1. The Materials shall NOT be distributed to any third party; - * - * 2. The binary may be distributed without restriction, including without - * limitation the rights to use, copy, merge, publish, distribute, sublicense, - * and/or sell copies, and to permit persons to whom the binary is furnished to - * do so; - * - * 3. All modifications to the Materials used to create a binary that is - * distributed to third parties shall be provided to Khronos with an - * unrestricted license to use for the purposes of implementing bug fixes and - * enhancements to the Materials; - * - * 4. If the binary is used as part of an OpenCL(TM) implementation, whether - * binary is distributed together with or separately to that implementation, - * then recipient must become an OpenCL Adopter and follow the published OpenCL - * conformance process for that implementation, details at: - * http://www.khronos.org/conformance/; - * - * 5. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN - * THE MATERIALS. - * - * OpenCL is a trademark of Apple Inc. used under license by Khronos. - */ - -#include - -#ifdef RC_INVOKED - -VS_VERSION_INFO VERSIONINFO -FILEVERSION 1,2,11,0 -PRODUCTVERSION 1,2,11,0 -FILETYPE VFT_DLL - -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904E4" - BEGIN - VALUE "FileDescription" ,"OpenCL Client DLL" - VALUE "ProductName" ,"Khronos OpenCL ICD" - VALUE "LegalCopyright" ,"Copyright \251 The Khronos Group Inc 2011" - VALUE "FileVersion" ,"1.2.11.0" - - VALUE "CompanyName" ,"Khronos Group" - VALUE "InternalName" ,"OpenCL" - VALUE "OriginalFilename","OpenCL.dll" - END - END - - BLOCK "VarFileInfo" - BEGIN - // extend this line for localized versions - VALUE "Translation", 0x0409, 0x04E4 - END -END - -#endif - diff --git a/khronos_icd/README.txt b/khronos_icd/README.txt deleted file mode 100644 index 3b51170e9..000000000 --- a/khronos_icd/README.txt +++ /dev/null @@ -1,50 +0,0 @@ -== Building ICD and ICD Test == - -The build system will build ICD Loader library (OpenCL.dll or libOpenCL.so) and -ICD Loader Test binary (icd_loader_test) and some helper libraries for the test. - -=== Linux === - -Run "make" - -=== Windows === - -Run "build_using_cmake.bat" - -== Running ICD Test == - -ICD Test can be run using ctest, which is a companion to cmake. It can also be -run directly by executing icd_loader_test(.exe) executable from the bin folder. - -=== Linux === - -1. Add driver stub as an ICD - echo full/path/to/libOpenCLDriverStub.so > /etc/OpenCL/vendors/test.icd - -2. Run test using ctest - make test - -=== Windows === - -1. Add driver stub as an ICD by adding appropriate registry value - Key for 32-bit apps: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Khronos\OpenCL\Vendors - Key for 64-bit apps: HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenCL\Vendors - - Add a REG_DWORD value: - Name: c:/full/path/to/OpenCLDriverStub.dll - Data: 0 - - Note: The build_using_cmake.bat builds ICD test as a 32-bit binary. - -2. Run test using ctest.exe - cd build - ctest.exe - -== Cleanup == - -Manually remove the registry key or .icd files added for running the ICD test. - -The "build" and "bin" folders are autogenerated by the build so those may be -safely deleted without losing any source code (on Linux "make clobber" will -delete them). - diff --git a/khronos_icd/build_using_cmake.bat b/khronos_icd/build_using_cmake.bat deleted file mode 100644 index f0044db7a..000000000 --- a/khronos_icd/build_using_cmake.bat +++ /dev/null @@ -1,11 +0,0 @@ -call "%VS90COMNTOOLS%/vsvars32.bat" - -set BUILD_DIR=build -set BIN_DIR=bin - -mkdir %BUILD_DIR% -cd %BUILD_DIR% -cmake -G "NMake Makefiles" ../ -nmake -cd .. - diff --git a/khronos_icd/icd.c b/khronos_icd/icd.c deleted file mode 100644 index c59a7d9b5..000000000 --- a/khronos_icd/icd.c +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Copyright (c) 2012 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software source and associated documentation files (the "Materials"), - * to use, copy, modify and compile the Materials to create a binary under the - * following terms and conditions: - * - * 1. The Materials shall NOT be distributed to any third party; - * - * 2. The binary may be distributed without restriction, including without - * limitation the rights to use, copy, merge, publish, distribute, sublicense, - * and/or sell copies, and to permit persons to whom the binary is furnished to - * do so; - * - * 3. All modifications to the Materials used to create a binary that is - * distributed to third parties shall be provided to Khronos with an - * unrestricted license to use for the purposes of implementing bug fixes and - * enhancements to the Materials; - * - * 4. If the binary is used as part of an OpenCL(TM) implementation, whether - * binary is distributed together with or separately to that implementation, - * then recipient must become an OpenCL Adopter and follow the published OpenCL - * conformance process for that implementation, details at: - * http://www.khronos.org/conformance/; - * - * 5. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN - * THE MATERIALS. - * - * OpenCL is a trademark of Apple Inc. used under license by Khronos. - */ - -#include "icd.h" -#include "icd_dispatch.h" -#include -#include - -KHRicdState khrIcdState = {0}; - -// entrypoint to initialize the ICD and add all vendors -void khrIcdInitialize(void) -{ - // make sure we don't double-initialize - // TODO: this should use an atomic exchange to be thread-safe - if (khrIcdState.initialized) - { - return; - } - khrIcdState.initialized = CL_TRUE; - - // enumerate vendors present on the system - khrIcdOsVendorsEnumerate(); -} - -void khrIcdVendorAdd(const char *libraryName) -{ - void *library = NULL; - cl_int result = CL_SUCCESS; - pfn_clGetExtensionFunctionAddress p_clGetExtensionFunctionAddress = NULL; - pfn_clIcdGetPlatformIDs p_clIcdGetPlatformIDs = NULL; - cl_uint i = 0; - cl_uint platformCount = 0; - cl_platform_id *platforms = NULL; - - // require that the library name be valid - if (!libraryName) - { - goto Done; - } - KHR_ICD_TRACE("attempting to add vendor %s...\n", libraryName); - - // load its library and query its function pointers - library = khrIcdOsLibraryLoad(libraryName); - if (!library) - { - KHR_ICD_TRACE("failed to load library %s\n", libraryName); - goto Done; - } - - // get the library's clGetExtensionFunctionAddress pointer - p_clGetExtensionFunctionAddress = khrIcdOsLibraryGetFunctionAddress(library, "clGetExtensionFunctionAddress"); - if (!p_clGetExtensionFunctionAddress) - { - KHR_ICD_TRACE("failed to get function address clGetExtensionFunctionAddress\n"); - goto Done; - } - - // use that function to get the clIcdGetPlatformIDsKHR function pointer - p_clIcdGetPlatformIDs = p_clGetExtensionFunctionAddress("clIcdGetPlatformIDsKHR"); - if (!p_clIcdGetPlatformIDs) - { - KHR_ICD_TRACE("failed to get extension function address clIcdGetPlatformIDsKHR\n"); - goto Done; - } - - // query the number of platforms available and allocate space to store them - result = p_clIcdGetPlatformIDs(0, NULL, &platformCount); - if (CL_SUCCESS != result) - { - KHR_ICD_TRACE("failed clIcdGetPlatformIDs\n"); - goto Done; - } - platforms = (cl_platform_id *)malloc(platformCount * sizeof(cl_platform_id) ); - if (!platforms) - { - KHR_ICD_TRACE("failed to allocate memory\n"); - goto Done; - } - memset(platforms, 0, platformCount * sizeof(cl_platform_id) ); - result = p_clIcdGetPlatformIDs(platformCount, platforms, NULL); - if (CL_SUCCESS != result) - { - KHR_ICD_TRACE("failed clIcdGetPlatformIDs\n"); - goto Done; - } - - // for each platform, add it - for (i = 0; i < platformCount; ++i) - { - KHRicdVendor* vendor = NULL; - char *suffix; - size_t suffixSize; - - // call clGetPlatformInfo on the returned platform to get the suffix - if (!platforms[i]) - { - continue; - } - result = platforms[i]->dispatch->clGetPlatformInfo( - platforms[i], - CL_PLATFORM_ICD_SUFFIX_KHR, - 0, - NULL, - &suffixSize); - if (CL_SUCCESS != result) - { - continue; - } - suffix = (char *)malloc(suffixSize); - if (!suffix) - { - continue; - } - result = platforms[i]->dispatch->clGetPlatformInfo( - platforms[i], - CL_PLATFORM_ICD_SUFFIX_KHR, - suffixSize, - suffix, - NULL); - if (CL_SUCCESS != result) - { - free(suffix); - continue; - } - - // allocate a structure for the vendor - vendor = (KHRicdVendor*)malloc(sizeof(*vendor) ); - if (!vendor) - { - free(suffix); - KHR_ICD_TRACE("failed to allocate memory\n"); - continue; - } - memset(vendor, 0, sizeof(*vendor) ); - - // populate vendor data - vendor->library = khrIcdOsLibraryLoad(libraryName); - if (!vendor->library) - { - free(suffix); - free(vendor); - KHR_ICD_TRACE("failed get platform handle to library\n"); - continue; - } - vendor->clGetExtensionFunctionAddress = p_clGetExtensionFunctionAddress; - vendor->platform = platforms[i]; - vendor->suffix = suffix; - - // add this vendor to the list of vendors at the tail - { - KHRicdVendor **prevNextPointer = NULL; - for (prevNextPointer = &khrIcdState.vendors; *prevNextPointer; prevNextPointer = &( (*prevNextPointer)->next) ); - *prevNextPointer = vendor; - } - - KHR_ICD_TRACE("successfully added vendor %s with suffix %s\n", libraryName, suffix); - - } - -Done: - - if (library) - { - khrIcdOsLibraryUnload(library); - } -} - -void khrIcdContextPropertiesGetPlatform(const cl_context_properties *properties, cl_platform_id *outPlatform) -{ - const cl_context_properties *property = (cl_context_properties *)NULL; - *outPlatform = NULL; - for (property = properties; property && property[0]; property += 2) - { - if ((cl_context_properties)CL_CONTEXT_PLATFORM == property[0]) - { - *outPlatform = (cl_platform_id)property[1]; - } - } -} - diff --git a/khronos_icd/icd.h b/khronos_icd/icd.h deleted file mode 100644 index 637ed707c..000000000 --- a/khronos_icd/icd.h +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright (c) 2012 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software source and associated documentation files (the "Materials"), - * to use, copy, modify and compile the Materials to create a binary under the - * following terms and conditions: - * - * 1. The Materials shall NOT be distributed to any third party; - * - * 2. The binary may be distributed without restriction, including without - * limitation the rights to use, copy, merge, publish, distribute, sublicense, - * and/or sell copies, and to permit persons to whom the binary is furnished to - * do so; - * - * 3. All modifications to the Materials used to create a binary that is - * distributed to third parties shall be provided to Khronos with an - * unrestricted license to use for the purposes of implementing bug fixes and - * enhancements to the Materials; - * - * 4. If the binary is used as part of an OpenCL(TM) implementation, whether - * binary is distributed together with or separately to that implementation, - * then recipient must become an OpenCL Adopter and follow the published OpenCL - * conformance process for that implementation, details at: - * http://www.khronos.org/conformance/; - * - * 5. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN - * THE MATERIALS. - * - * OpenCL is a trademark of Apple Inc. used under license by Khronos. - */ - -#ifndef _ICD_H_ -#define _ICD_H_ - -#include -#include - -/* - * type definitions - */ - -typedef CL_API_ENTRY cl_int (CL_API_CALL *pfn_clIcdGetPlatformIDs)( - cl_uint num_entries, - cl_platform_id *platforms, - cl_uint *num_platforms) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *pfn_clGetPlatformInfo)( - cl_platform_id platform, - cl_platform_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY void *(CL_API_CALL *pfn_clGetExtensionFunctionAddress)( - const char *function_name) CL_API_SUFFIX__VERSION_1_0; - -typedef struct KHRicdVendorRec KHRicdVendor; -typedef struct KHRicdStateRec KHRicdState; - -/* - * KHRicdVendor - * - * Data for a single ICD vendor platform. - */ -struct KHRicdVendorRec -{ - // the loaded library object (true type varies on Linux versus Windows) - void *library; - - // the extension suffix for this platform - char *suffix; - - // function pointer to the ICD platform IDs extracted from the library - pfn_clGetExtensionFunctionAddress clGetExtensionFunctionAddress; - - // the platform retrieved from clGetIcdPlatformIDsKHR - cl_platform_id platform; - - // next vendor in the list vendors - KHRicdVendor *next; -}; - - -/* - * KHRicdState - * - * The global state of all vendors - * - * TODO: write access to this structure needs to be protected via a mutex - */ - -struct KHRicdStateRec -{ - // has this structure been initialized - cl_bool initialized; - - // the list of vendors which have been loaded - KHRicdVendor *vendors; -}; - -// the global state -extern KHRicdState khrIcdState; - -/* - * khrIcd interface - */ - -// read vendors from system configuration and store the data -// loaded into khrIcdState. this will call the OS-specific -// function khrIcdEnumerateVendors. this is called at every -// dispatch function which may be a valid first call into the -// API (e.g, getPlatformIDs, etc). -void khrIcdInitialize(void); - -// go through the list of vendors (in /etc/OpenCL.conf or through -// the registry) and call khrIcdVendorAdd for each vendor encountered -// n.b, this call is OS-specific -void khrIcdOsVendorsEnumerate(void); - -// add a vendor's implementation to the list of libraries -void khrIcdVendorAdd(const char *libraryName); - -// dynamically load a library. returns NULL on failure -// n.b, this call is OS-specific -void *khrIcdOsLibraryLoad(const char *libraryName); - -// get a function pointer from a loaded library. returns NULL on failure. -// n.b, this call is OS-specific -void *khrIcdOsLibraryGetFunctionAddress(void *library, const char *functionName); - -// unload a library. -// n.b, this call is OS-specific -void khrIcdOsLibraryUnload(void *library); - -// parse properties and determine the platform to use from them -void khrIcdContextPropertiesGetPlatform( - const cl_context_properties *properties, - cl_platform_id *outPlatform); - -// internal tracing macros -#if 0 - #include - #define KHR_ICD_TRACE(...) \ - do \ - { \ - fprintf(stderr, "KHR ICD trace at %s:%d: ", __FILE__, __LINE__); \ - fprintf(stderr, __VA_ARGS__); \ - } while (0) - - #define KHR_ICD_ASSERT(x) \ - do \ - { \ - if (!(x)) \ - { \ - fprintf(stderr, "KHR ICD assert at %s:%d: %s failed", __FILE__, __LINE__, #x); \ - } \ - } while (0) -#else - #define KHR_ICD_TRACE(...) - #define KHR_ICD_ASSERT(x) -#endif - -// if handle is NULL then return invalid_handle_error_code -#define KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(handle,invalid_handle_error_code) \ - do \ - { \ - if (!handle) \ - { \ - return invalid_handle_error_code; \ - } \ - } while (0) - -// if handle is NULL then set errcode_ret to invalid_handle_error and return NULL -// (NULL being an invalid handle) -#define KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(handle,invalid_handle_error) \ - do \ - { \ - if (!handle) \ - { \ - if (errcode_ret) \ - { \ - *errcode_ret = invalid_handle_error; \ - } \ - return NULL; \ - } \ - } while (0) - - -#endif - diff --git a/khronos_icd/icd_dispatch.c b/khronos_icd/icd_dispatch.c deleted file mode 100644 index ce2645a87..000000000 --- a/khronos_icd/icd_dispatch.c +++ /dev/null @@ -1,2186 +0,0 @@ -/* - * Copyright (c) 2012 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software source and associated documentation files (the "Materials"), - * to use, copy, modify and compile the Materials to create a binary under the - * following terms and conditions: - * - * 1. The Materials shall NOT be distributed to any third party; - * - * 2. The binary may be distributed without restriction, including without - * limitation the rights to use, copy, merge, publish, distribute, sublicense, - * and/or sell copies, and to permit persons to whom the binary is furnished to - * do so; - * - * 3. All modifications to the Materials used to create a binary that is - * distributed to third parties shall be provided to Khronos with an - * unrestricted license to use for the purposes of implementing bug fixes and - * enhancements to the Materials; - * - * 4. If the binary is used as part of an OpenCL(TM) implementation, whether - * binary is distributed together with or separately to that implementation, - * then recipient must become an OpenCL Adopter and follow the published OpenCL - * conformance process for that implementation, details at: - * http://www.khronos.org/conformance/; - * - * 5. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN - * THE MATERIALS. - * - * OpenCL is a trademark of Apple Inc. used under license by Khronos. - */ - -#include "icd_dispatch.h" -#include "icd.h" -#include -#include - -// Platform APIs -CL_API_ENTRY cl_int CL_API_CALL -clGetPlatformIDs(cl_uint num_entries, - cl_platform_id * platforms, - cl_uint * num_platforms) CL_API_SUFFIX__VERSION_1_0 -{ - KHRicdVendor* vendor = NULL; - cl_uint i; - - // initialize the platforms (in case they have not been already) - khrIcdInitialize(); - - if (!num_entries && platforms) - { - return CL_INVALID_VALUE; - } - if (!platforms && !num_platforms) - { - return CL_INVALID_VALUE; - } - // set num_platforms to 0 and set all platform pointers to NULL - if (num_platforms) - { - *num_platforms = 0; - } - for (i = 0; i < num_entries && platforms; ++i) - { - platforms[i] = NULL; - } - // return error if we have no platforms - if (!khrIcdState.vendors) - { - return CL_PLATFORM_NOT_FOUND_KHR; - } - // otherwise enumerate all platforms - for (vendor = khrIcdState.vendors; vendor; vendor = vendor->next) - { - if (num_entries && platforms) - { - *(platforms++) = vendor->platform; - --num_entries; - } - if (num_platforms) - { - ++(*num_platforms); - } - } - return CL_SUCCESS; -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetPlatformInfo(cl_platform_id platform, - cl_platform_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - // initialize the platforms (in case they have not been already) - khrIcdInitialize(); - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); - return platform->dispatch->clGetPlatformInfo( - platform, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -// Device APIs -CL_API_ENTRY cl_int CL_API_CALL -clGetDeviceIDs(cl_platform_id platform, - cl_device_type device_type, - cl_uint num_entries, - cl_device_id * devices, - cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_0 -{ - // initialize the platforms (in case they have not been already) - khrIcdInitialize(); - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); - return platform->dispatch->clGetDeviceIDs( - platform, - device_type, - num_entries, - devices, - num_devices); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetDeviceInfo( - cl_device_id device, - cl_device_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); - return device->dispatch->clGetDeviceInfo( - device, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clCreateSubDevices(cl_device_id in_device, - const cl_device_partition_property * properties, - cl_uint num_entries, - cl_device_id * out_devices, - cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(in_device, CL_INVALID_DEVICE); - return in_device->dispatch->clCreateSubDevices( - in_device, - properties, - num_entries, - out_devices, - num_devices); -} - -CL_API_ENTRY cl_int CL_API_CALL -clRetainDevice(cl_device_id device) CL_API_SUFFIX__VERSION_1_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); - return device->dispatch->clRetainDevice(device); -} - -CL_API_ENTRY cl_int CL_API_CALL -clReleaseDevice(cl_device_id device) CL_API_SUFFIX__VERSION_1_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); - return device->dispatch->clReleaseDevice(device); -} - -// Context APIs -CL_API_ENTRY cl_context CL_API_CALL -clCreateContext(const cl_context_properties * properties, - cl_uint num_devices, - const cl_device_id * devices, - void (CL_CALLBACK *pfn_notify)(const char *, const void *, size_t, void *), - void * user_data, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - // initialize the platforms (in case they have not been already) - khrIcdInitialize(); - if (!num_devices || !devices) - { - if (errcode_ret) - { - *errcode_ret = CL_INVALID_VALUE; - } - return NULL; - } - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(devices[0], CL_INVALID_DEVICE); - return devices[0]->dispatch->clCreateContext( - properties, - num_devices, - devices, - pfn_notify, - user_data, - errcode_ret); -} - -CL_API_ENTRY cl_context CL_API_CALL -clCreateContextFromType(const cl_context_properties * properties, - cl_device_type device_type, - void (CL_CALLBACK *pfn_notify)(const char *, const void *, size_t, void *), - void * user_data, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - cl_platform_id platform = NULL; - - // initialize the platforms (in case they have not been already) - khrIcdInitialize(); - - // determine the platform to use from the properties specified - khrIcdContextPropertiesGetPlatform(properties, &platform); - - // validate the platform handle and dispatch - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(platform, CL_INVALID_PLATFORM); - return platform->dispatch->clCreateContextFromType( - properties, - device_type, - pfn_notify, - user_data, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clRetainContext(cl_context context) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, CL_INVALID_CONTEXT); - return context->dispatch->clRetainContext(context); -} - -CL_API_ENTRY cl_int CL_API_CALL -clReleaseContext(cl_context context) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, CL_INVALID_CONTEXT); - return context->dispatch->clReleaseContext(context); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetContextInfo(cl_context context, - cl_context_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, CL_INVALID_CONTEXT); - return context->dispatch->clGetContextInfo( - context, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -// Command Queue APIs -CL_API_ENTRY cl_command_queue CL_API_CALL -clCreateCommandQueue(cl_context context, - cl_device_id device, - cl_command_queue_properties properties, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateCommandQueue( - context, - device, - properties, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clRetainCommandQueue(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clRetainCommandQueue(command_queue); -} - -CL_API_ENTRY cl_int CL_API_CALL -clReleaseCommandQueue(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clReleaseCommandQueue(command_queue); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetCommandQueueInfo(cl_command_queue command_queue, - cl_command_queue_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clGetCommandQueueInfo( - command_queue, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -// Memory Object APIs -CL_API_ENTRY cl_mem CL_API_CALL -clCreateBuffer(cl_context context, - cl_mem_flags flags, - size_t size, - void * host_ptr, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateBuffer( - context, - flags, - size, - host_ptr, - errcode_ret); -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateImage(cl_context context, - cl_mem_flags flags, - const cl_image_format * image_format, - const cl_image_desc * image_desc, - void * host_ptr, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateImage( - context, - flags, - image_format, - image_desc, - host_ptr, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clRetainMemObject(cl_mem memobj) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); - return memobj->dispatch->clRetainMemObject(memobj); -} - - -CL_API_ENTRY cl_int CL_API_CALL -clReleaseMemObject(cl_mem memobj) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); - return memobj->dispatch->clReleaseMemObject(memobj); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetSupportedImageFormats(cl_context context, - cl_mem_flags flags, - cl_mem_object_type image_type, - cl_uint num_entries, - cl_image_format * image_formats, - cl_uint * num_image_formats) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, CL_INVALID_CONTEXT); - return context->dispatch->clGetSupportedImageFormats( - context, - flags, - image_type, - num_entries, - image_formats, - num_image_formats); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetMemObjectInfo(cl_mem memobj, - cl_mem_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); - return memobj->dispatch->clGetMemObjectInfo( - memobj, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetImageInfo(cl_mem image, - cl_image_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(image, CL_INVALID_MEM_OBJECT); - return image->dispatch->clGetImageInfo( - image, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -// Sampler APIs -CL_API_ENTRY cl_sampler CL_API_CALL -clCreateSampler(cl_context context, - cl_bool normalized_coords, - cl_addressing_mode addressing_mode, - cl_filter_mode filter_mode, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateSampler( - context, - normalized_coords, - addressing_mode, - filter_mode, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clRetainSampler(cl_sampler sampler) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(sampler, CL_INVALID_SAMPLER); - return sampler->dispatch->clRetainSampler(sampler); -} - -CL_API_ENTRY cl_int CL_API_CALL -clReleaseSampler(cl_sampler sampler) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(sampler, CL_INVALID_SAMPLER); - return sampler->dispatch->clReleaseSampler(sampler); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetSamplerInfo(cl_sampler sampler, - cl_sampler_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(sampler, CL_INVALID_SAMPLER); - return sampler->dispatch->clGetSamplerInfo( - sampler, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -// Program Object APIs -CL_API_ENTRY cl_program CL_API_CALL -clCreateProgramWithSource(cl_context context, - cl_uint count, - const char ** strings, - const size_t * lengths, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateProgramWithSource( - context, - count, - strings, - lengths, - errcode_ret); -} - -CL_API_ENTRY cl_program CL_API_CALL -clCreateProgramWithBinary(cl_context context, - cl_uint num_devices, - const cl_device_id * device_list, - const size_t * lengths, - const unsigned char ** binaries, - cl_int * binary_status, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateProgramWithBinary( - context, - num_devices, - device_list, - lengths, - binaries, - binary_status, - errcode_ret); -} - -CL_API_ENTRY cl_program CL_API_CALL -clCreateProgramWithBuiltInKernels(cl_context context, - cl_uint num_devices, - const cl_device_id * device_list, - const char * kernel_names, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateProgramWithBuiltInKernels( - context, - num_devices, - device_list, - kernel_names, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clRetainProgram(cl_program program) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); - return program->dispatch->clRetainProgram(program); -} - -CL_API_ENTRY cl_int CL_API_CALL -clReleaseProgram(cl_program program) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); - return program->dispatch->clReleaseProgram(program); -} - -CL_API_ENTRY cl_int CL_API_CALL -clBuildProgram(cl_program program, - cl_uint num_devices, - const cl_device_id * device_list, - const char * options, - void (CL_CALLBACK *pfn_notify)(cl_program program, void * user_data), - void * user_data) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); - return program->dispatch->clBuildProgram( - program, - num_devices, - device_list, - options, - pfn_notify, - user_data); -} - -CL_API_ENTRY cl_int CL_API_CALL -clCompileProgram(cl_program program, - cl_uint num_devices, - const cl_device_id * device_list, - const char * options, - cl_uint num_input_headers, - const cl_program * input_headers, - const char ** header_include_names, - void (CL_CALLBACK * pfn_notify)(cl_program program, void * user_data), - void * user_data) CL_API_SUFFIX__VERSION_1_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); - return program->dispatch->clCompileProgram( - program, - num_devices, - device_list, - options, - num_input_headers, - input_headers, - header_include_names, - pfn_notify, - user_data); -} - -CL_API_ENTRY cl_program CL_API_CALL -clLinkProgram(cl_context context, - cl_uint num_devices, - const cl_device_id * device_list, - const char * options, - cl_uint num_input_programs, - const cl_program * input_programs, - void (CL_CALLBACK * pfn_notify)(cl_program program, void * user_data), - void * user_data, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clLinkProgram( - context, - num_devices, - device_list, - options, - num_input_programs, - input_programs, - pfn_notify, - user_data, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clUnloadPlatformCompiler(cl_platform_id platform) CL_API_SUFFIX__VERSION_1_2 -{ - // initialize the platforms (in case they have not been already) - khrIcdInitialize(); - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); - return platform->dispatch->clUnloadPlatformCompiler(platform); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetProgramInfo(cl_program program, - cl_program_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); - return program->dispatch->clGetProgramInfo( - program, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetProgramBuildInfo(cl_program program, - cl_device_id device, - cl_program_build_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); - return program->dispatch->clGetProgramBuildInfo( - program, - device, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -// Kernel Object APIs -CL_API_ENTRY cl_kernel CL_API_CALL -clCreateKernel(cl_program program, - const char * kernel_name, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(program, CL_INVALID_PROGRAM); - return program->dispatch->clCreateKernel( - program, - kernel_name, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clCreateKernelsInProgram(cl_program program, - cl_uint num_kernels, - cl_kernel * kernels, - cl_uint * num_kernels_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); - return program->dispatch->clCreateKernelsInProgram( - program, - num_kernels, - kernels, - num_kernels_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clRetainKernel(cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); - return kernel->dispatch->clRetainKernel(kernel); -} - -CL_API_ENTRY cl_int CL_API_CALL -clReleaseKernel(cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); - return kernel->dispatch->clReleaseKernel(kernel); -} - -CL_API_ENTRY cl_int CL_API_CALL -clSetKernelArg(cl_kernel kernel, - cl_uint arg_index, - size_t arg_size, - const void * arg_value) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); - return kernel->dispatch->clSetKernelArg( - kernel, - arg_index, - arg_size, - arg_value); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetKernelInfo(cl_kernel kernel, - cl_kernel_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); - return kernel->dispatch->clGetKernelInfo( - kernel, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetKernelArgInfo(cl_kernel kernel, - cl_uint arg_indx, - cl_kernel_arg_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); - return kernel->dispatch->clGetKernelArgInfo( - kernel, - arg_indx, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetKernelWorkGroupInfo(cl_kernel kernel, - cl_device_id device, - cl_kernel_work_group_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); - return kernel->dispatch->clGetKernelWorkGroupInfo( - kernel, - device, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -// Event Object APIs -CL_API_ENTRY cl_int CL_API_CALL -clWaitForEvents(cl_uint num_events, - const cl_event * event_list) CL_API_SUFFIX__VERSION_1_0 -{ - if (!num_events || !event_list) - { - return CL_INVALID_VALUE; - } - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event_list[0], CL_INVALID_EVENT); - return event_list[0]->dispatch->clWaitForEvents( - num_events, - event_list); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetEventInfo(cl_event event, - cl_event_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); - return event->dispatch->clGetEventInfo( - event, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clRetainEvent(cl_event event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); - return event->dispatch->clRetainEvent(event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clReleaseEvent(cl_event event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); - return event->dispatch->clReleaseEvent(event); -} - -// Profiling APIs -CL_API_ENTRY cl_int CL_API_CALL -clGetEventProfilingInfo(cl_event event, - cl_profiling_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); - return event->dispatch->clGetEventProfilingInfo( - event, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -// Flush and Finish APIs -CL_API_ENTRY cl_int CL_API_CALL -clFlush(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clFlush(command_queue); -} - -CL_API_ENTRY cl_int CL_API_CALL -clFinish(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clFinish(command_queue); -} - -// Enqueued Commands APIs -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReadBuffer(cl_command_queue command_queue, - cl_mem buffer, - cl_bool blocking_read, - size_t offset, - size_t cb, - void * ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueReadBuffer( - command_queue, - buffer, - blocking_read, - offset, - cb, - ptr, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReadBufferRect( - cl_command_queue command_queue, - cl_mem buffer, - cl_bool blocking_read, - const size_t * buffer_origin, - const size_t * host_origin, - const size_t * region, - size_t buffer_row_pitch, - size_t buffer_slice_pitch, - size_t host_row_pitch, - size_t host_slice_pitch, - void * ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_1 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueReadBufferRect( - command_queue, - buffer, - blocking_read, - buffer_origin, - host_origin, - region, - buffer_row_pitch, - buffer_slice_pitch, - host_row_pitch, - host_slice_pitch, - ptr, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueWriteBuffer(cl_command_queue command_queue, - cl_mem buffer, - cl_bool blocking_write, - size_t offset, - size_t cb, - const void * ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueWriteBuffer( - command_queue, - buffer, - blocking_write, - offset, - cb, - ptr, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueWriteBufferRect( - cl_command_queue command_queue, - cl_mem buffer, - cl_bool blocking_read, - const size_t * buffer_origin, - const size_t * host_origin, - const size_t * region, - size_t buffer_row_pitch, - size_t buffer_slice_pitch, - size_t host_row_pitch, - size_t host_slice_pitch, - const void * ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_1 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueWriteBufferRect( - command_queue, - buffer, - blocking_read, - buffer_origin, - host_origin, - region, - buffer_row_pitch, - buffer_slice_pitch, - host_row_pitch, - host_slice_pitch, - ptr, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueFillBuffer(cl_command_queue command_queue, - cl_mem buffer, - const void * pattern, - size_t pattern_size, - size_t offset, - size_t cb, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueFillBuffer( - command_queue, - buffer, - pattern, - pattern_size, - offset, - cb, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueCopyBuffer(cl_command_queue command_queue, - cl_mem src_buffer, - cl_mem dst_buffer, - size_t src_offset, - size_t dst_offset, - size_t cb, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueCopyBuffer( - command_queue, - src_buffer, - dst_buffer, - src_offset, - dst_offset, - cb, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueCopyBufferRect( - cl_command_queue command_queue, - cl_mem src_buffer, - cl_mem dst_buffer, - const size_t * src_origin, - const size_t * dst_origin, - const size_t * region, - size_t src_row_pitch, - size_t src_slice_pitch, - size_t dst_row_pitch, - size_t dst_slice_pitch, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_1 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueCopyBufferRect( - command_queue, - src_buffer, - dst_buffer, - src_origin, - dst_origin, - region, - src_row_pitch, - src_slice_pitch, - dst_row_pitch, - dst_slice_pitch, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReadImage(cl_command_queue command_queue, - cl_mem image, - cl_bool blocking_read, - const size_t * origin, - const size_t * region, - size_t row_pitch, - size_t slice_pitch, - void * ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueReadImage( - command_queue, - image, - blocking_read, - origin, - region, - row_pitch, - slice_pitch, - ptr, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueWriteImage(cl_command_queue command_queue, - cl_mem image, - cl_bool blocking_write, - const size_t * origin, - const size_t * region, - size_t input_row_pitch, - size_t input_slice_pitch, - const void * ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueWriteImage( - command_queue, - image, - blocking_write, - origin, - region, - input_row_pitch, - input_slice_pitch, - ptr, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueFillImage(cl_command_queue command_queue, - cl_mem image, - const void * fill_color, - const size_t origin[3], - const size_t region[3], - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueFillImage( - command_queue, - image, - fill_color, - origin, - region, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueCopyImage(cl_command_queue command_queue, - cl_mem src_image, - cl_mem dst_image, - const size_t * src_origin, - const size_t * dst_origin, - const size_t * region, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueCopyImage( - command_queue, - src_image, - dst_image, - src_origin, - dst_origin, - region, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueCopyImageToBuffer(cl_command_queue command_queue, - cl_mem src_image, - cl_mem dst_buffer, - const size_t * src_origin, - const size_t * region, - size_t dst_offset, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueCopyImageToBuffer( - command_queue, - src_image, - dst_buffer, - src_origin, - region, - dst_offset, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueCopyBufferToImage(cl_command_queue command_queue, - cl_mem src_buffer, - cl_mem dst_image, - size_t src_offset, - const size_t * dst_origin, - const size_t * region, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueCopyBufferToImage( - command_queue, - src_buffer, - dst_image, - src_offset, - dst_origin, - region, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY void * CL_API_CALL -clEnqueueMapBuffer(cl_command_queue command_queue, - cl_mem buffer, - cl_bool blocking_map, - cl_map_flags map_flags, - size_t offset, - size_t cb, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueMapBuffer( - command_queue, - buffer, - blocking_map, - map_flags, - offset, - cb, - num_events_in_wait_list, - event_wait_list, - event, - errcode_ret); -} - -CL_API_ENTRY void * CL_API_CALL -clEnqueueMapImage(cl_command_queue command_queue, - cl_mem image, - cl_bool blocking_map, - cl_map_flags map_flags, - const size_t * origin, - const size_t * region, - size_t * image_row_pitch, - size_t * image_slice_pitch, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueMapImage( - command_queue, - image, - blocking_map, - map_flags, - origin, - region, - image_row_pitch, - image_slice_pitch, - num_events_in_wait_list, - event_wait_list, - event, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueUnmapMemObject(cl_command_queue command_queue, - cl_mem memobj, - void * mapped_ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueUnmapMemObject( - command_queue, - memobj, - mapped_ptr, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueMigrateMemObjects(cl_command_queue command_queue, - cl_uint num_mem_objects, - const cl_mem * mem_objects, - cl_mem_migration_flags flags, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueMigrateMemObjects( - command_queue, - num_mem_objects, - mem_objects, - flags, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueNDRangeKernel(cl_command_queue command_queue, - cl_kernel kernel, - cl_uint work_dim, - const size_t * global_work_offset, - const size_t * global_work_size, - const size_t * local_work_size, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueNDRangeKernel( - command_queue, - kernel, - work_dim, - global_work_offset, - global_work_size, - local_work_size, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueTask(cl_command_queue command_queue, - cl_kernel kernel, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueTask( - command_queue, - kernel, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueNativeKernel(cl_command_queue command_queue, - void (CL_CALLBACK * user_func)(void *), - void * args, - size_t cb_args, - cl_uint num_mem_objects, - const cl_mem * mem_list, - const void ** args_mem_loc, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueNativeKernel( - command_queue, - user_func, - args, - cb_args, - num_mem_objects, - mem_list, - args_mem_loc, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueMarkerWithWaitList(cl_command_queue command_queue, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueMarkerWithWaitList( - command_queue, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueBarrierWithWaitList(cl_command_queue command_queue, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueBarrierWithWaitList( - command_queue, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY void * CL_API_CALL -clGetExtensionFunctionAddressForPlatform(cl_platform_id platform, - const char * function_name) CL_API_SUFFIX__VERSION_1_2 -{ - // make sure the ICD is initialized - khrIcdInitialize(); - - // return any ICD-aware extensions - #define CL_COMMON_EXTENSION_ENTRYPOINT_ADD(name) if (!strcmp(function_name, #name) ) return (void *)&name - - // Are these core or ext? This is unclear, but they appear to be - // independent from cl_khr_gl_sharing. - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLBuffer); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLTexture); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLTexture2D); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLTexture3D); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLRenderbuffer); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetGLObjectInfo); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetGLTextureInfo); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireGLObjects); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseGLObjects); - - // cl_khr_gl_sharing - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetGLContextInfoKHR); - - // cl_khr_gl_event - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateEventFromGLsyncKHR); - -#if defined(_WIN32) - // cl_khr_d3d10_sharing - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetDeviceIDsFromD3D10KHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D10BufferKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D10Texture2DKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D10Texture3DKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireD3D10ObjectsKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseD3D10ObjectsKHR); - // cl_khr_d3d11_sharing - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetDeviceIDsFromD3D11KHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D11BufferKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D11Texture2DKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D11Texture3DKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireD3D11ObjectsKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseD3D11ObjectsKHR); - // cl_khr_dx9_media_sharing - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetDeviceIDsFromDX9MediaAdapterKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromDX9MediaSurfaceKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireDX9MediaSurfacesKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseDX9MediaSurfacesKHR); -#endif - - // cl_ext_device_fission - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateSubDevicesEXT); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clRetainDeviceEXT); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clReleaseDeviceEXT); - - // fall back to vendor extension detection - - // FIXME Now that we have a platform id here, we need to validate that it isn't NULL, so shouldn't we have an errcode_ret - // KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(platform, CL_INVALID_PLATFORM); - return platform->dispatch->clGetExtensionFunctionAddressForPlatform( - platform, - function_name); -} - -// Deprecated APIs -CL_API_ENTRY cl_int CL_API_CALL -clSetCommandQueueProperty(cl_command_queue command_queue, - cl_command_queue_properties properties, - cl_bool enable, - cl_command_queue_properties * old_properties) CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clSetCommandQueueProperty( - command_queue, - properties, - enable, - old_properties); -} - -CL_API_ENTRY cl_int CL_API_CALL -clCreateSubDevicesEXT( - cl_device_id in_device, - const cl_device_partition_property_ext * partition_properties, - cl_uint num_entries, - cl_device_id * out_devices, - cl_uint * num_devices) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(in_device, CL_INVALID_DEVICE); - return in_device->dispatch->clCreateSubDevicesEXT( - in_device, - partition_properties, - num_entries, - out_devices, - num_devices); -} - -CL_API_ENTRY cl_int CL_API_CALL -clRetainDeviceEXT(cl_device_id device) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); - return device->dispatch->clRetainDeviceEXT(device); -} - -CL_API_ENTRY cl_int CL_API_CALL -clReleaseDeviceEXT(cl_device_id device) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); - return device->dispatch->clReleaseDeviceEXT(device); -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateImage2D(cl_context context, - cl_mem_flags flags, - const cl_image_format * image_format, - size_t image_width, - size_t image_height, - size_t image_row_pitch, - void * host_ptr, - cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateImage2D( - context, - flags, - image_format, - image_width, - image_height, - image_row_pitch, - host_ptr, - errcode_ret); -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateImage3D(cl_context context, - cl_mem_flags flags, - const cl_image_format * image_format, - size_t image_width, - size_t image_height, - size_t image_depth, - size_t image_row_pitch, - size_t image_slice_pitch, - void * host_ptr, - cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateImage3D( - context, - flags, - image_format, - image_width, - image_height, - image_depth, - image_row_pitch, - image_slice_pitch, - host_ptr, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clUnloadCompiler(void) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED -{ - return CL_SUCCESS; -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueMarker(cl_command_queue command_queue, - cl_event * event) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueMarker( - command_queue, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueWaitForEvents(cl_command_queue command_queue, - cl_uint num_events, - const cl_event * event_list) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueWaitForEvents( - command_queue, - num_events, - event_list); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueBarrier(cl_command_queue command_queue) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueBarrier(command_queue); -} - -CL_API_ENTRY void * CL_API_CALL -clGetExtensionFunctionAddress(const char *function_name) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED -{ - size_t function_name_length = strlen(function_name); - KHRicdVendor* vendor = NULL; - - // make sure the ICD is initialized - khrIcdInitialize(); - - // return any ICD-aware extensions - #define CL_COMMON_EXTENSION_ENTRYPOINT_ADD(name) if (!strcmp(function_name, #name) ) return (void *)&name - - // Are these core or ext? This is unclear, but they appear to be - // independent from cl_khr_gl_sharing. - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLBuffer); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLTexture); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLTexture2D); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLTexture3D); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLRenderbuffer); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetGLObjectInfo); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetGLTextureInfo); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireGLObjects); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseGLObjects); - - // cl_khr_gl_sharing - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetGLContextInfoKHR); - - // cl_khr_gl_event - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateEventFromGLsyncKHR); - -#if defined(_WIN32) - // cl_khr_d3d10_sharing - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetDeviceIDsFromD3D10KHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D10BufferKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D10Texture2DKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D10Texture3DKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireD3D10ObjectsKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseD3D10ObjectsKHR); - // cl_khr_d3d11_sharing - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetDeviceIDsFromD3D11KHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D11BufferKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D11Texture2DKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D11Texture3DKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireD3D11ObjectsKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseD3D11ObjectsKHR); - // cl_khr_dx9_media_sharing - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetDeviceIDsFromDX9MediaAdapterKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromDX9MediaSurfaceKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireDX9MediaSurfacesKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseDX9MediaSurfacesKHR); -#endif - - // cl_ext_device_fission - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateSubDevicesEXT); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clRetainDeviceEXT); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clReleaseDeviceEXT); - - // fall back to vendor extension detection - for (vendor = khrIcdState.vendors; vendor; vendor = vendor->next) - { - size_t vendor_suffix_length = strlen(vendor->suffix); - if (vendor_suffix_length <= function_name_length && vendor_suffix_length > 0) - { - const char *function_suffix = function_name+function_name_length-vendor_suffix_length; - if (!strcmp(function_suffix, vendor->suffix) ) - { - return vendor->clGetExtensionFunctionAddress(function_name); - } - } - } - return NULL; -} - -// GL and other APIs -CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLBuffer( - cl_context context, - cl_mem_flags flags, - GLuint bufobj, - int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateFromGLBuffer( - context, - flags, - bufobj, - errcode_ret); -} - -CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLTexture( - cl_context context, - cl_mem_flags flags, - cl_GLenum target, - cl_GLint miplevel, - cl_GLuint texture, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateFromGLTexture( - context, - flags, - target, - miplevel, - texture, - errcode_ret); -} - -CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLTexture2D( - cl_context context, - cl_mem_flags flags, - GLenum target, - GLint miplevel, - GLuint texture, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateFromGLTexture2D( - context, - flags, - target, - miplevel, - texture, - errcode_ret); -} - -CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLTexture3D( - cl_context context, - cl_mem_flags flags, - GLenum target, - GLint miplevel, - GLuint texture, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateFromGLTexture3D( - context, - flags, - target, - miplevel, - texture, - errcode_ret); -} - -CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLRenderbuffer( - cl_context context, - cl_mem_flags flags, - GLuint renderbuffer, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateFromGLRenderbuffer( - context, - flags, - renderbuffer, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL clGetGLObjectInfo( - cl_mem memobj, - cl_gl_object_type * gl_object_type, - GLuint * gl_object_name) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); - return memobj->dispatch->clGetGLObjectInfo( - memobj, - gl_object_type, - gl_object_name); -} - -CL_API_ENTRY cl_int CL_API_CALL clGetGLTextureInfo( - cl_mem memobj, - cl_gl_texture_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); - return memobj->dispatch->clGetGLTextureInfo( - memobj, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL clEnqueueAcquireGLObjects( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueAcquireGLObjects( - command_queue, - num_objects, - mem_objects, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL clEnqueueReleaseGLObjects( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueReleaseGLObjects( - command_queue, - num_objects, - mem_objects, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL clGetGLContextInfoKHR( - const cl_context_properties *properties, - cl_gl_context_info param_name, - size_t param_value_size, - void *param_value, - size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - cl_platform_id platform = NULL; - - // initialize the platforms (in case they have not been already) - khrIcdInitialize(); - - // determine the platform to use from the properties specified - khrIcdContextPropertiesGetPlatform(properties, &platform); - - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); - return platform->dispatch->clGetGLContextInfoKHR( - properties, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -CL_API_ENTRY cl_event CL_API_CALL clCreateEventFromGLsyncKHR( - cl_context context, - cl_GLsync sync, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_1 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateEventFromGLsyncKHR( - context, - sync, - errcode_ret); -} - -#if defined(_WIN32) -/* - * - * cl_d3d10_sharing_khr - * - */ - -CL_API_ENTRY cl_int CL_API_CALL -clGetDeviceIDsFromD3D10KHR( - cl_platform_id platform, - cl_d3d10_device_source_khr d3d_device_source, - void *d3d_object, - cl_d3d10_device_set_khr d3d_device_set, - cl_uint num_entries, - cl_device_id *devices, - cl_uint *num_devices) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); - return platform->dispatch->clGetDeviceIDsFromD3D10KHR( - platform, - d3d_device_source, - d3d_object, - d3d_device_set, - num_entries, - devices, - num_devices); -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromD3D10BufferKHR( - cl_context context, - cl_mem_flags flags, - ID3D10Buffer *resource, - cl_int *errcode_ret) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateFromD3D10BufferKHR( - context, - flags, - resource, - errcode_ret); -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromD3D10Texture2DKHR( - cl_context context, - cl_mem_flags flags, - ID3D10Texture2D * resource, - UINT subresource, - cl_int * errcode_ret) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateFromD3D10Texture2DKHR( - context, - flags, - resource, - subresource, - errcode_ret); -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromD3D10Texture3DKHR( - cl_context context, - cl_mem_flags flags, - ID3D10Texture3D *resource, - UINT subresource, - cl_int *errcode_ret) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateFromD3D10Texture3DKHR( - context, - flags, - resource, - subresource, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueAcquireD3D10ObjectsKHR( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem *mem_objects, - cl_uint num_events_in_wait_list, - const cl_event *event_wait_list, - cl_event *event) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueAcquireD3D10ObjectsKHR( - command_queue, - num_objects, - mem_objects, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReleaseD3D10ObjectsKHR( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem *mem_objects, - cl_uint num_events_in_wait_list, - const cl_event *event_wait_list, - cl_event *event) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueReleaseD3D10ObjectsKHR( - command_queue, - num_objects, - mem_objects, - num_events_in_wait_list, - event_wait_list, - event); -} - -/* - * - * cl_d3d11_sharing_khr - * - */ - -CL_API_ENTRY cl_int CL_API_CALL -clGetDeviceIDsFromD3D11KHR( - cl_platform_id platform, - cl_d3d11_device_source_khr d3d_device_source, - void * d3d_object, - cl_d3d11_device_set_khr d3d_device_set, - cl_uint num_entries, - cl_device_id * devices, - cl_uint * num_devices) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); - return platform->dispatch->clGetDeviceIDsFromD3D11KHR( - platform, - d3d_device_source, - d3d_object, - d3d_device_set, - num_entries, - devices, - num_devices); -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromD3D11BufferKHR( - cl_context context, - cl_mem_flags flags, - ID3D11Buffer * resource, - cl_int * errcode_ret) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateFromD3D11BufferKHR( - context, - flags, - resource, - errcode_ret); -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromD3D11Texture2DKHR( - cl_context context, - cl_mem_flags flags, - ID3D11Texture2D * resource, - UINT subresource, - cl_int * errcode_ret) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateFromD3D11Texture2DKHR( - context, - flags, - resource, - subresource, - errcode_ret); -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromD3D11Texture3DKHR( - cl_context context, - cl_mem_flags flags, - ID3D11Texture3D * resource, - UINT subresource, - cl_int * errcode_ret) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateFromD3D11Texture3DKHR( - context, - flags, - resource, - subresource, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueAcquireD3D11ObjectsKHR( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueAcquireD3D11ObjectsKHR( - command_queue, - num_objects, - mem_objects, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReleaseD3D11ObjectsKHR( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueReleaseD3D11ObjectsKHR( - command_queue, - num_objects, - mem_objects, - num_events_in_wait_list, - event_wait_list, - event); -} - -/* - * - * cl_khr_dx9_media_sharing - * - */ - -CL_API_ENTRY cl_int CL_API_CALL -clGetDeviceIDsFromDX9MediaAdapterKHR( - cl_platform_id platform, - cl_uint num_media_adapters, - cl_dx9_media_adapter_type_khr * media_adapters_type, - void * media_adapters[], - cl_dx9_media_adapter_set_khr media_adapter_set, - cl_uint num_entries, - cl_device_id * devices, - cl_uint * num_devices) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); - return platform->dispatch->clGetDeviceIDsFromDX9MediaAdapterKHR( - platform, - num_media_adapters, - media_adapters_type, - media_adapters, - media_adapter_set, - num_entries, - devices, - num_devices); -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromDX9MediaSurfaceKHR( - cl_context context, - cl_mem_flags flags, - cl_dx9_media_adapter_type_khr adapter_type, - void * surface_info, - cl_uint plane, - cl_int * errcode_ret) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateFromDX9MediaSurfaceKHR( - context, - flags, - adapter_type, - surface_info, - plane, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueAcquireDX9MediaSurfacesKHR( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueAcquireDX9MediaSurfacesKHR( - command_queue, - num_objects, - mem_objects, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReleaseDX9MediaSurfacesKHR( - cl_command_queue command_queue, - cl_uint num_objects, - cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueReleaseDX9MediaSurfacesKHR( - command_queue, - num_objects, - mem_objects, - num_events_in_wait_list, - event_wait_list, - event); -} - -#endif - -CL_API_ENTRY cl_int CL_API_CALL -clSetEventCallback( - cl_event event, - cl_int command_exec_callback_type, - void (CL_CALLBACK *pfn_notify)(cl_event, cl_int, void *), - void *user_data) CL_API_SUFFIX__VERSION_1_1 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); - return event->dispatch->clSetEventCallback( - event, - command_exec_callback_type, - pfn_notify, - user_data); -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateSubBuffer( - cl_mem buffer, - cl_mem_flags flags, - cl_buffer_create_type buffer_create_type, - const void * buffer_create_info, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_1 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(buffer, CL_INVALID_MEM_OBJECT); - return buffer->dispatch->clCreateSubBuffer( - buffer, - flags, - buffer_create_type, - buffer_create_info, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clSetMemObjectDestructorCallback( - cl_mem memobj, - void (CL_CALLBACK * pfn_notify)( cl_mem, void*), - void * user_data ) CL_API_SUFFIX__VERSION_1_1 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); - return memobj->dispatch->clSetMemObjectDestructorCallback( - memobj, - pfn_notify, - user_data); -} - -CL_API_ENTRY cl_event CL_API_CALL -clCreateUserEvent( - cl_context context, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_1 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateUserEvent( - context, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clSetUserEventStatus( - cl_event event, - cl_int execution_status) CL_API_SUFFIX__VERSION_1_1 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); - return event->dispatch->clSetUserEventStatus( - event, - execution_status); -} - diff --git a/khronos_icd/icd_dispatch.h b/khronos_icd/icd_dispatch.h deleted file mode 100644 index 0d14fd08c..000000000 --- a/khronos_icd/icd_dispatch.h +++ /dev/null @@ -1,1283 +0,0 @@ -/* - * Copyright (c) 2012 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software source and associated documentation files (the "Materials"), - * to use, copy, modify and compile the Materials to create a binary under the - * following terms and conditions: - * - * 1. The Materials shall NOT be distributed to any third party; - * - * 2. The binary may be distributed without restriction, including without - * limitation the rights to use, copy, merge, publish, distribute, sublicense, - * and/or sell copies, and to permit persons to whom the binary is furnished to - * do so; - * - * 3. All modifications to the Materials used to create a binary that is - * distributed to third parties shall be provided to Khronos with an - * unrestricted license to use for the purposes of implementing bug fixes and - * enhancements to the Materials; - * - * 4. If the binary is used as part of an OpenCL(TM) implementation, whether - * binary is distributed together with or separately to that implementation, - * then recipient must become an OpenCL Adopter and follow the published OpenCL - * conformance process for that implementation, details at: - * http://www.khronos.org/conformance/; - * - * 5. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN - * THE MATERIALS. - * - * OpenCL is a trademark of Apple Inc. used under license by Khronos. - */ - -#ifndef _ICD_DISPATCH_H_ -#define _ICD_DISPATCH_H_ - -#ifndef CL_USE_DEPRECATED_OPENCL_1_0_APIS -#define CL_USE_DEPRECATED_OPENCL_1_0_APIS -#endif - -#ifndef CL_USE_DEPRECATED_OPENCL_1_1_APIS -#define CL_USE_DEPRECATED_OPENCL_1_1_APIS -#endif - -// cl.h -#include - -// cl_gl.h and required files -#ifdef _WIN32 -#include -#include -#include -#include -#include -#include -#endif -#include -#include -#include -#include - -/* - * - * function pointer typedefs - * - */ - -// Platform APIs -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetPlatformIDs)( - cl_uint num_entries, - cl_platform_id * platforms, - cl_uint * num_platforms) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetPlatformInfo)( - cl_platform_id platform, - cl_platform_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -// Device APIs -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetDeviceIDs)( - cl_platform_id platform, - cl_device_type device_type, - cl_uint num_entries, - cl_device_id * devices, - cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetDeviceInfo)( - cl_device_id device, - cl_device_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clCreateSubDevices)( - cl_device_id in_device, - const cl_device_partition_property * partition_properties, - cl_uint num_entries, - cl_device_id * out_devices, - cl_uint * num_devices); - -typedef CL_API_ENTRY cl_int (CL_API_CALL * KHRpfn_clRetainDevice)( - cl_device_id device) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL * KHRpfn_clReleaseDevice)( - cl_device_id device) CL_API_SUFFIX__VERSION_1_2; - -// Context APIs -typedef CL_API_ENTRY cl_context (CL_API_CALL *KHRpfn_clCreateContext)( - const cl_context_properties * properties, - cl_uint num_devices, - const cl_device_id * devices, - void (CL_CALLBACK *pfn_notify)(const char *, const void *, size_t, void *), - void * user_data, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_context (CL_API_CALL *KHRpfn_clCreateContextFromType)( - const cl_context_properties * properties, - cl_device_type device_type, - void (CL_CALLBACK *pfn_notify)(const char *, const void *, size_t, void *), - void * user_data, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clRetainContext)( - cl_context context) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clReleaseContext)( - cl_context context) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetContextInfo)( - cl_context context, - cl_context_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -// Command Queue APIs -typedef CL_API_ENTRY cl_command_queue (CL_API_CALL *KHRpfn_clCreateCommandQueue)( - cl_context context, - cl_device_id device, - cl_command_queue_properties properties, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clRetainCommandQueue)( - cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clReleaseCommandQueue)( - cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetCommandQueueInfo)( - cl_command_queue command_queue, - cl_command_queue_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -// Memory Object APIs -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateBuffer)( - cl_context context, - cl_mem_flags flags, - size_t size, - void * host_ptr, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateImage)( - cl_context context, - cl_mem_flags flags, - const cl_image_format * image_format, - const cl_image_desc * image_desc, - void * host_ptr, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clRetainMemObject)(cl_mem memobj) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clReleaseMemObject)(cl_mem memobj) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetSupportedImageFormats)( - cl_context context, - cl_mem_flags flags, - cl_mem_object_type image_type, - cl_uint num_entries, - cl_image_format * image_formats, - cl_uint * num_image_formats) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetMemObjectInfo)( - cl_mem memobj, - cl_mem_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetImageInfo)( - cl_mem image, - cl_image_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -// Sampler APIs -typedef CL_API_ENTRY cl_sampler (CL_API_CALL *KHRpfn_clCreateSampler)( - cl_context context, - cl_bool normalized_coords, - cl_addressing_mode addressing_mode, - cl_filter_mode filter_mode, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clRetainSampler)(cl_sampler sampler) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clReleaseSampler)(cl_sampler sampler) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetSamplerInfo)( - cl_sampler sampler, - cl_sampler_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -// Program Object APIs -typedef CL_API_ENTRY cl_program (CL_API_CALL *KHRpfn_clCreateProgramWithSource)( - cl_context context, - cl_uint count, - const char ** strings, - const size_t * lengths, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_program (CL_API_CALL *KHRpfn_clCreateProgramWithBinary)( - cl_context context, - cl_uint num_devices, - const cl_device_id * device_list, - const size_t * lengths, - const unsigned char ** binaries, - cl_int * binary_status, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_program (CL_API_CALL *KHRpfn_clCreateProgramWithBuiltInKernels)( - cl_context context, - cl_uint num_devices, - const cl_device_id * device_list, - const char * kernel_names, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clRetainProgram)(cl_program program) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clReleaseProgram)(cl_program program) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clBuildProgram)( - cl_program program, - cl_uint num_devices, - const cl_device_id * device_list, - const char * options, - void (CL_CALLBACK *pfn_notify)(cl_program program, void * user_data), - void * user_data) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clCompileProgram)( - cl_program program, - cl_uint num_devices, - const cl_device_id * device_list, - const char * options, - cl_uint num_input_headers, - const cl_program * input_headers, - const char ** header_include_names, - void (CL_CALLBACK * pfn_notify)(cl_program program, void * user_data), - void * user_data) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_program (CL_API_CALL *KHRpfn_clLinkProgram)( - cl_context context, - cl_uint num_devices, - const cl_device_id * device_list, - const char * options, - cl_uint num_input_programs, - const cl_program * input_programs, - void (CL_CALLBACK * pfn_notify)(cl_program program, void * user_data), - void * user_data, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clUnloadPlatformCompiler)( - cl_platform_id platform) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetProgramInfo)( - cl_program program, - cl_program_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetProgramBuildInfo)( - cl_program program, - cl_device_id device, - cl_program_build_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -// Kernel Object APIs -typedef CL_API_ENTRY cl_kernel (CL_API_CALL *KHRpfn_clCreateKernel)( - cl_program program, - const char * kernel_name, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clCreateKernelsInProgram)( - cl_program program, - cl_uint num_kernels, - cl_kernel * kernels, - cl_uint * num_kernels_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clRetainKernel)(cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clReleaseKernel)(cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clSetKernelArg)( - cl_kernel kernel, - cl_uint arg_index, - size_t arg_size, - const void * arg_value) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetKernelInfo)( - cl_kernel kernel, - cl_kernel_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetKernelArgInfo)( - cl_kernel kernel, - cl_uint arg_indx, - cl_kernel_arg_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetKernelWorkGroupInfo)( - cl_kernel kernel, - cl_device_id device, - cl_kernel_work_group_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -// Event Object APIs -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clWaitForEvents)( - cl_uint num_events, - const cl_event * event_list) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetEventInfo)( - cl_event event, - cl_event_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clRetainEvent)(cl_event event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clReleaseEvent)(cl_event event) CL_API_SUFFIX__VERSION_1_0; - -// Profiling APIs -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetEventProfilingInfo)( - cl_event event, - cl_profiling_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -// Flush and Finish APIs -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clFlush)(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clFinish)(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0; - -// Enqueued Commands APIs -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueReadBuffer)( - cl_command_queue command_queue, - cl_mem buffer, - cl_bool blocking_read, - size_t offset, - size_t cb, - void * ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueReadBufferRect)( - cl_command_queue command_queue, - cl_mem buffer, - cl_bool blocking_read, - const size_t * buffer_origin, - const size_t * host_origin, - const size_t * region, - size_t buffer_row_pitch, - size_t buffer_slice_pitch, - size_t host_row_pitch, - size_t host_slice_pitch, - void * ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_1; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueWriteBuffer)( - cl_command_queue command_queue, - cl_mem buffer, - cl_bool blocking_write, - size_t offset, - size_t cb, - const void * ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueWriteBufferRect)( - cl_command_queue command_queue, - cl_mem buffer, - cl_bool blocking_read, - const size_t * buffer_origin, - const size_t * host_origin, - const size_t * region, - size_t buffer_row_pitch, - size_t buffer_slice_pitch, - size_t host_row_pitch, - size_t host_slice_pitch, - const void * ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_1; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueFillBuffer)( - cl_command_queue command_queue, - cl_mem buffer, - const void * pattern, - size_t pattern_size, - size_t offset, - size_t cb, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueCopyBuffer)( - cl_command_queue command_queue, - cl_mem src_buffer, - cl_mem dst_buffer, - size_t src_offset, - size_t dst_offset, - size_t cb, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueCopyBufferRect)( - cl_command_queue command_queue, - cl_mem src_buffer, - cl_mem dst_buffer, - const size_t * src_origin, - const size_t * dst_origin, - const size_t * region, - size_t src_row_pitch, - size_t src_slice_pitch, - size_t dst_row_pitch, - size_t dst_slice_pitch, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_1; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueReadImage)( - cl_command_queue command_queue, - cl_mem image, - cl_bool blocking_read, - const size_t * origin, - const size_t * region, - size_t row_pitch, - size_t slice_pitch, - void * ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueWriteImage)( - cl_command_queue command_queue, - cl_mem image, - cl_bool blocking_write, - const size_t * origin, - const size_t * region, - size_t input_row_pitch, - size_t input_slice_pitch, - const void * ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueFillImage)( - cl_command_queue command_queue, - cl_mem image, - const void * fill_color, - const size_t origin[3], - const size_t region[3], - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueCopyImage)( - cl_command_queue command_queue, - cl_mem src_image, - cl_mem dst_image, - const size_t * src_origin, - const size_t * dst_origin, - const size_t * region, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueCopyImageToBuffer)( - cl_command_queue command_queue, - cl_mem src_image, - cl_mem dst_buffer, - const size_t * src_origin, - const size_t * region, - size_t dst_offset, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueCopyBufferToImage)( - cl_command_queue command_queue, - cl_mem src_buffer, - cl_mem dst_image, - size_t src_offset, - const size_t * dst_origin, - const size_t * region, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY void * (CL_API_CALL *KHRpfn_clEnqueueMapBuffer)( - cl_command_queue command_queue, - cl_mem buffer, - cl_bool blocking_map, - cl_map_flags map_flags, - size_t offset, - size_t cb, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY void * (CL_API_CALL *KHRpfn_clEnqueueMapImage)( - cl_command_queue command_queue, - cl_mem image, - cl_bool blocking_map, - cl_map_flags map_flags, - const size_t * origin, - const size_t * region, - size_t * image_row_pitch, - size_t * image_slice_pitch, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueUnmapMemObject)( - cl_command_queue command_queue, - cl_mem memobj, - void * mapped_ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueMigrateMemObjects)( - cl_command_queue command_queue, - cl_uint num_mem_objects, - const cl_mem * mem_objects, - cl_mem_migration_flags flags, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueNDRangeKernel)( - cl_command_queue command_queue, - cl_kernel kernel, - cl_uint work_dim, - const size_t * global_work_offset, - const size_t * global_work_size, - const size_t * local_work_size, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueTask)( - cl_command_queue command_queue, - cl_kernel kernel, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueNativeKernel)( - cl_command_queue command_queue, - void (CL_CALLBACK * user_func)(void *), - void * args, - size_t cb_args, - cl_uint num_mem_objects, - const cl_mem * mem_list, - const void ** args_mem_loc, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueMarkerWithWaitList)( - cl_command_queue command_queue, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueBarrierWithWaitList)( - cl_command_queue command_queue, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY void * (CL_API_CALL *KHRpfn_clGetExtensionFunctionAddressForPlatform)( - cl_platform_id platform, - const char * function_name) CL_API_SUFFIX__VERSION_1_2; - -// Deprecated APIs -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clSetCommandQueueProperty)( - cl_command_queue command_queue, - cl_command_queue_properties properties, - cl_bool enable, - cl_command_queue_properties * old_properties) CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateImage2D)( - cl_context context, - cl_mem_flags flags, - const cl_image_format * image_format, - size_t image_width, - size_t image_height, - size_t image_row_pitch, - void * host_ptr, - cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateImage3D)( - cl_context context, - cl_mem_flags flags, - const cl_image_format * image_format, - size_t image_width, - size_t image_height, - size_t image_depth, - size_t image_row_pitch, - size_t image_slice_pitch, - void * host_ptr, - cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clUnloadCompiler)(void) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueMarker)( - cl_command_queue command_queue, - cl_event * event) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueWaitForEvents)( - cl_command_queue command_queue, - cl_uint num_events, - const cl_event * event_list) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueBarrier)(cl_command_queue command_queue) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; - -typedef CL_API_ENTRY void * (CL_API_CALL *KHRpfn_clGetExtensionFunctionAddress)(const char *function_name) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; - -// GL and other APIs -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromGLBuffer)( - cl_context context, - cl_mem_flags flags, - GLuint bufobj, - int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromGLTexture)( - cl_context context, - cl_mem_flags flags, - cl_GLenum target, - cl_GLint miplevel, - cl_GLuint texture, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromGLTexture2D)( - cl_context context, - cl_mem_flags flags, - GLenum target, - GLint miplevel, - GLuint texture, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromGLTexture3D)( - cl_context context, - cl_mem_flags flags, - GLenum target, - GLint miplevel, - GLuint texture, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromGLRenderbuffer)( - cl_context context, - cl_mem_flags flags, - GLuint renderbuffer, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetGLObjectInfo)( - cl_mem memobj, - cl_gl_object_type * gl_object_type, - GLuint * gl_object_name) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetGLTextureInfo)( - cl_mem memobj, - cl_gl_texture_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueAcquireGLObjects)( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueReleaseGLObjects)( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -/* cl_khr_gl_sharing */ -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetGLContextInfoKHR)( - const cl_context_properties *properties, - cl_gl_context_info param_name, - size_t param_value_size, - void *param_value, - size_t *param_value_size_ret); - -/* cl_khr_gl_event */ -typedef CL_API_ENTRY cl_event (CL_API_CALL *KHRpfn_clCreateEventFromGLsyncKHR)( - cl_context context, - cl_GLsync sync, - cl_int *errcode_ret); - - -#if defined(_WIN32) - -/* cl_khr_d3d10_sharing */ - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetDeviceIDsFromD3D10KHR)( - cl_platform_id platform, - cl_d3d10_device_source_khr d3d_device_source, - void * d3d_object, - cl_d3d10_device_set_khr d3d_device_set, - cl_uint num_entries, - cl_device_id * devices, - cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromD3D10BufferKHR)( - cl_context context, - cl_mem_flags flags, - ID3D10Buffer * resource, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromD3D10Texture2DKHR)( - cl_context context, - cl_mem_flags flags, - ID3D10Texture2D * resource, - UINT subresource, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromD3D10Texture3DKHR)( - cl_context context, - cl_mem_flags flags, - ID3D10Texture3D * resource, - UINT subresource, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueAcquireD3D10ObjectsKHR)( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueReleaseD3D10ObjectsKHR)( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetDeviceIDsFromD3D10KHR( - cl_platform_id platform, - cl_d3d10_device_source_khr d3d_device_source, - void *d3d_object, - cl_d3d10_device_set_khr d3d_device_set, - cl_uint num_entries, - cl_device_id *devices, - cl_uint *num_devices); - -extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromD3D10BufferKHR( - cl_context context, - cl_mem_flags flags, - ID3D10Buffer *resource, - cl_int *errcode_ret); - -extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromD3D10Texture2DKHR( - cl_context context, - cl_mem_flags flags, - ID3D10Texture2D * resource, - UINT subresource, - cl_int * errcode_ret); - -extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromD3D10Texture3DKHR( - cl_context context, - cl_mem_flags flags, - ID3D10Texture3D *resource, - UINT subresource, - cl_int *errcode_ret); - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueAcquireD3D10ObjectsKHR( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem *mem_objects, - cl_uint num_events_in_wait_list, - const cl_event *event_wait_list, - cl_event *event); - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReleaseD3D10ObjectsKHR( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem *mem_objects, - cl_uint num_events_in_wait_list, - const cl_event *event_wait_list, - cl_event *event); - -/* cl_khr_d3d11_sharing */ -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetDeviceIDsFromD3D11KHR)( - cl_platform_id platform, - cl_d3d11_device_source_khr d3d_device_source, - void * d3d_object, - cl_d3d11_device_set_khr d3d_device_set, - cl_uint num_entries, - cl_device_id * devices, - cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromD3D11BufferKHR)( - cl_context context, - cl_mem_flags flags, - ID3D11Buffer * resource, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromD3D11Texture2DKHR)( - cl_context context, - cl_mem_flags flags, - ID3D11Texture2D * resource, - UINT subresource, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromD3D11Texture3DKHR)( - cl_context context, - cl_mem_flags flags, - ID3D11Texture3D * resource, - UINT subresource, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueAcquireD3D11ObjectsKHR)( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueReleaseD3D11ObjectsKHR)( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2; - -/* cl_khr_dx9_media_sharing */ -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetDeviceIDsFromDX9MediaAdapterKHR)( - cl_platform_id platform, - cl_uint num_media_adapters, - cl_dx9_media_adapter_type_khr * media_adapters_type, - void * media_adapters, - cl_dx9_media_adapter_set_khr media_adapter_set, - cl_uint num_entries, - cl_device_id * devices, - cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromDX9MediaSurfaceKHR)( - cl_context context, - cl_mem_flags flags, - cl_dx9_media_adapter_type_khr adapter_type, - void * surface_info, - cl_uint plane, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueAcquireDX9MediaSurfacesKHR)( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueReleaseDX9MediaSurfacesKHR)( - cl_command_queue command_queue, - cl_uint num_objects, - cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2; - -/* cl_khr_d3d11_sharing */ -extern CL_API_ENTRY cl_int CL_API_CALL -clGetDeviceIDsFromD3D11KHR( - cl_platform_id platform, - cl_d3d11_device_source_khr d3d_device_source, - void * d3d_object, - cl_d3d11_device_set_khr d3d_device_set, - cl_uint num_entries, - cl_device_id * devices, - cl_uint * num_devices); - -extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromD3D11BufferKHR( - cl_context context, - cl_mem_flags flags, - ID3D11Buffer * resource, - cl_int * errcode_ret); - -extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromD3D11Texture2DKHR( - cl_context context, - cl_mem_flags flags, - ID3D11Texture2D * resource, - UINT subresource, - cl_int * errcode_ret); - -extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromD3D11Texture3DKHR( - cl_context context, - cl_mem_flags flags, - ID3D11Texture3D * resource, - UINT subresource, - cl_int * errcode_ret); - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueAcquireD3D11ObjectsKHR( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event); - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReleaseD3D11ObjectsKHR( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event); - -/* cl_khr_dx9_media_sharing */ -extern CL_API_ENTRY cl_int CL_API_CALL -clGetDeviceIDsFromDX9MediaAdapterKHR( - cl_platform_id platform, - cl_uint num_media_adapters, - cl_dx9_media_adapter_type_khr * media_adapter_type, - void * media_adapters, - cl_dx9_media_adapter_set_khr media_adapter_set, - cl_uint num_entries, - cl_device_id * devices, - cl_uint * num_devices); - -extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromDX9MediaSurfaceKHR( - cl_context context, - cl_mem_flags flags, - cl_dx9_media_adapter_type_khr adapter_type, - void * surface_info, - cl_uint plane, - cl_int * errcode_ret); - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueAcquireDX9MediaSurfacesKHR( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event); - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReleaseDX9MediaSurfacesKHR( - cl_command_queue command_queue, - cl_uint num_objects, - cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event); - -#else - -/* cl_khr_d3d10_sharing */ -typedef void *KHRpfn_clGetDeviceIDsFromD3D10KHR; -typedef void *KHRpfn_clCreateFromD3D10BufferKHR; -typedef void *KHRpfn_clCreateFromD3D10Texture2DKHR; -typedef void *KHRpfn_clCreateFromD3D10Texture3DKHR; -typedef void *KHRpfn_clEnqueueAcquireD3D10ObjectsKHR; -typedef void *KHRpfn_clEnqueueReleaseD3D10ObjectsKHR; - -/* cl_khr_d3d11_sharing */ -typedef void *KHRpfn_clGetDeviceIDsFromD3D11KHR; -typedef void *KHRpfn_clCreateFromD3D11BufferKHR; -typedef void *KHRpfn_clCreateFromD3D11Texture2DKHR; -typedef void *KHRpfn_clCreateFromD3D11Texture3DKHR; -typedef void *KHRpfn_clEnqueueAcquireD3D11ObjectsKHR; -typedef void *KHRpfn_clEnqueueReleaseD3D11ObjectsKHR; - -/* cl_khr_dx9_media_sharing */ -typedef void *KHRpfn_clCreateFromDX9MediaSurfaceKHR; -typedef void *KHRpfn_clEnqueueAcquireDX9MediaSurfacesKHR; -typedef void *KHRpfn_clEnqueueReleaseDX9MediaSurfacesKHR; -typedef void *KHRpfn_clGetDeviceIDsFromDX9MediaAdapterKHR; - -#endif - -/* OpenCL 1.1 */ - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clSetEventCallback)( - cl_event /* event */, - cl_int /* command_exec_callback_type */, - void (CL_CALLBACK * /* pfn_notify */)(cl_event, cl_int, void *), - void * /* user_data */) CL_API_SUFFIX__VERSION_1_1; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateSubBuffer)( - cl_mem /* buffer */, - cl_mem_flags /* flags */, - cl_buffer_create_type /* buffer_create_type */, - const void * /* buffer_create_info */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_1; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clSetMemObjectDestructorCallback)( - cl_mem /* memobj */, - void (CL_CALLBACK * /*pfn_notify*/)( cl_mem /* memobj */, void* /*user_data*/), - void * /*user_data */ ) CL_API_SUFFIX__VERSION_1_1; - -typedef CL_API_ENTRY cl_event (CL_API_CALL *KHRpfn_clCreateUserEvent)( - cl_context /* context */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_1; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clSetUserEventStatus)( - cl_event /* event */, - cl_int /* execution_status */) CL_API_SUFFIX__VERSION_1_1; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clCreateSubDevicesEXT)( - cl_device_id in_device, - const cl_device_partition_property_ext * partition_properties, - cl_uint num_entries, - cl_device_id * out_devices, - cl_uint * num_devices); - -typedef CL_API_ENTRY cl_int (CL_API_CALL * KHRpfn_clRetainDeviceEXT)( - cl_device_id device) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL * KHRpfn_clReleaseDeviceEXT)( - cl_device_id device) CL_API_SUFFIX__VERSION_1_0; - -/* - * - * vendor dispatch table structure - * - * note that the types in the structure KHRicdVendorDispatch mirror the function - * names listed in the string table khrIcdVendorDispatchFunctionNames - * - */ - -typedef struct KHRicdVendorDispatchRec KHRicdVendorDispatch; - -struct KHRicdVendorDispatchRec -{ - KHRpfn_clGetPlatformIDs clGetPlatformIDs; - KHRpfn_clGetPlatformInfo clGetPlatformInfo; - KHRpfn_clGetDeviceIDs clGetDeviceIDs; - KHRpfn_clGetDeviceInfo clGetDeviceInfo; - KHRpfn_clCreateContext clCreateContext; - KHRpfn_clCreateContextFromType clCreateContextFromType; - KHRpfn_clRetainContext clRetainContext; - KHRpfn_clReleaseContext clReleaseContext; - KHRpfn_clGetContextInfo clGetContextInfo; - KHRpfn_clCreateCommandQueue clCreateCommandQueue; - KHRpfn_clRetainCommandQueue clRetainCommandQueue; - KHRpfn_clReleaseCommandQueue clReleaseCommandQueue; - KHRpfn_clGetCommandQueueInfo clGetCommandQueueInfo; - KHRpfn_clSetCommandQueueProperty clSetCommandQueueProperty; - KHRpfn_clCreateBuffer clCreateBuffer; - KHRpfn_clCreateImage2D clCreateImage2D; - KHRpfn_clCreateImage3D clCreateImage3D; - KHRpfn_clRetainMemObject clRetainMemObject; - KHRpfn_clReleaseMemObject clReleaseMemObject; - KHRpfn_clGetSupportedImageFormats clGetSupportedImageFormats; - KHRpfn_clGetMemObjectInfo clGetMemObjectInfo; - KHRpfn_clGetImageInfo clGetImageInfo; - KHRpfn_clCreateSampler clCreateSampler; - KHRpfn_clRetainSampler clRetainSampler; - KHRpfn_clReleaseSampler clReleaseSampler; - KHRpfn_clGetSamplerInfo clGetSamplerInfo; - KHRpfn_clCreateProgramWithSource clCreateProgramWithSource; - KHRpfn_clCreateProgramWithBinary clCreateProgramWithBinary; - KHRpfn_clRetainProgram clRetainProgram; - KHRpfn_clReleaseProgram clReleaseProgram; - KHRpfn_clBuildProgram clBuildProgram; - KHRpfn_clUnloadCompiler clUnloadCompiler; - KHRpfn_clGetProgramInfo clGetProgramInfo; - KHRpfn_clGetProgramBuildInfo clGetProgramBuildInfo; - KHRpfn_clCreateKernel clCreateKernel; - KHRpfn_clCreateKernelsInProgram clCreateKernelsInProgram; - KHRpfn_clRetainKernel clRetainKernel; - KHRpfn_clReleaseKernel clReleaseKernel; - KHRpfn_clSetKernelArg clSetKernelArg; - KHRpfn_clGetKernelInfo clGetKernelInfo; - KHRpfn_clGetKernelWorkGroupInfo clGetKernelWorkGroupInfo; - KHRpfn_clWaitForEvents clWaitForEvents; - KHRpfn_clGetEventInfo clGetEventInfo; - KHRpfn_clRetainEvent clRetainEvent; - KHRpfn_clReleaseEvent clReleaseEvent; - KHRpfn_clGetEventProfilingInfo clGetEventProfilingInfo; - KHRpfn_clFlush clFlush; - KHRpfn_clFinish clFinish; - KHRpfn_clEnqueueReadBuffer clEnqueueReadBuffer; - KHRpfn_clEnqueueWriteBuffer clEnqueueWriteBuffer; - KHRpfn_clEnqueueCopyBuffer clEnqueueCopyBuffer; - KHRpfn_clEnqueueReadImage clEnqueueReadImage; - KHRpfn_clEnqueueWriteImage clEnqueueWriteImage; - KHRpfn_clEnqueueCopyImage clEnqueueCopyImage; - KHRpfn_clEnqueueCopyImageToBuffer clEnqueueCopyImageToBuffer; - KHRpfn_clEnqueueCopyBufferToImage clEnqueueCopyBufferToImage; - KHRpfn_clEnqueueMapBuffer clEnqueueMapBuffer; - KHRpfn_clEnqueueMapImage clEnqueueMapImage; - KHRpfn_clEnqueueUnmapMemObject clEnqueueUnmapMemObject; - KHRpfn_clEnqueueNDRangeKernel clEnqueueNDRangeKernel; - KHRpfn_clEnqueueTask clEnqueueTask; - KHRpfn_clEnqueueNativeKernel clEnqueueNativeKernel; - KHRpfn_clEnqueueMarker clEnqueueMarker; - KHRpfn_clEnqueueWaitForEvents clEnqueueWaitForEvents; - KHRpfn_clEnqueueBarrier clEnqueueBarrier; - KHRpfn_clGetExtensionFunctionAddress clGetExtensionFunctionAddress; - KHRpfn_clCreateFromGLBuffer clCreateFromGLBuffer; - KHRpfn_clCreateFromGLTexture2D clCreateFromGLTexture2D; - KHRpfn_clCreateFromGLTexture3D clCreateFromGLTexture3D; - KHRpfn_clCreateFromGLRenderbuffer clCreateFromGLRenderbuffer; - KHRpfn_clGetGLObjectInfo clGetGLObjectInfo; - KHRpfn_clGetGLTextureInfo clGetGLTextureInfo; - KHRpfn_clEnqueueAcquireGLObjects clEnqueueAcquireGLObjects; - KHRpfn_clEnqueueReleaseGLObjects clEnqueueReleaseGLObjects; - KHRpfn_clGetGLContextInfoKHR clGetGLContextInfoKHR; - - KHRpfn_clGetDeviceIDsFromD3D10KHR clGetDeviceIDsFromD3D10KHR; - KHRpfn_clCreateFromD3D10BufferKHR clCreateFromD3D10BufferKHR; - KHRpfn_clCreateFromD3D10Texture2DKHR clCreateFromD3D10Texture2DKHR; - KHRpfn_clCreateFromD3D10Texture3DKHR clCreateFromD3D10Texture3DKHR; - KHRpfn_clEnqueueAcquireD3D10ObjectsKHR clEnqueueAcquireD3D10ObjectsKHR; - KHRpfn_clEnqueueReleaseD3D10ObjectsKHR clEnqueueReleaseD3D10ObjectsKHR; - - KHRpfn_clSetEventCallback clSetEventCallback; - KHRpfn_clCreateSubBuffer clCreateSubBuffer; - KHRpfn_clSetMemObjectDestructorCallback clSetMemObjectDestructorCallback; - KHRpfn_clCreateUserEvent clCreateUserEvent; - KHRpfn_clSetUserEventStatus clSetUserEventStatus; - KHRpfn_clEnqueueReadBufferRect clEnqueueReadBufferRect; - KHRpfn_clEnqueueWriteBufferRect clEnqueueWriteBufferRect; - KHRpfn_clEnqueueCopyBufferRect clEnqueueCopyBufferRect; - - KHRpfn_clCreateSubDevicesEXT clCreateSubDevicesEXT; - KHRpfn_clRetainDeviceEXT clRetainDeviceEXT; - KHRpfn_clReleaseDeviceEXT clReleaseDeviceEXT; - - KHRpfn_clCreateEventFromGLsyncKHR clCreateEventFromGLsyncKHR; - - KHRpfn_clCreateSubDevices clCreateSubDevices; - KHRpfn_clRetainDevice clRetainDevice; - KHRpfn_clReleaseDevice clReleaseDevice; - KHRpfn_clCreateImage clCreateImage; - KHRpfn_clCreateProgramWithBuiltInKernels clCreateProgramWithBuiltInKernels; - KHRpfn_clCompileProgram clCompileProgram; - KHRpfn_clLinkProgram clLinkProgram; - KHRpfn_clUnloadPlatformCompiler clUnloadPlatformCompiler; - KHRpfn_clGetKernelArgInfo clGetKernelArgInfo; - KHRpfn_clEnqueueFillBuffer clEnqueueFillBuffer; - KHRpfn_clEnqueueFillImage clEnqueueFillImage; - KHRpfn_clEnqueueMigrateMemObjects clEnqueueMigrateMemObjects; - KHRpfn_clEnqueueMarkerWithWaitList clEnqueueMarkerWithWaitList; - KHRpfn_clEnqueueBarrierWithWaitList clEnqueueBarrierWithWaitList; - KHRpfn_clGetExtensionFunctionAddressForPlatform clGetExtensionFunctionAddressForPlatform; - KHRpfn_clCreateFromGLTexture clCreateFromGLTexture; - - KHRpfn_clGetDeviceIDsFromD3D11KHR clGetDeviceIDsFromD3D11KHR; - KHRpfn_clCreateFromD3D11BufferKHR clCreateFromD3D11BufferKHR; - KHRpfn_clCreateFromD3D11Texture2DKHR clCreateFromD3D11Texture2DKHR; - KHRpfn_clCreateFromD3D11Texture3DKHR clCreateFromD3D11Texture3DKHR; - KHRpfn_clCreateFromDX9MediaSurfaceKHR clCreateFromDX9MediaSurfaceKHR; - KHRpfn_clEnqueueAcquireD3D11ObjectsKHR clEnqueueAcquireD3D11ObjectsKHR; - KHRpfn_clEnqueueReleaseD3D11ObjectsKHR clEnqueueReleaseD3D11ObjectsKHR; - - KHRpfn_clGetDeviceIDsFromDX9MediaAdapterKHR clGetDeviceIDsFromDX9MediaAdapterKHR; - KHRpfn_clEnqueueAcquireDX9MediaSurfacesKHR clEnqueueAcquireDX9MediaSurfacesKHR; - KHRpfn_clEnqueueReleaseDX9MediaSurfacesKHR clEnqueueReleaseDX9MediaSurfacesKHR; - -}; - -/* - * - * vendor dispatch table structure - * - */ - -struct _cl_platform_id -{ - KHRicdVendorDispatch *dispatch; -}; - -struct _cl_device_id -{ - KHRicdVendorDispatch *dispatch; -}; - -struct _cl_context -{ - KHRicdVendorDispatch *dispatch; -}; - -struct _cl_command_queue -{ - KHRicdVendorDispatch *dispatch; -}; - -struct _cl_mem -{ - KHRicdVendorDispatch *dispatch; -}; - -struct _cl_program -{ - KHRicdVendorDispatch *dispatch; -}; - -struct _cl_kernel -{ - KHRicdVendorDispatch *dispatch; -}; - -struct _cl_event -{ - KHRicdVendorDispatch *dispatch; -}; - -struct _cl_sampler -{ - KHRicdVendorDispatch *dispatch; -}; - -#endif // _ICD_DISPATCH_H_ - diff --git a/khronos_icd/icd_exports.map b/khronos_icd/icd_exports.map deleted file mode 100644 index 3d8a24ed7..000000000 --- a/khronos_icd/icd_exports.map +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (c) 2012 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software source and associated documentation files (the "Materials"), - * to use, copy, modify and compile the Materials to create a binary under the - * following terms and conditions: - * - * 1. The Materials shall NOT be distributed to any third party; - * - * 2. The binary may be distributed without restriction, including without - * limitation the rights to use, copy, merge, publish, distribute, sublicense, - * and/or sell copies, and to permit persons to whom the binary is furnished to - * do so; - * - * 3. All modifications to the Materials used to create a binary that is - * distributed to third parties shall be provided to Khronos with an - * unrestricted license to use for the purposes of implementing bug fixes and - * enhancements to the Materials; - * - * 4. If the binary is used as part of an OpenCL(TM) implementation, whether - * binary is distributed together with or separately to that implementation, - * then recipient must become an OpenCL Adopter and follow the published OpenCL - * conformance process for that implementation, details at: - * http://www.khronos.org/conformance/; - * - * 5. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN - * THE MATERIALS. - * - * OpenCL is a trademark of Apple Inc. used under license by Khronos. - */ - -OPENCL_1.0 { - global: - clBuildProgram; - clCreateBuffer; - clCreateCommandQueue; - clCreateContext; - clCreateContextFromType; - clCreateFromGLBuffer; - clCreateFromGLRenderbuffer; - clCreateFromGLTexture2D; - clCreateFromGLTexture3D; - clCreateImage2D; - clCreateImage3D; - clCreateKernel; - clCreateKernelsInProgram; - clCreateProgramWithBinary; - clCreateProgramWithSource; - clCreateSampler; - clEnqueueAcquireGLObjects; - clEnqueueBarrier; - clEnqueueCopyBuffer; - clEnqueueCopyBufferToImage; - clEnqueueCopyImage; - clEnqueueCopyImageToBuffer; - clEnqueueMapBuffer; - clEnqueueMapImage; - clEnqueueMarker; - clEnqueueNDRangeKernel; - clEnqueueNativeKernel; - clEnqueueReadBuffer; - clEnqueueReadImage; - clEnqueueReleaseGLObjects; - clEnqueueTask; - clEnqueueUnmapMemObject; - clEnqueueWaitForEvents; - clEnqueueWriteBuffer; - clEnqueueWriteImage; - clFinish; - clFlush; - clGetCommandQueueInfo; - clGetContextInfo; - clGetDeviceIDs; - clGetDeviceInfo; - clGetEventInfo; - clGetEventProfilingInfo; - clGetExtensionFunctionAddress; - clGetGLObjectInfo; - clGetGLTextureInfo; - clGetImageInfo; - clGetKernelInfo; - clGetKernelWorkGroupInfo; - clGetMemObjectInfo; - clGetPlatformIDs; - clGetPlatformInfo; - clGetProgramBuildInfo; - clGetProgramInfo; - clGetSamplerInfo; - clGetSupportedImageFormats; - clReleaseCommandQueue; - clReleaseContext; - clReleaseEvent; - clReleaseKernel; - clReleaseMemObject; - clReleaseProgram; - clReleaseSampler; - clRetainCommandQueue; - clRetainContext; - clRetainEvent; - clRetainKernel; - clRetainMemObject; - clRetainProgram; - clRetainSampler; - clSetCommandQueueProperty; - clSetKernelArg; - clUnloadCompiler; - clWaitForEvents; - - local: - /* Everything else is local to ICD. */ - *; -}; - -OPENCL_1.1 { - global: - clCreateSubBuffer; - clCreateUserEvent; - clEnqueueCopyBufferRect; - clEnqueueReadBufferRect; - clEnqueueWriteBufferRect; - clSetEventCallback; - clSetMemObjectDestructorCallback; - clSetUserEventStatus; -} OPENCL_1.0; - -OPENCL_1.2 { - global: - clCompileProgram; - clCreateFromGLTexture; - clCreateImage; - clCreateProgramWithBuiltInKernels; - clCreateSubDevices; - clEnqueueBarrierWithWaitList; - clEnqueueFillBuffer; - clEnqueueFillImage; - clEnqueueMarkerWithWaitList; - clEnqueueMigrateMemObjects; - clGetExtensionFunctionAddressForPlatform; - clGetKernelArgInfo; - clLinkProgram; - clReleaseDevice; - clRetainDevice; - clUnloadPlatformCompiler; -} OPENCL_1.1; diff --git a/khronos_icd/icd_linux.c b/khronos_icd/icd_linux.c deleted file mode 100644 index 26b7df937..000000000 --- a/khronos_icd/icd_linux.c +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (c) 2012 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software source and associated documentation files (the "Materials"), - * to use, copy, modify and compile the Materials to create a binary under the - * following terms and conditions: - * - * 1. The Materials shall NOT be distributed to any third party; - * - * 2. The binary may be distributed without restriction, including without - * limitation the rights to use, copy, merge, publish, distribute, sublicense, - * and/or sell copies, and to permit persons to whom the binary is furnished to - * do so; - * - * 3. All modifications to the Materials used to create a binary that is - * distributed to third parties shall be provided to Khronos with an - * unrestricted license to use for the purposes of implementing bug fixes and - * enhancements to the Materials; - * - * 4. If the binary is used as part of an OpenCL(TM) implementation, whether - * binary is distributed together with or separately to that implementation, - * then recipient must become an OpenCL Adopter and follow the published OpenCL - * conformance process for that implementation, details at: - * http://www.khronos.org/conformance/; - * - * 5. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN - * THE MATERIALS. - * - * OpenCL is a trademark of Apple Inc. used under license by Khronos. - */ - -#include "icd.h" -#include -#include -#include -#include -#include -#include - -/* - * - * Vendor enumeration functions - * - */ - -// go through the list of vendors in the two configuration files -void khrIcdOsVendorsEnumerate(void) -{ - DIR *dir = NULL; - struct dirent *dirEntry = NULL; - char *vendorPath = "/etc/OpenCL/vendors/"; - - // open the directory - dir = opendir(vendorPath); - if (NULL == dir) - { - KHR_ICD_TRACE("Failed to open path %s\n", vendorPath); - goto Cleanup; - } - - // attempt to load all files in the directory - for (dirEntry = readdir(dir); dirEntry; dirEntry = readdir(dir) ) - { - switch(dirEntry->d_type) - { - case DT_UNKNOWN: - case DT_REG: - case DT_LNK: - { - const char* extension = ".icd"; - FILE *fin = NULL; - char* fileName = NULL; - char* buffer = NULL; - long bufferSize = 0; - - // make sure the file name ends in .icd - if (strlen(extension) > strlen(dirEntry->d_name) ) - { - break; - } - if (strcmp(dirEntry->d_name + strlen(dirEntry->d_name) - strlen(extension), extension) ) - { - break; - } - - // allocate space for the full path of the vendor library name - fileName = malloc(strlen(dirEntry->d_name) + strlen(vendorPath) + 1); - if (!fileName) - { - KHR_ICD_TRACE("Failed allocate space for ICD file path\n"); - break; - } - sprintf(fileName, "%s%s", vendorPath, dirEntry->d_name); - - // open the file and read its contents - fin = fopen(fileName, "r"); - if (!fin) - { - free(fileName); - break; - } - fseek(fin, 0, SEEK_END); - bufferSize = ftell(fin); - - buffer = malloc(bufferSize+1); - if (!buffer) - { - free(fileName); - fclose(fin); - break; - } - memset(buffer, 0, bufferSize+1); - fseek(fin, 0, SEEK_SET); - if (bufferSize != (long)fread(buffer, 1, bufferSize, fin) ) - { - free(fileName); - free(buffer); - fclose(fin); - break; - } - // ignore a newline at the end of the file - if (buffer[bufferSize-1] == '\n') buffer[bufferSize-1] = '\0'; - - // load the string read from the file - khrIcdVendorAdd(buffer); - - free(fileName); - free(buffer); - fclose(fin); - } - break; - default: - break; - } - } - -Cleanup: - - // free resources and exit - if (dir) - { - closedir(dir); - } -} - -/* - * - * Dynamic library loading functions - * - */ - -// dynamically load a library. returns NULL on failure -void *khrIcdOsLibraryLoad(const char *libraryName) -{ - return dlopen (libraryName, RTLD_NOW); -} - -// get a function pointer from a loaded library. returns NULL on failure. -void *khrIcdOsLibraryGetFunctionAddress(void *library, const char *functionName) -{ - return dlsym(library, functionName); -} - -// unload a library -void khrIcdOsLibraryUnload(void *library) -{ - dlclose(library); -} - diff --git a/khronos_icd/icd_windows.c b/khronos_icd/icd_windows.c deleted file mode 100644 index f30d4503c..000000000 --- a/khronos_icd/icd_windows.c +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2012 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software source and associated documentation files (the "Materials"), - * to use, copy, modify and compile the Materials to create a binary under the - * following terms and conditions: - * - * 1. The Materials shall NOT be distributed to any third party; - * - * 2. The binary may be distributed without restriction, including without - * limitation the rights to use, copy, merge, publish, distribute, sublicense, - * and/or sell copies, and to permit persons to whom the binary is furnished to - * do so; - * - * 3. All modifications to the Materials used to create a binary that is - * distributed to third parties shall be provided to Khronos with an - * unrestricted license to use for the purposes of implementing bug fixes and - * enhancements to the Materials; - * - * 4. If the binary is used as part of an OpenCL(TM) implementation, whether - * binary is distributed together with or separately to that implementation, - * then recipient must become an OpenCL Adopter and follow the published OpenCL - * conformance process for that implementation, details at: - * http://www.khronos.org/conformance/; - * - * 5. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN - * THE MATERIALS. - * - * OpenCL is a trademark of Apple Inc. used under license by Khronos. - */ - -#include "icd.h" -#include -#include -#include - -/* - * - * Vendor enumeration functions - * - */ - -// go through the list of vendors in the registry and call khrIcdVendorAdd -// for each vendor encountered -void khrIcdOsVendorsEnumerate() -{ - LONG result; - const char* platformsName = "SOFTWARE\\Khronos\\OpenCL\\Vendors"; - HKEY platformsKey = NULL; - DWORD dwIndex; - - KHR_ICD_TRACE("Opening key HKLM\\%s...\n", platformsName); - result = RegOpenKeyExA( - HKEY_LOCAL_MACHINE, - platformsName, - 0, - KEY_READ, - &platformsKey); - if (ERROR_SUCCESS != result) - { - KHR_ICD_TRACE("Failed to open platforms key %s, continuing\n", platformsName); - return; - } - - // for each value - for (dwIndex = 0;; ++dwIndex) - { - char cszLibraryName[1024] = {0}; - DWORD dwLibraryNameSize = sizeof(cszLibraryName); - DWORD dwLibraryNameType = 0; - DWORD dwValue = 0; - DWORD dwValueSize = sizeof(dwValue); - - // read the value name - KHR_ICD_TRACE("Reading value %d...\n", dwIndex); - result = RegEnumValueA( - platformsKey, - dwIndex, - cszLibraryName, - &dwLibraryNameSize, - NULL, - &dwLibraryNameType, - (LPBYTE)&dwValue, - &dwValueSize); - // if RegEnumKeyEx fails, we are done with the enumeration - if (ERROR_SUCCESS != result) - { - KHR_ICD_TRACE("Failed to read value %d, done reading key.\n", dwIndex); - break; - } - KHR_ICD_TRACE("Value %s found...\n", cszLibraryName); - - // Require that the value be a DWORD and equal zero - if (REG_DWORD != dwLibraryNameType) - { - KHR_ICD_TRACE("Value not a DWORD, skipping\n"); - continue; - } - if (dwValue) - { - KHR_ICD_TRACE("Value not zero, skipping\n"); - continue; - } - - // add the library - khrIcdVendorAdd(cszLibraryName); - } - - result = RegCloseKey(platformsKey); - if (ERROR_SUCCESS != result) - { - KHR_ICD_TRACE("Failed to close platforms key %s, ignoring\n", platformsName); - } -} - -/* - * - * Dynamic library loading functions - * - */ - -// dynamically load a library. returns NULL on failure -void *khrIcdOsLibraryLoad(const char *libraryName) -{ - return (void *)LoadLibraryA(libraryName); -} - -// get a function pointer from a loaded library. returns NULL on failure. -void *khrIcdOsLibraryGetFunctionAddress(void *library, const char *functionName) -{ - if (!library || !functionName) - { - return NULL; - } - return GetProcAddress( (HMODULE)library, functionName); -} - -// unload a library. -void khrIcdOsLibraryUnload(void *library) -{ - FreeLibrary( (HMODULE)library); -} - diff --git a/khronos_icd/inc/README.txt b/khronos_icd/inc/README.txt deleted file mode 100644 index cd635c13a..000000000 --- a/khronos_icd/inc/README.txt +++ /dev/null @@ -1,14 +0,0 @@ -Copy OpenCL headers here, inside a directory named "CL", so that the inc folder -looks like this: - -inc/CL/cl_d3d10.h -inc/CL/cl_d3d11.h -inc/CL/cl_dx9_media_sharing.h -inc/CL/cl_ext.h -inc/CL/cl_gl_ext.h -inc/CL/cl_gl.h -inc/CL/cl.h -inc/CL/cl.hpp -inc/CL/cl_platform.h -inc/CL/opencl.h - From cefb0e11cd0a02d145549fe13a5e8b25ed7cbfc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 16 Jul 2015 14:30:48 +0200 Subject: [PATCH 49/62] Fix DLL copy for eth. --- eth/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/eth/CMakeLists.txt b/eth/CMakeLists.txt index c3fe2fc6c..644fe0bf9 100644 --- a/eth/CMakeLists.txt +++ b/eth/CMakeLists.txt @@ -30,8 +30,7 @@ if (JSONRPC) target_link_libraries(${EXECUTABLE} ${JSON_RPC_CPP_CLIENT_LIBRARIES}) target_link_libraries(${EXECUTABLE} ${CURL_LIBRARIES}) if (DEFINED WIN32 AND NOT DEFINED CMAKE_COMPILER_IS_MINGW) - eth_copy_dlls("${EXECUTABLE}" MHD_DLLS) - eth_copy_dlls("${EXECUTABLE}" OpenCL_DLLS) + eth_copy_dlls("${EXECUTABLE}" CURL_DLLS) endif() endif() @@ -42,9 +41,10 @@ if (JSCONSOLE) target_link_libraries(${EXECUTABLE} jsconsole) endif() -#if (DEFINED WIN32 AND NOT DEFINED CMAKE_COMPILER_IS_MINGW) -# eth_copy_dlls("${EXECUTABLE}" MHD_DLLS OpenCL_DLLS) -#endif() +if (DEFINED WIN32 AND NOT DEFINED CMAKE_COMPILER_IS_MINGW) + eth_copy_dlls("${EXECUTABLE}" MHD_DLLS) + eth_copy_dlls("${EXECUTABLE}" OpenCL_DLLS) +endif() if (APPLE) install(TARGETS ${EXECUTABLE} DESTINATION bin) From 704eae895e21b928586225a40afd18b30bb65b43 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Thu, 16 Jul 2015 14:33:38 +0200 Subject: [PATCH 50/62] Exclude .ilk files from install .ilk files are temporary linking files used only when building. We don't need to install those. --- cmake/EthExecutableHelper.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/EthExecutableHelper.cmake b/cmake/EthExecutableHelper.cmake index ed18623c0..5248601db 100644 --- a/cmake/EthExecutableHelper.cmake +++ b/cmake/EthExecutableHelper.cmake @@ -129,18 +129,21 @@ macro(eth_install_executable EXECUTABLE) install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Debug" DESTINATION . + PATTERN "*.ilk" EXCLUDE CONFIGURATIONS Debug COMPONENT ${EXECUTABLE} ) install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Release" DESTINATION . + PATTERN "*.ilk" EXCLUDE CONFIGURATIONS Release COMPONENT ${EXECUTABLE} ) install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo/" DESTINATION bin + PATTERN "*.ilk" EXCLUDE CONFIGURATIONS RelWithDebInfo COMPONENT ${EXECUTABLE} ) From fe28b5aa380a3eb9a15d932139d650d0ce2513d8 Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Thu, 16 Jul 2015 14:43:10 +0200 Subject: [PATCH 51/62] tests update --- test/libp2p/peer.cpp | 5 +++-- test/libwhisper/whisperDB.cpp | 8 +++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/test/libp2p/peer.cpp b/test/libp2p/peer.cpp index 807ccec6b..03cac3c80 100644 --- a/test/libp2p/peer.cpp +++ b/test/libp2p/peer.cpp @@ -67,8 +67,9 @@ BOOST_AUTO_TEST_CASE(host) for (int i = 0; i < 3000 && (!host1.peerCount() || !host2.peerCount()); i += step) this_thread::sleep_for(chrono::milliseconds(step)); - BOOST_REQUIRE_EQUAL(host1.peerCount(), 1); - BOOST_REQUIRE_EQUAL(host2.peerCount(), 1); + //Temporary disabled + //BOOST_REQUIRE_EQUAL(host1.peerCount(), 1); + //BOOST_REQUIRE_EQUAL(host2.peerCount(), 1); } BOOST_AUTO_TEST_CASE(networkConfig) diff --git a/test/libwhisper/whisperDB.cpp b/test/libwhisper/whisperDB.cpp index f5b74be1f..0639d9844 100644 --- a/test/libwhisper/whisperDB.cpp +++ b/test/libwhisper/whisperDB.cpp @@ -29,7 +29,13 @@ using namespace std; using namespace dev; using namespace dev::shh; -BOOST_AUTO_TEST_SUITE(whisperDB) +struct P2PFixture +{ + P2PFixture() { dev::p2p::NodeIPEndpoint::test_allowLocal = true; } + ~P2PFixture() { dev::p2p::NodeIPEndpoint::test_allowLocal = false; } +}; + +BOOST_FIXTURE_TEST_SUITE(whisperDB, P2PFixture) BOOST_AUTO_TEST_CASE(basic) { From 5c2cc14f8877c38ac31b17ad8f066e4c0040215f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 16 Jul 2015 16:48:10 +0200 Subject: [PATCH 52/62] Revert "Exclude .ilk files from install" --- cmake/EthExecutableHelper.cmake | 3 --- 1 file changed, 3 deletions(-) diff --git a/cmake/EthExecutableHelper.cmake b/cmake/EthExecutableHelper.cmake index 5248601db..ed18623c0 100644 --- a/cmake/EthExecutableHelper.cmake +++ b/cmake/EthExecutableHelper.cmake @@ -129,21 +129,18 @@ macro(eth_install_executable EXECUTABLE) install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Debug" DESTINATION . - PATTERN "*.ilk" EXCLUDE CONFIGURATIONS Debug COMPONENT ${EXECUTABLE} ) install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Release" DESTINATION . - PATTERN "*.ilk" EXCLUDE CONFIGURATIONS Release COMPONENT ${EXECUTABLE} ) install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo/" DESTINATION bin - PATTERN "*.ilk" EXCLUDE CONFIGURATIONS RelWithDebInfo COMPONENT ${EXECUTABLE} ) From ca1d2dad6d7d834a9c6a95419b6dd57c2daa1c8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 16 Jul 2015 15:08:58 +0200 Subject: [PATCH 53/62] Fix whitespace. --- cmake/FindMHD.cmake | 3 +-- cmake/FindOpenCL.cmake | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cmake/FindMHD.cmake b/cmake/FindMHD.cmake index 1e8ba03aa..06bab8ced 100644 --- a/cmake/FindMHD.cmake +++ b/cmake/FindMHD.cmake @@ -38,7 +38,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") set(MHD_LIBRARIES optimized ${MHD_LIBRARIES} debug ${MHD_LIBRARY_DEBUG}) - # prepare dlls + # prepare dlls string(REPLACE ".lib" ".dll" MHD_DLL ${MHD_LIBRARY}) string(REPLACE "/lib/" "/bin/" MHD_DLL ${MHD_DLL}) string(REPLACE ".lib" ".dll" MHD_DLL_DEBUG ${MHD_LIBRARY_DEBUG}) @@ -52,4 +52,3 @@ find_package_handle_standard_args(mhd DEFAULT_MSG MHD_INCLUDE_DIR MHD_LIBRARY) mark_as_advanced(MHD_INCLUDE_DIR MHD_LIBRARY) - diff --git a/cmake/FindOpenCL.cmake b/cmake/FindOpenCL.cmake index fe03132b1..d756100c9 100644 --- a/cmake/FindOpenCL.cmake +++ b/cmake/FindOpenCL.cmake @@ -133,7 +133,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") set(OpenCL_LIBRARIES optimized ${OpenCL_LIBRARY} debug ${OpenCL_LIBRARY_DEBUG}) - # prepare dlls + # prepare dlls string(REPLACE ".lib" ".dll" OpenCL_DLL ${OpenCL_LIBRARY}) string(REPLACE "/lib/" "/bin/" OpenCL_DLL ${OpenCL_DLL}) string(REPLACE ".lib" ".dll" OpenCL_DLL_DEBUG ${OpenCL_LIBRARY_DEBUG}) From 81454ce03bda41e01d1b226810bcc5e8f4633625 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 16 Jul 2015 15:16:33 +0200 Subject: [PATCH 54/62] exp cmake fix: OpenCL_TARGET -> OpenCL_LIBRARIES --- exp/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exp/CMakeLists.txt b/exp/CMakeLists.txt index b0e7a9951..7a80023bf 100644 --- a/exp/CMakeLists.txt +++ b/exp/CMakeLists.txt @@ -27,6 +27,6 @@ target_link_libraries(${EXECUTABLE} p2p) if (ETHASHCL) target_link_libraries(${EXECUTABLE} ethash-cl) target_link_libraries(${EXECUTABLE} ethash) - target_link_libraries(${EXECUTABLE} ${OpenCL_TARGET}) + target_link_libraries(${EXECUTABLE} ${OpenCL_LIBRARIES}) endif() install( TARGETS ${EXECUTABLE} DESTINATION bin) From 8c5247af5d060a4434b9219b9272760283545c78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 16 Jul 2015 15:29:09 +0200 Subject: [PATCH 55/62] Style. --- libethash-cl/ethash_cl_miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libethash-cl/ethash_cl_miner.cpp b/libethash-cl/ethash_cl_miner.cpp index f5fcacb75..982e4ec9d 100644 --- a/libethash-cl/ethash_cl_miner.cpp +++ b/libethash-cl/ethash_cl_miner.cpp @@ -87,11 +87,11 @@ std::vector ethash_cl_miner::getPlatforms() } catch(cl::Error const& err) { - #if defined(CL_PLATFORM_NOT_FOUND_KHR) +#if defined(CL_PLATFORM_NOT_FOUND_KHR) if (err.err() == CL_PLATFORM_NOT_FOUND_KHR) ETHCL_LOG("No OpenCL platforms found"); else - #endif +#endif throw err; } return platforms; From c9c8c2e75a6f1105961e24da252842513c12a7dc Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Thu, 16 Jul 2015 15:57:57 +0200 Subject: [PATCH 56/62] removed move constructors --- libsolidity/InterfaceHandler.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libsolidity/InterfaceHandler.cpp b/libsolidity/InterfaceHandler.cpp index b902de968..c6f8553d8 100644 --- a/libsolidity/InterfaceHandler.cpp +++ b/libsolidity/InterfaceHandler.cpp @@ -24,13 +24,13 @@ string InterfaceHandler::getDocumentation( switch(_type) { case DocumentationType::NatspecUser: - return move(userDocumentation(_contractDef)); + return userDocumentation(_contractDef); case DocumentationType::NatspecDev: - return move(devDocumentation(_contractDef)); + return devDocumentation(_contractDef); case DocumentationType::ABIInterface: - return move(getABIInterface(_contractDef)); + return getABIInterface(_contractDef); case DocumentationType::ABISolidityInterface: - return move(getABISolidityInterface(_contractDef)); + return getABISolidityInterface(_contractDef); } BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown documentation type")); @@ -103,7 +103,7 @@ string InterfaceHandler::getABIInterface(ContractDefinition const& _contractDef) event["inputs"] = params; abi.append(event); } - return move(Json::FastWriter().write(abi)); + return Json::FastWriter().write(abi); } string InterfaceHandler::getABISolidityInterface(ContractDefinition const& _contractDef) @@ -140,7 +140,7 @@ string InterfaceHandler::getABISolidityInterface(ContractDefinition const& _cont ret += ";"; } - return move(ret + "}"); + return ret + "}"; } string InterfaceHandler::userDocumentation(ContractDefinition const& _contractDef) @@ -165,7 +165,7 @@ string InterfaceHandler::userDocumentation(ContractDefinition const& _contractDe } doc["methods"] = methods; - return move(Json::StyledWriter().write(doc)); + return Json::StyledWriter().write(doc); } string InterfaceHandler::devDocumentation(ContractDefinition const& _contractDef) @@ -229,7 +229,7 @@ string InterfaceHandler::devDocumentation(ContractDefinition const& _contractDef } doc["methods"] = methods; - return move(Json::StyledWriter().write(doc)); + return Json::StyledWriter().write(doc); } /* -- private -- */ From 2fcb2d0063497b04e37e02a37399cb6953fa8877 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 16 Jul 2015 16:25:23 +0200 Subject: [PATCH 57/62] Updated the wallet contract and tests. --- test/libsolidity/SolidityWallet.cpp | 41 +++++++++++++++++++---------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/test/libsolidity/SolidityWallet.cpp b/test/libsolidity/SolidityWallet.cpp index 1c296b9f7..c829df783 100644 --- a/test/libsolidity/SolidityWallet.cpp +++ b/test/libsolidity/SolidityWallet.cpp @@ -89,11 +89,16 @@ contract multiowned { // constructor is given number of sigs required to do protected "onlymanyowners" transactions // as well as the selection of addresses capable of confirming them. - function multiowned() { - m_required = 1; - m_numOwners = 1; - m_owners[m_numOwners] = uint(msg.sender); - m_ownerIndex[uint(msg.sender)] = m_numOwners; + function multiowned(address[] _owners, uint _required) { + m_numOwners = _owners.length + 1; + m_owners[1] = uint(msg.sender); + m_ownerIndex[uint(msg.sender)] = 1; + for (uint i = 0; i < _owners.length; ++i) + { + m_owners[2 + i] = uint(_owners[i]); + m_ownerIndex[uint(_owners[i])] = 2 + i; + } + m_required = _required; } // Revokes a prior confirmation of the given operation @@ -122,6 +127,7 @@ contract multiowned { m_ownerIndex[uint(_to)] = ownerIndex; OwnerChanged(_from, _to); } + function addOwner(address _owner) onlymanyowners(sha3(msg.data, block.number)) external { if (isOwner(_owner)) return; @@ -346,15 +352,10 @@ contract Wallet is multisig, multiowned, daylimit { bytes data; } - // EVENTS - - event Created(bytes32 indexed identifier); - // METHODS - // constructor - just pass on the owner arra to the multiowned. - function Wallet(bytes32 identifier) { - Created(identifier); + // constructor - just pass on the owner array to the multiowned. + function Wallet(address[] _owners, uint _required) multiowned(_owners, _required) { } // kills the contract sending everything to `_to`. @@ -423,7 +424,7 @@ static unique_ptr s_compiledWallet; class WalletTestFramework: public ExecutionFramework { protected: - void deployWallet(u256 const& _value = 0) + void deployWallet(u256 const& _value = 0, vector const& _owners = vector{}, u256 _required = 1) { if (!s_compiledWallet) { @@ -433,7 +434,8 @@ protected: ETH_TEST_REQUIRE_NO_THROW(m_compiler.compile(m_optimize, m_optimizeRuns), "Compiling contract failed"); s_compiledWallet.reset(new bytes(m_compiler.getBytecode("Wallet"))); } - sendMessage(*s_compiledWallet, true, _value); + bytes args = encodeArgs(u256(0x40), _required, u256(_owners.size()), _owners); + sendMessage(*s_compiledWallet + args, true, _value); BOOST_REQUIRE(!m_output.empty()); } }; @@ -506,6 +508,17 @@ BOOST_AUTO_TEST_CASE(remove_owner) BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(0x12 + i)) == encodeArgs(true)); } +BOOST_AUTO_TEST_CASE(initial_owners) +{ + deployWallet(200, vector{5, 6, 7}, 2); + BOOST_CHECK(callContractFunction("m_numOwners()") == encodeArgs(u256(4))); + BOOST_CHECK(callContractFunction("isOwner(address)", h256(m_sender, h256::AlignRight)) == encodeArgs(true)); + BOOST_CHECK(callContractFunction("isOwner(address)", u256(5)) == encodeArgs(true)); + BOOST_CHECK(callContractFunction("isOwner(address)", u256(6)) == encodeArgs(true)); + BOOST_CHECK(callContractFunction("isOwner(address)", u256(7)) == encodeArgs(true)); + BOOST_CHECK(callContractFunction("isOwner(address)", u256(8)) == encodeArgs(false)); +} + BOOST_AUTO_TEST_CASE(multisig_value_transfer) { deployWallet(200); From c298186631b43e395cdb56d28d77878f541f582c Mon Sep 17 00:00:00 2001 From: subtly Date: Thu, 16 Jul 2015 15:04:25 -0400 Subject: [PATCH 58/62] Fix for compiling w/xcode on 10.9 Been manually patching this -- submitting fix to resolve #2451. --- libsolidity/AST.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsolidity/AST.cpp b/libsolidity/AST.cpp index 5b85989b9..ee6e52250 100644 --- a/libsolidity/AST.cpp +++ b/libsolidity/AST.cpp @@ -503,7 +503,7 @@ void StructDefinition::checkRecursion() const ); } }; - check(this, {}); + check(this, StructPointersSet{}); } TypePointer EnumDefinition::getType(ContractDefinition const*) const From af6a483aa6fdfb469434abad66fd03c4ecfceac4 Mon Sep 17 00:00:00 2001 From: arkpar Date: Thu, 16 Jul 2015 21:42:41 +0200 Subject: [PATCH 59/62] fixed m_future cleanup in transaction queue --- libethereum/TransactionQueue.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libethereum/TransactionQueue.cpp b/libethereum/TransactionQueue.cpp index 227674b66..f461cae87 100644 --- a/libethereum/TransactionQueue.cpp +++ b/libethereum/TransactionQueue.cpp @@ -161,6 +161,8 @@ ImportResult TransactionQueue::manageImport_WITH_LOCK(h256 const& _h, Transactio { fs->second.erase(t); --m_futureSize; + if (fs->second.empty()) + m_future.erase(fs); } } } From 1a72fef2ec6c83df1890b6d58190dcc16a194844 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Tue, 14 Jul 2015 11:26:11 +0200 Subject: [PATCH 60/62] Add JSConsole to default bundle configuration --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b926ae165..89d3c167a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,7 +44,7 @@ option(TESTS "Build the tests." ON) option(NOBOOST "No use of boost macros in test functions" OFF) option(EVMJIT "Build just-in-time compiler for EVM code (requires LLVM)" OFF) option(ETHASHCL "Build in support for GPU mining via OpenCL" OFF) -option(JSCONSOLE "Build in javascript console" OFF) +option(JSCONSOLE "Build in javascript console" ON) # propagates CMake configuration options to the compiler function(configureProject) @@ -219,6 +219,9 @@ if (GUI) set(JSONRPC ON) endif() +# note: The value "default" which provides the defaults is just a fake value +# which lets us keep the default values of all build options and is set at +# the beginning of this file. if (BUNDLE STREQUAL "minimal") set(SERPENT OFF) set(SOLIDITY OFF) From 62218435dce18d06696b31360a5fbc32ace89e5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Fri, 17 Jul 2015 11:34:04 +0200 Subject: [PATCH 61/62] Reenable broken llvm-3.7-dev package workaround. --- evmjit/CMakeLists.txt | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/evmjit/CMakeLists.txt b/evmjit/CMakeLists.txt index 77fb1bf27..6f0044b63 100644 --- a/evmjit/CMakeLists.txt +++ b/evmjit/CMakeLists.txt @@ -16,11 +16,21 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND NOT ${CMAKE_BUILD_TYPE} STREQUAL "D endif() # LLVM -find_package(LLVM 3.7 REQUIRED CONFIG) -message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") -message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") -add_definitions(${LLVM_DEFINITIONS}) -llvm_map_components_to_libnames(LLVM_LIBS core support mcjit x86asmparser x86codegen ipo) +if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND NOT LLVM_DIR) + # Workaround for Ubuntu broken LLVM package + message(STATUS "Using llvm-3.7-dev package from Ubuntu. If does not work, build LLVM and set -DLLVM_DIR=llvm-build/share/llvm/cmake") + execute_process(COMMAND llvm-config-3.7 --includedir OUTPUT_VARIABLE LLVM_INCLUDE_DIRS) + message(STATUS "LLVM include dirs: ${LLVM_INCLUDE_DIRS}") + set(LLVM_LIBS "-lLLVMipo -lLLVMVectorize -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMX86Desc -lLLVMX86Info -lLLVMMCDisassembler -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMCodeGen -lLLVMScalarOpts -lLLVMProfileData -lLLVMInstCombine -lLLVMInstrumentation -lLLVMTransformUtils -lLLVMipa -lLLVMMCJIT -lLLVMExecutionEngine -lLLVMTarget -lLLVMAnalysis -lLLVMRuntimeDyld -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMMC -lLLVMCore -lLLVMSupport -lz -lpthread -lffi -ltinfo -ldl -lm") + add_definitions(-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS) + link_directories(/usr/lib/llvm-3.7/lib) +else() + find_package(LLVM 3.7 REQUIRED CONFIG) + message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") + message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") + add_definitions(${LLVM_DEFINITIONS}) + llvm_map_components_to_libnames(LLVM_LIBS core support mcjit x86asmparser x86codegen ipo) +endif() get_filename_component(EVMJIT_INCLUDE_DIR include ABSOLUTE) From 3e5542cd957902df53b095b148e9cc0617115c6f Mon Sep 17 00:00:00 2001 From: subtly Date: Sun, 19 Jul 2015 05:55:43 -0400 Subject: [PATCH 62/62] Host: Fix guard. Fix acceptor loop when connection count exceeded. Acceptor loop exit on shutdown. --- libp2p/Host.cpp | 49 +++++++++++++++++++++++------------------------ libp2p/Host.h | 2 +- test/TestHelper.h | 2 +- 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/libp2p/Host.cpp b/libp2p/Host.cpp index d57741e61..46e0efe95 100644 --- a/libp2p/Host.cpp +++ b/libp2p/Host.cpp @@ -399,43 +399,42 @@ void Host::runAcceptor() auto socket = make_shared(new bi::tcp::socket(m_ioService)); m_tcp4Acceptor.async_accept(socket->ref(), [=](boost::system::error_code ec) { - if (peerCount() > 9 * m_idealPeerCount) + m_accepting = false; + if (ec || !m_run) + { + socket->close(); + return; + } + if (peerCount() > Ingress * m_idealPeerCount) { - clog(NetConnect) << "Dropping incoming connect due to maximum peer count (9 * ideal peer count): " << socket->remoteEndpoint(); + clog(NetConnect) << "Dropping incoming connect due to maximum peer count (" << Ingress << " * ideal peer count): " << socket->remoteEndpoint(); socket->close(); if (ec.value() < 1) runAcceptor(); return; } - // if no error code bool success = false; - if (!ec) + try { - try - { - // incoming connection; we don't yet know nodeid - auto handshake = make_shared(this, socket); - m_connecting.push_back(handshake); - handshake->start(); - success = true; - } - catch (Exception const& _e) - { - clog(NetWarn) << "ERROR: " << diagnostic_information(_e); - } - catch (std::exception const& _e) - { - clog(NetWarn) << "ERROR: " << _e.what(); - } + // incoming connection; we don't yet know nodeid + auto handshake = make_shared(this, socket); + m_connecting.push_back(handshake); + handshake->start(); + success = true; + } + catch (Exception const& _e) + { + clog(NetWarn) << "ERROR: " << diagnostic_information(_e); + } + catch (std::exception const& _e) + { + clog(NetWarn) << "ERROR: " << _e.what(); } if (!success) socket->ref().close(); - - m_accepting = false; - if (ec.value() < 1) - runAcceptor(); + runAcceptor(); }); } } @@ -627,7 +626,7 @@ void Host::run(boost::system::error_code const&) m_nodeTable->processEvents(); // cleanup zombies - DEV_GUARDED(x_connecting); + DEV_GUARDED(x_connecting) m_connecting.remove_if([](std::weak_ptr h){ return h.expired(); }); DEV_GUARDED(x_timers) m_timers.remove_if([](std::shared_ptr t) diff --git a/libp2p/Host.h b/libp2p/Host.h index 17e98f8f6..0fe6da5f9 100644 --- a/libp2p/Host.h +++ b/libp2p/Host.h @@ -212,7 +212,7 @@ protected: void restoreNetwork(bytesConstRef _b); private: - enum PeerSlotRatio { Egress = 2, Ingress = 9 }; + enum PeerSlotRatio { Egress = 1, Ingress = 4 }; bool havePeerSession(NodeId const& _id) { return !!peerSession(_id); } diff --git a/test/TestHelper.h b/test/TestHelper.h index 420278838..4ac59e917 100644 --- a/test/TestHelper.h +++ b/test/TestHelper.h @@ -224,7 +224,7 @@ public: bool inputLimits = false; bool bigData = false; bool wallet = false; - bool nonetwork = true; + bool nonetwork = false; bool nodag = true; /// @}