diff --git a/thesis/bachelor.pdf b/thesis/bachelor.pdf index 1ab69b1..00f6bc9 100644 Binary files a/thesis/bachelor.pdf and b/thesis/bachelor.pdf differ diff --git a/thesis/content/40_design.tex b/thesis/content/40_design.tex index aba8820..3201bc8 100644 --- a/thesis/content/40_design.tex +++ b/thesis/content/40_design.tex @@ -34,11 +34,21 @@ The task of prefetching is somewhat aligned with that of a cache. As a cache is more generic and allows use beyond Query Driven Prefetching, the choice was made to solve the prefetching offload by implementing an offloading \texttt{Cache}. When referring to the provided implementation, \texttt{Cache} will be used from now on. The interface with \texttt{Cache} must provide three basic functions: requesting a memory block to be cached, accessing a cached memory block and synchronizing cache with the source memory. The latter operation comes in to play when the data that is cached may also be modified, requiring the entry to be updated with the source or the other way around. Due to the many possible setups and use cases, the user should also be responsible for choosing cache placement and the copy method. As re-caching is resource intensive, data should remain in the cache for as long as possible while being removed when memory pressure due to restrictive memory size drives the \texttt{Cache} to flush unused entries. \par +\begin{figure}[h] + \centering + \includegraphics[width=0.9\textwidth]{images/design-classdiagram.png} + \caption{Public Interface of CacheData and Cache Classes} + \label{fig:impl-design-interface} +\end{figure} + +For reference, the public interface which we will develop throughout this section is visualized in Figure \ref{fig:impl-design-interface} for both classes created. Colour coding signals thread safety where grey denotes impossibility for threaded access. Green indicates full safety guarantees only relying on atomics to achieve this. Turquoise functions use locking mechanisms to achieve thread safety. Operations in yellow may observe threading effects from atomics but are still inherently safe to call. Finally, red markers indicate unsafe functions which must be called from a single threaded context. As we implement these classes in C++ in Chapter \ref{chap:implementation}, we also utilize C++-Notation for functions in the figure here.\par + \subsection{Interface} -To allow rapid integration and ease developer workload, a simple interface was chosen. As this work primarily focuses on caching static data, the choice was made only to provide cache invalidation and not synchronization. Given a memory address, \texttt{Cache::Invalidate} will remove all entries for it. The other two operations are provided in one single function, which we shall call \texttt{Cache::Access} henceforth, receiving a data pointer and size it takes care of either submitting a caching operation if the pointer received is not yet cached or returning the cache entry if it is. The cache placement and assignment of the task to accelerators are controlled by the user. In addition to the two basic operations outlined before, the user also is given the option to flush the cache using \texttt{Cache::Flush} of unused elements manually or to clear it completely with \texttt{Cache::Clear}. \par -As caching is performed asynchronously, the user may wish to wait on the operation. This would be beneficial if there are other threads making progress in parallel while the current thread waits on its data becoming available in the faster cache, speeding up local computation. To achieve this, the \texttt{Cache::Access} will return an instance of an object which from hereinafter will be referred to as \texttt{CacheData}. Through \texttt{CacheData::GetDataLocation} a pointer to the cached data will be retrieved, while also providing \texttt{CacheData::WaitOnCompletion} which must only return when the caching operation has completed and during which the current thread is put to sleep, allowing other threads to progress. \par +To allow rapid integration and ease developer workload, a simple interface was chosen. As this work primarily focuses on caching static data, the choice was made only to provide cache invalidation and not synchronization. Given a memory address, \texttt{Cache::Invalidate} will remove all entries for it. The other two operations are provided in one single function, which we shall call \texttt{Cache::Access} henceforth, receiving a data pointer and size it takes care of either submitting a caching operation if the pointer received is not yet cached or returning the cache entry if it is. The cache placement and assignment of the task to accelerators are controlled by the user. In addition to the two basic operations outlined before, the user also is given the option to flush the cache using \texttt{Cache::Flush} of unused elements manually or to clear it completely with \texttt{Cache::Clear}. This interface is represented on the right block of Figure \ref{fig:impl-design-interface} labelled \enquote{Cache}. \par + +As caching is performed asynchronously, the user may wish to wait on the operation. This would be beneficial if there are other threads making progress in parallel while the current thread waits on its data becoming available in the faster cache, speeding up local computation. To achieve this, the \texttt{Cache::Access} will return an instance of an object which from hereinafter will be referred to as \texttt{CacheData}. Through \texttt{CacheData::GetDataLocation} a pointer to the cached data will be retrieved, while also providing \texttt{CacheData::WaitOnCompletion} which must only return when the caching operation has completed and during which the current thread is put to sleep, allowing other threads to progress. Figure \ref{fig:impl-design-interface} also documents the public interface for \texttt{CacheData} on the left block labelled as such. \par \subsection{Cache Entry Reuse} \label{subsec:design:cache-entry-reuse} diff --git a/thesis/images/design-classdiagram.png b/thesis/images/design-classdiagram.png new file mode 100644 index 0000000..c42f896 Binary files /dev/null and b/thesis/images/design-classdiagram.png differ diff --git a/thesis/images/design-classdiagram.xml b/thesis/images/design-classdiagram.xml new file mode 100644 index 0000000..f70f6ab --- /dev/null +++ b/thesis/images/design-classdiagram.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +