Talvos  0.1
SPIR-V interpreter and dynamic analysis framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Plugin.h
Go to the documentation of this file.
1 // Copyright (c) 2018 the Talvos developers. All rights reserved.
2 //
3 // This file is distributed under a three-clause BSD license. For full license
4 // terms please see the LICENSE file distributed with this source code.
5 
8 
9 #ifndef TALVOS_PLUGIN_H
10 #define TALVOS_PLUGIN_H
11 
12 #include <cstdint>
13 
14 namespace talvos
15 {
16 
17 class Command;
18 class Instruction;
19 class Invocation;
20 class Memory;
21 class Workgroup;
22 
26 class Plugin
27 {
28 public:
29  virtual ~Plugin() = default;
30 
32  virtual bool isThreadSafe() const { return true; }
33 
35  virtual void atomicAccess(const Memory *Mem, uint64_t Address,
36  uint64_t NumBytes, uint32_t Opcode, uint32_t Scope,
37  uint32_t Semantics, const Invocation *Invoc)
38  {}
39 
41  virtual void commandBegin(const Command *Cmd) {}
42 
44  virtual void commandComplete(const Command *Cmd) {}
45 
47  virtual void hostMemoryLoad(const Memory *Mem, uint64_t Address,
48  uint64_t NumBytes)
49  {}
50 
52  virtual void hostMemoryStore(const Memory *Mem, uint64_t Address,
53  uint64_t NumBytes, const uint8_t *Data)
54  {}
55 
57  virtual void instructionExecuted(const Invocation *Invoc,
58  const Instruction *Inst)
59  {}
60 
62  virtual void invocationBegin(const Invocation *Invoc) {}
63 
65  virtual void invocationComplete(const Invocation *Invoc) {}
66 
68  virtual void memoryLoad(const Memory *Mem, uint64_t Address,
69  uint64_t NumBytes, const Invocation *Invoc)
70  {}
71 
73  virtual void memoryMap(const Memory *Mem, uint64_t Base, uint64_t Offset,
74  uint64_t NumBytes)
75  {}
76 
78  virtual void memoryStore(const Memory *Mem, uint64_t Address,
79  uint64_t NumBytes, const uint8_t *Data,
80  const Invocation *Invoc)
81  {}
82 
84  virtual void memoryUnmap(const Memory *Mem, uint64_t Base) {}
85 
87  virtual void workgroupBegin(const Workgroup *Group) {}
88 
90  virtual void workgroupBarrier(const Workgroup *Group) {}
91 
93  virtual void workgroupComplete(const Workgroup *Group) {}
94 };
95 
96 } // namespace talvos
97 
98 #endif
virtual void instructionExecuted(const Invocation *Invoc, const Instruction *Inst)
Called when an instruction has been executed by an invocation.
Definition: Plugin.h:57
Base class for Talvos plugins.
Definition: Plugin.h:26
virtual void memoryUnmap(const Memory *Mem, uint64_t Base)
Called when a memory region is unmapped by the host.
Definition: Plugin.h:84
virtual void workgroupBarrier(const Workgroup *Group)
Called when a workgroup barrier is cleared.
Definition: Plugin.h:90
This class is a base class for all commands.
Definition: Commands.h:31
virtual void commandComplete(const Command *Cmd)
Called when a command has completed.
Definition: Plugin.h:44
This class represents a single execution of a SPIR-V entry point.
Definition: Invocation.h:33
virtual void hostMemoryLoad(const Memory *Mem, uint64_t Address, uint64_t NumBytes)
Called when the host loads data from memory.
Definition: Plugin.h:47
virtual bool isThreadSafe() const
Returns true if the plugin is thread-safe.
Definition: Plugin.h:32
This class represents an address space in the virtual device.
Definition: Memory.h:37
virtual void memoryMap(const Memory *Mem, uint64_t Base, uint64_t Offset, uint64_t NumBytes)
Called when a memory region is mapped by the host.
Definition: Plugin.h:73
virtual void workgroupComplete(const Workgroup *Group)
Called when a workgroup has completed.
Definition: Plugin.h:93
virtual void memoryLoad(const Memory *Mem, uint64_t Address, uint64_t NumBytes, const Invocation *Invoc)
Called when an invocation loads data from memory.
Definition: Plugin.h:68
virtual void commandBegin(const Command *Cmd)
Called when a command has begun executing.
Definition: Plugin.h:41
This class represents a workgroup executing a compute command.
Definition: Workgroup.h:27
virtual void atomicAccess(const Memory *Mem, uint64_t Address, uint64_t NumBytes, uint32_t Opcode, uint32_t Scope, uint32_t Semantics, const Invocation *Invoc)
Called when memory is atomically accessed by an instruction.
Definition: Plugin.h:35
virtual void invocationComplete(const Invocation *Invoc)
Called when an invocation has completed.
Definition: Plugin.h:65
virtual void hostMemoryStore(const Memory *Mem, uint64_t Address, uint64_t NumBytes, const uint8_t *Data)
Called when the host stores data to memory.
Definition: Plugin.h:52
virtual void memoryStore(const Memory *Mem, uint64_t Address, uint64_t NumBytes, const uint8_t *Data, const Invocation *Invoc)
Called when an invocation stores data to memory.
Definition: Plugin.h:78
virtual ~Plugin()=default
virtual void workgroupBegin(const Workgroup *Group)
Called when a workgroup has begun executing.
Definition: Plugin.h:87
virtual void invocationBegin(const Invocation *Invoc)
Called when an invocation has begun executing.
Definition: Plugin.h:62
This class represents a SPIR-V instruction.
Definition: Instruction.h:27