text
stringlengths
28
935k
meta
stringlengths
137
139
red_pajama_subset
stringclasses
1 value
\section{Introduction} \label{sec:intro} Despite the immense popularity and availability of online video content via outlets such as Youtube and Facebook, most work on object detection focuses on static images. Given the breakthroughs of deep convolutional neural networks for detecting objects in static images, the application of these methods to video might seem straightforward. However, motion blur and compression artifacts cause substantial frame-to-frame variability, even in videos that appear smooth to the eye. These attributes complicate prediction tasks like classification and localization. Object-detection models trained on images tend not to perform competitively on videos owing to domain shift factors \cite{KalogeitonFS15}. Moreover, object-level annotations in popular video data-sets can be extremely sparse, impeding the development of better video-based object detection models. Girshik \emph{et al}\bmvaOneDot \cite{RCNN_girshick14CVPR} demonstrate that even given scarce labeled training data, high-capacity convolutional neural networks can achieve state of the art detection performance if first pre-trained on a related task with abundant training data, such as 1000-way ImageNet classification. Followed the pretraining, the networks can be fine-tuned to a related but distinct domain. Also relevant to our work, the recently introduced models Faster R-CNN \cite{Faster_RCNN_RenHG015} and You Look Only Once (YOLO) \cite{YOLO_RedmonDGF15} unify the tasks of classification and localization. These methods, which are accurate and efficient, propose to solve both tasks through a single model, bypassing the separate object proposal methods used by R-CNN \cite{RCNN_girshick14CVPR}. In this paper, we introduce a method to extend unified object recognition and localization to the video domain. Our approach applies transfer learning from the image domain to video frames. Additionally, we present a novel recurrent neural network (RNN) method that refines predictions by exploiting contextual information in neighboring frames. In summary, we contribute the following: \begin{itemize} \item A new method for refining a video-based object detection consisting of two parts: (i) a \emph{pseudo-labeler}, which assigns provisional labels to all available video frames. (ii) A recurrent neural network, which reads in a sequence of provisionally labeled frames, using the contextual information to output refined predictions. \item An effective training strategy utilizing (i) category-level weak-supervision at every time-step, (ii) localization-level strong supervision at final time-step (iii) a penalty encouraging prediction smoothness at consecutive time-steps, and (iv) similarity constraints between \emph{pseudo-labels} and prediction output at every time-step. \item An extensive empirical investigation demonstrating that on the YouTube Objects \cite{youtube-Objects} dataset, our framework achieves mean average precision (mAP) of $68.73$ on test data, compared to a best published result of $37.41$ \cite{Tripathi_WACV16} and $61.66$ for a domain adapted YOLO network \cite{YOLO_RedmonDGF15}. \end{itemize} \section{Methods} \label{sec:method} In this work, we aim to refine object detection in video by utilizing contextual information from neighboring video frames. We accomplish this through a two-stage process. First, we train a \emph{pseudo-labeler}, that is, a domain-adapted convolutional neural network for object detection, trained individually on the labeled video frames. Specifically, we fine-tune the YOLO object detection network \cite{YOLO_RedmonDGF15}, which was originally trained for the 20-class PASCAL VOC \cite{PASCAL_VOC} dataset, to the Youtube-Video \cite{youtube-Objects} dataset. When fine-tuning to the 10 sub-categories present in the video dataset, our objective is to minimize the weighted squared detection loss (equation \ref{eqn:obj_det_loss}) as specified in YOLO \cite{YOLO_RedmonDGF15}. While fine-tuning, we learn only the parameters of the top-most fully-connected layers, keeping the $24$ convolutional layers and $4$ max-pooling layers unchanged. The training takes roughly 50 epochs to converge, using the RMSProp \cite{RMSProp} optimizer with momentum of $0.9$ and a mini-batch size of $128$. As with YOLO \cite{YOLO_RedmonDGF15}, our fine-tuned $pseudo-labeler$ takes $448 \times 448$ frames as input and regresses on category types and locations of possible objects at each one of $S \times S$ non-overlapping grid cells. For each grid cell, the model outputs class conditional probabilities as well as $B$ bounding boxes and their associated confidence scores. As in YOLO, we consider a \emph{responsible} bounding box for a grid cell to be the one among the $B$ boxes for which the predicted area and the ground truth area shares the maximum Intersection Over Union. During training, we simultaneously optimize classification and localization error (equation \ref{eqn:obj_det_loss}). For each grid cell, we minimize the localization error for the \emph{responsible} bounding box with respect to the ground truth only when an object appears in that cell. Next, we train a Recurrent Neural Network (RNN), with Gated Recurrent Units (GRUs) \cite{Cho14_GRU}. This net takes as input sequences of \emph{pseudo-labels}, optimizing an objective that encourages both accuracy on the target frame and consistency across consecutive frames. Given a series of \emph{pseudo-labels} $\mathbf{x}^{(1)}, ..., \mathbf{x}^{(T)}$, we train the RNN to generate improved predictions $\hat{\mathbf{y}}^{(1)}, ..., \hat{\mathbf{y}}^{(T)}$ with respect to the ground truth $\mathbf{y}^{(T)}$ available only at the final step in each sequence. Here, $t$ indexes sequence steps and $T$ denotes the length of the sequence. As output, we use a fully-connected layer with a linear activation function, as our problem is regression. In our final experiments, we use a $2$-layer GRU with $150$ nodes per layer, hyper-parameters determined on validation data. The following equations define the forward pass through a GRU layer, where $\mathbf{h}^{(t)}_l$ denotes the layer's output at the current time step, and $\mathbf{h}^{(t)}_{l-1}$ denotes the previous layer's output at the same sequence step: \begin{equation} \label{eqn:GRU} \begin{aligned} \mathbf{r}^{(t)}_l &= \sigma(\mathbf{h}^{(t)}_{l-1}W^{xr}_l + \mathbf{h}^{(t-1)}_lW^{hr}_l + \mathbf{b}^r_l)\\ \mathbf{u}^{(t)}_l &= \sigma(\mathbf{h}^{(t)}_{l-1}W^{xu}_l + \mathbf{h}^{(t-1)}_lW^{hu}_l + \mathbf{b}^u_l)\\ \mathbf{c}^{(t)}_l &= \sigma(\mathbf{h}^{(t)}_{l-1}W^{xc}_l + r_t \odot(\mathbf{h}^{(t-1)}_lW^{hc}_l) + \mathbf{b}^c_l)\\ \mathbf{h}^{(t)}_l &= (1-\mathbf{u}^{(t)}_l)\odot \mathbf{h}^{(t-1)}_l + \mathbf{u}^{(t)}_l\odot \mathbf{c}^{(t)}_l \end{aligned} \end{equation} Here, $\sigma$ denotes an element-wise logistic function and $\odot$ is the (element-wise) Hadamard product. The reset gate, update gate, and candidate hidden state are denoted by $\textbf{r}$, $\textbf{u}$, and $\textbf{c}$ respectively. For $S = 7$ and $B=2$, the pseudo-labels $\mathbf{x}^{(t)}$ and prediction $\hat{\mathbf{y}}^{(t)}$ both lie in $\mathbb{R}^{1470}$. \vspace{-2.5mm} \subsection{Training} We design an objective function (Equation \ref{eqn:objective}) that accounts for both accuracy at the target frame and consistency of predictions across adjacent time steps in the following ways: \begin{equation} \label{eqn:objective} \mbox{loss} = \mbox{d\_loss} + \alpha \cdot \mbox{s\_loss} + \beta \cdot \mbox{c\_loss} + \gamma \cdot \mbox{pc\_loss} \end{equation} Here, d\_loss, s\_loss, c\_loss and pc\_loss stand for detection\_loss, similarity\_loss, category\_loss and prediction\_consistency\_loss described in the following sections. The values of the hyper-parameters $\alpha=0.2$, $\beta=0.2$ and $\gamma=0.1$ are chosen based on the detection performance on the validation set. The training converges in 80 epochs for parameter updates using RMSProp \cite{RMSProp} and momentum $0.9$. During training we use a mini-batch size of $128$ and sequences of length $30$. \subsubsection{Strong Supervision at Target Frame} On the final output, for which the ground truth classification and localization is available, we apply a multi-part object detection loss as described in YOLO \cite{YOLO_RedmonDGF15}. \vspace{-2.5mm} \begin{equation} \label{eqn:obj_det_loss} \begin{aligned} \mbox{detection\_loss} &= \lambda_{coord}\sum^{S^2}_{i=0}\sum^{B}_{j=0}\mathbbm{1}^{obj}_{ij}\big(\mathit{x}^{(T)}_i - \hat{\mathit{x}}^{(T)}_i\big)^2 + \big(\mathit{y}^{(T)}_i - \hat{\mathit{y}}^{(T)}_i\big)^2 \\ & + \lambda_{coord}\sum^{S^2}_{i=0}\sum^{B}_{j=0}\mathbbm{1}^{obj}_{ij}\big(\sqrt{w_i}^{(T)} - \sqrt{\hat{w}^{(T)}_i}\big)^2 + \big (\sqrt{h_i}^{(T)} - \sqrt{\hat{h}^{(T)}_i} \big)^2 \\ & + \sum^{S^2}_{i=0}\sum^{B}_{j=0}\mathbbm{1}^{obj}_{ij}(\mathit{C}_i - \hat{\mathit{C}_i})^2 \\ & + \lambda_{noobj}\sum^{S^2}_{i=0}\sum^{B}_{j=0}\mathbbm{1}^{noobj}_{ij}\big(\mathit{C}^{(T)}_i - \hat{\mathit{C}}^{(T)}_i\big)^2 \\ & + \sum^{S^2}_{i=0}\mathbbm{1}^{obj}_{i}\sum_{c \in classes}\big(p_i^{(T)}(c) - \hat{p_i}^{(T)}(c)\big)^2 \end{aligned} \end{equation} where $\mathbbm{1}^{obj}_{i}$ denotes if the object appears in cell $i$ and $\mathbbm{1}^{obj}_{ij}$ denotes that $j$th bounding box predictor in cell $i$ is \emph{responsible} for that prediction. The loss function penalizes classification and localization error differently based on presence or absence of an object in that grid cell. $x_i, y_i, w_i, h_i$ corresponds to the ground truth bounding box center coordinates, width and height for objects in grid cell (if it exists) and $\hat{x_i}, \hat{y_i}, \hat{w_i}, \hat{h_i}$ stand for the corresponding predictions. $C_i$ and $\hat{C_i}$ denote confidence score of \emph{objectness} at grid cell $i$ for ground truth and prediction. $p_i(c)$ and $\hat{p_i}(c)$ stand for conditional probability for object class $c$ at cell index $i$ for ground truth and prediction respectively. We use similar settings for YOLO's object detection loss minimization and use values of $\lambda_{coord} = 5$ and $\lambda_{noobj} = 0.5$. \vspace{-2.5mm} \subsubsection{Similarity between \emph{Pseudo-labels} and Predictions} Our objective function also includes a regularizer that penalizes the dissimilarity between \emph{pseudo-labels} and the prediction at each time frame $t$. \vspace{-2.5mm} \begin{equation} \label{auto_enc_loss} \mbox{similarity\_loss} = \sum^T_{t=0}\sum^{S^2}_{i=0}\hat{C}^{(t)}_i\Big(\mathbf{x}^{(t)}_i - \hat{\mathbf{y}_i}^{(t)} \Big)^2 \end{equation} Here, $\mathbf{x}^{(t)}_i$ and $\hat{\mathbf{y}_i}^{(t)}$ denote the \emph{pseudo-labels} and predictions corresponding to the $i$-th grid cell at $t$-th time step respectively. We perform minimization of the square loss weighted by the predicted confidence score at the corresponding cell. \subsubsection{Object Category-level Weak-Supervision} Replication of the static target at each sequential step has been shown to be effective in \cite{LiptonKEW15, yue2015beyond, dai2015semi}. Of course, with video data, different objects may move in different directions and speeds. Yet, within a short time duration, we could expect all objects to be present. Thus we employ target replication for classification but not localization objectives. We minimize the square loss between the categories aggregated over all grid cells in the ground truth $\mathbf{y}^{(T)}$ at final time step $T$ and predictions $\hat{\mathbf{y}}^{(t)}$ at all time steps $t$. Aggregated category from the ground truth considers only the cell indices where an object is present. For predictions, contribution of cell $i$ is weighted by its predicted confidence score $\hat{C}^{(t)}_i$. Note that cell indices with positive detection are sparse. Thus, we consider the confidence score of each cell while minimizing the aggregated category loss. \vspace{-2.5mm} \begin{equation} \label{category_supervision} \mbox{category\_loss} = \sum^T_{t=0}\bigg(\sum_{c \in classes} \Big(\sum^{S^2}_{i=0} \hat{C}^{(t)}_i\big(\hat{p}^{(t)}_i(c)\big) - \sum^{S^2}_{i=0}\mathbbm{1}^{obj^{(T)}}_i \big(p_i^{(T)}(c)\big)\Big) \bigg)^2 \end{equation} \subsubsection{Consecutive Prediction Smoothness} Additionally, we regularize the model by encouraging smoothness of predictions across consecutive time-steps. This makes sense intuitively because we assume that objects rarely move rapidly from one frame to another. \vspace{-2.5mm} \begin{equation} \label{prediction_smoothness} \mbox{prediction\_consistency\_loss} = \sum^{T-1}_{t=0}\Big(\hat{\mathbf{y}_i}^{(t)} - \hat{\mathbf{y}_i}^{(t+1)} \Big)^2 \end{equation} \vspace{-2.5mm} \subsection{Inference} The recurrent neural network predicts output at every time-step. The network predicts $98$ bounding boxes per video frame and class probabilities for each of the $49$ grid cells. We note that for every cell, the net predicts class conditional probabilities for each one of the $C$ categories and $B$ bounding boxes. Each one of the $B$ predicted bounding boxes per cell has an associated \emph{objectness} confidence score. The predicted confidence score at that grid is the maximum among the boxes. The bounding box with the highest score becomes the \emph{responsible} prediction for that grid cell $i$. The product of class conditional probability $\hat{p}^{(t)}_i(c)$ for category type $c$ and \emph{objectness} confidence score $\hat{C}^{(t)}_i$ at grid cell $i$, if above a threshold, infers a detection. In order for an object of category type $c$ to be detected for $i$-th cell at time-step $t$, both the class conditional probability $\hat{p}^{(t)}_i(c)$ and \emph{objectness score} $\hat{C}^{(t)}_i$ must be reasonably high. Additionally, we employ Non-Maximum Suppression (NMS) to winnow multiple high scoring bounding boxes around an object instance and produce a single detection for an instance. By virtue of YOLO-style prediction, NMS is not critical. \section{Experimental Results} \label{sec:results} In this section, we empirically evaluate our model on the popular \textbf{Youtube-Objects} dataset, providing both quantitative results (as measured by mean Average Precision) and subjective evaluations of the model's performance, considering both successful predictions and failure cases. The \textbf{Youtube-Objects} dataset\cite{youtube-Objects} is composed of videos collected from Youtube by querying for the names of 10 object classes of the PASCAL VOC Challenge. It contains 155 videos in total and between 9 and 24 videos for each class. The duration of each video varies between 30 seconds and 3 minutes. However, only $6087$ frames are annotated with $6975$ bounding-box instances. The training and test split is provided. \subsection{Experimental Setup} We implement the domain-adaption of YOLO and the proposed RNN model using Theano \cite{Theano2016arXiv160502688short}. Our best performing RNN model uses two GRU layers of $150$ hidden units each and dropout of probability $0.5$ between layers, significantly outperforming domain-adapted YOLO alone. While we can only objectively evaluate prediction quality on the labeled frames, we present subjective evaluations on sequences. \subsection{Objective Evaluation} We compare our approach with other methods evaluated on the Youtube-Objects dataset. As shown in Table \ref{table:per_category_results} and Table \ref{table:final_mAP}, Deformable Parts Model (DPM) \cite{FelzenszwalbMR_CVPR_2008})-based detector reports \cite{KalogeitonFS15} mean average precision below $30$, with especially poor performance in some categories such as \emph{cat}. The method of Tripathi \emph{et al}\bmvaOneDot (VPO) \cite{Tripathi_WACV16} uses consistent video object proposals followed by a domain-adapted AlexNet classifier (5 convolutional layer, 3 fully connected) \cite{AlexNet12} in an R-CNN \cite{RCNN_girshick14CVPR}-like framework, achieving mAP of $37.41$. We also compare against YOLO ($24$ convolutional layers, 2 fully connected layers), which unifies the classification and localization tasks, and achieves mean Average Precision over $55$. In our method, we adapt YOLO to generate \emph{pseudo-labels} for all video frames, feeding them as inputs to the refinement RNN. We choose YOLO as the \emph{pseudo-labeler} because it is the most accurate among feasibly fast image-level detectors. The domain-adaptation improves YOLO's performance, achieving mAP of $61.66$. Our model with RNN-based prediction refinement, achieves superior aggregate mAP to all baselines. The RNN refinement model using both input-output similarity, category-level weak-supervision, and prediction smoothness performs best, achieving $\mbox{68.73}$ mAP. This amounts to a relative improvement of $\mbox{11.5\%}$ over the best baselines. Additionally, the RNN improves detection accuracy on most individual categories (Table \ref{table:per_category_results}). \begin{table} \label{table:per_category_results} \centering \footnotesize \begin{tabular}{lllllllllll} \multicolumn{11}{c}{\textbf{Average Precision on 10-categories}} \\ \midrule Methods & airplane & bird & boat & car & cat & cow & dog & horse & mbike & train \\ \midrule DPM\cite{FelzenszwalbMR_CVPR_2008} & 28.42 & 48.14 & 25.50 & 48.99 & 1.69 & 19.24 & 15.84 & 35.10 & 31.61 & 39.58 \\ VOP\cite{Tripathi_WACV16} & 29.77 & 28.82 & 35.34 & 41.00 & 33.7 & 57.56 & 34.42 & 54.52 & 29.77 & 29.23 \\ YOLO\cite{YOLO_RedmonDGF15} & 76.67 & 89.51 & 57.66 & 65.52 & 43.03 & 53.48 & 55.81 & 36.96 & 24.62 & 62.03 \\ DA YOLO & \textbf{83.89} & \textbf{91.98} & 59.91 & 81.95 & 46.67 & 56.78 & 53.49 & 42.53 & 32.31 & 67.09 \\ \midrule RNN-IOS & 82.78 & 89.51 & 68.02 & \textbf{82.67} & 47.88 & 70.33 & 52.33 & 61.52 & 27.69 & \textbf{67.72} \\ RNN-WS & 77.78 & 89.51 & \textbf{69.40} & 78.16 & 51.52 & \textbf{78.39} & 47.09 & 81.52 & 36.92 & 62.03 \\ RNN-PS & 76.11 & 87.65 & 62.16 & 80.69 & \textbf{62.42} & 78.02 & \textbf{58.72} & \textbf{81.77} & \textbf{41.54} & 58.23 \\ \bottomrule \end{tabular} \caption{Per-category object detection results for the Deformable Parts Model (DPM), Video Object Proposal based AlexNet (VOP), image-trained YOLO (YOLO), domain-adapted YOLO (DA-YOLO). RNN-IOS regularizes on input-output similarity, to which RNN-WS adds category-level weak-supervision, to which RNN-PS adds a regularizer encouraging prediction smoothness.} \end{table} \begin{table}[h] \label{table:final_mAP} \centering \begin{tabular}{llllllll} \multicolumn{8}{c}{\textbf{mean Average Precision on all categories}} \\ \midrule Methods & DPM & VOP & YOLO & DA YOLO & RNN-IOS & RNN-WS & RNN-PS\\ \midrule mAP & 29.41 & 37.41 & 56.53 & \textbf{61.66} & 65.04 & 67.23 & \textcolor{blue}{\textbf{68.73}}\\ \bottomrule \end{tabular} \caption{Overall detection results on Youtube-Objects dataset. Our best model (RNN-PS) provides $7\%$ improvements over DA-YOLO baseline.} \end{table} \vspace{-2.5mm} \vspace{-2.5mm} \subsection{Subjective Evaluation} We provide a subjective evaluation of the proposed RNN model in Figure \ref{fig:subjective1}. Top and bottom rows in every pair of sequences correspond to \emph{pseudo-labels} and results from our approach respectively. While only the last frame in each sequence has associated ground truth, we can observe that the RNN produces more accurate and more consistent predictions across time frames. The predictions are consistent with respect to classification, localization and confidence scores. In the first example, the RNN consistently detects the \emph{dog} throughout the sequence, even though the \emph{pseudo-labels} for the first two frames were wrong (\emph{bird}). In the second example, \emph{pseudo-labels} were \emph{motorbike}, \emph{person}, \emph{bicycle} and even \emph{none} at different time-steps. However, our approach consistently predicted \emph{motorbike}. The third example shows that the RNN consistently predicts both of the cars while the \emph{pseudo-labeler} detects only the smaller car in two frames within the sequence. The last two examples show how the RNN increases its confidence scores, bringing out the positive detection for \emph{cat} and \emph{car} respectively both of which fell below the detection threshold of the \emph{pseudo-labeler}. \begin{figure*} \begin{center} \includegraphics[scale=0.75]{result2_category_consistency-eps-converted-to.pdf} \includegraphics[scale=0.75]{result3_category_consistency-eps-converted-to.pdf} \includegraphics[scale=0.75]{result1_localizations-eps-converted-to.pdf} \includegraphics[scale=0.75]{result8_detection_through_consistency-eps-converted-to.pdf} \includegraphics[scale=0.75]{result16_detection_through_consistency-eps-converted-to.pdf} \end{center} \caption{ Object detection results from the final eight frames of five different test-set sequences. In each pair of rows, the top row shows the \emph{pseudo-labeler} and the bottom row shows the RNN. In the first two examples, the RNN consistently predicts correct categories \emph{dog} and \emph{motorbike}, in contrast to the inconsistent baseline. In the third sequence, the RNN correctly predicts multiple instances while the \emph{pseudo-labeler} misses one. For the last two sequences, the RNN increases the confidence score, detecting objects missed by the baseline. } \label{fig:subjective1} \end{figure*} \subsection{Areas For Improvement} The YOLO scheme for unifying classification and localization \cite{YOLO_RedmonDGF15} imposes strong spatial constraints on bounding box predictions since each grid cell can have only one class. This restricts the set of possible predictions, which may be undesirable in the case where many objects are in close proximity. Additionally, the rigidity of the YOLO model may present problems for the refinement RNN, which encourages smoothness of predictions across the sequence of frames. Consider, for example, an object which moves slightly but transits from one grid cell to another. Here smoothness of predictions seems undesirable. \begin{figure*} \begin{center} \includegraphics[scale=0.75]{failure_cases-eps-converted-to.pdf} \end{center} \caption{Failure cases for the proposed model. Left: the RNN cannot recover from incorrect \emph{pseudo-labels}. Right: RNN localization performs worse than \emph{pseudo-labels} possibly owing to multiple instances of the same object. } \label{fig:failure_cases} \vspace{-2.5mm} \end{figure*} Figure \ref{fig:failure_cases} shows some failure cases. In the first case, the \emph{pseudo-labeler} classifies the instances as \emph{dogs} and even as \emph{birds} in two frames whereas the ground truth instances are \emph{horses}. The RNN cannot recover from the incorrect pseudo-labels. Strangely, the model increases the confidence score marginally for a different wrong category \emph{cow}. In the second case, possibly owing to motion and close proximity of multiple instances of the same object category, the RNN predicts the correct category but fails on localization. These point to future work to make the framework robust to motion. The category-level weak supervision in the current scheme assumes the presence of all objects in nearby frames. While for short snippets of video this assumption generally holds, it may be violated in case of occlusions, or sudden arrival or departure of objects. In addition, our assumptions regarding the desirability of prediction smoothness can be violated in the case of rapidly moving objects. \vspace{-2.5mm} \section{Related Work} \label{sec:prior-art} Our work builds upon a rich literature in both image-level object detection,video analysis, and recurrent neural networks. Several papers propose ways of using deep convolutional networks for detecting objects \cite{RCNN_girshick14CVPR,fast_RCNN_15,Faster_RCNN_RenHG015, YOLO_RedmonDGF15, SzegedyREA14, Inside_Outside_Net_BellZBG15, DeepID-Net_2015_CVPR, Overfeat_SermanetEZMFL13, CRAFTCVPR16, Gidaris_2015_ICCV}. Some approaches classify the proposal regions \cite{RCNN_girshick14CVPR,fast_RCNN_15} into object categories and some other recent methods \cite{Faster_RCNN_RenHG015, YOLO_RedmonDGF15} unify the localization and classification stages. Kalogeiton \emph{et al}\bmvaOneDot \cite{KalogeitonFS15} identifies domain shift factors between still images and videos, necessitating video-specific object detectors. To deal with shift factors and sparse object-level annotations in video, researchers have proposed several strategies. Recently, \cite{Tripathi_WACV16} proposed both transfer learning from the image domain to video frames and optimizing for temporally consistent object proposals. Their approach is capable of detecting both moving and static objects. However, the object proposal generation step that precedes classification is slow. Prest \emph{et al}\bmvaOneDot \cite{Weak_obj_from_videoPrestLCSF12}, utilize weak supervision for object detection in videos via category-level annotations of frames, absent localization ground truth. This method assumes that the target object is moving, outputting a spatio-temporal tube that captures this most salient moving object. This paper, however, does not consider context within video for detecting multiple objects. A few recent papers \cite{DeepID-Net_2015_CVPR, Inside_Outside_Net_BellZBG15} identify the important role of context in visual recognition. For object detection in images, Bell \emph{et al}\bmvaOneDot \cite{Inside_Outside_Net_BellZBG15} use spatial RNNs to harness contextual information, showing large improvements on PASCAL VOC \cite{PASCAL_VOC} and Microsoft COCO \cite{COCOLinMBHPRDZ14} object detection datasets. Their approach adopts proposal generation followed by classification framework. This paper exploits spatial, but not temporal context. Recently, Kang \emph{et al}\bmvaOneDot \cite{KangCVPR16} introduced tubelets with convolutional neural networks (T-CNN) for detecting objects in video. T-CNN uses spatio-temporal tubelet proposal generation followed by the classification and re-scoring, incorporating temporal and contextual information from tubelets obtained in videos. T-CNN won the recently introduced ImageNet object-detection-from-video (VID) task with provided densely annotated video clips. Although the method is effective for densely annotated training data, it's behavior for sparsely labeled data is not evaluated. By modeling video as a time series, especially via GRU \cite{Cho14_GRU} or LSTM RNNs\cite{LSTM_Hochreiter_97}, several papers demonstrate improvement on visual tasks including video classification \cite{yue2015beyond}, activity recognition \cite{LongTermRecurrentDonahueHGRVSD14}, and human dynamics \cite{Fragkiadaki_2015_ICCV}. These models generally aggregate CNN features over tens of seconds, which forms the input to an RNN. They perform well for global description tasks such as classification \cite{yue2015beyond,LongTermRecurrentDonahueHGRVSD14} but require large annotated datasets. Yet, detecting multiple generic objects by explicitly modeling video as an ordered sequence remains less explored. Our work differs from the prior art in a few distinct ways. First, this work is the first, to our knowledge, to demonstrate the capacity of RNNs to improve localized object detection in videos. The approach may also be the first to refine the object predictions of frame-level models. Notably, our model produces significant improvements even on a small dataset with sparse annotations. \vspace{-2.5mm} \vspace{-2.5mm} \section{Conclusion} We introduce a framework for refining object detection in video. Our approach extracts contextual information from neighboring frames, generating predictions with state of the art accuracy that are also temporally consistent. Importantly, our model benefits from context frames even when they lack ground truth annotations. For the recurrent model, we demonstrate an efficient and effective training strategy that simultaneously employs localization-level strong supervision, category-level weak-supervision, and a penalty encouraging smoothness of predictions across adjacent frames. On a video dataset with sparse object-level annotation, our framework proves effective, as validated by extensive experiments. A subjective analysis of failure cases suggests that the current approach may struggle most on cases when multiple rapidly moving objects are in close proximity. Likely, the sequential smoothness penalty is not optimal for such complex dynamics. Our results point to several promising directions for future work. First, recent state of the art results for video classification show that longer sequences help in global inference. However, the use of longer sequences for localization remains unexplored. We also plan to explore methods to better model local motion information with the goal of improving localization of multiple objects in close proximity. Another promising direction, we would like to experiment with loss functions to incorporate specialized handling of classification and localization objectives.
{'timestamp': '2016-07-20T02:04:30', 'yymm': '1607', 'arxiv_id': '1607.04648', 'language': 'en', 'url': 'https://arxiv.org/abs/1607.04648'}
arxiv
\section{Introduction} The concept of synchronistion is based on the adjustment of rhythms of oscillating systems due to their interaction \cite{pikovsky01}. Synchronisation phenomenon was recognised by Huygens in the 17th century, time when he performed experiments to understand this phenomenon \cite{bennett02}. To date, several kinds of synchronisation among coupled systems were reported, such as complete \cite{li16}, phase \cite{pereira07,batista10}, lag \cite{huang14}, and collective almost synchronisation \cite{baptista12}. Neuronal synchronous rhythms have been observed in a wide range of researches about cognitive functions \cite{wang10,hutcheon00}. Electroencephalography and magnetoencephalography studies have been suggested that neuronal synchronization in the gamma frequency plays a functional role for memories in humans \cite{axmacher06,fell11}. Steinmetz et al. \cite{steinmetz00} investigated the synchronous behaviour of pairs of neurons in the secondary somatosensory cortex of monkey. They found that attention modulates oscillatory neuronal synchronisation in the somatosensory cortex. Moreover, in the literature it has been proposed that there is a relationship between conscious perception and synchronisation of neuronal activity \cite{hipp11}. We study spiking and bursting synchronisation betwe\-en neuron in a neuronal network model. A spike refers to the action potential generated by a neuron that rapidly rises and falls \cite{lange08}, while bursting refers to a sequence of spikes that are followed by a quiescent time \cite{wu12}. It was demonstrated that spiking synchronisation is relevant to olfactory bulb \cite{davison01} and is involved in motor cortical functions \cite{riehle97}. The characteristics and mechanisms of bursting synchronisation were studied in cultured cortical neurons by means of planar electrode array \cite{maeda95}. Jefferys $\&$ Haas discovered synchronised bursting of CA1 hippocampal pyramidal cells \cite{jefferys82}. There is a wide range of mathematical models used to describe neuronal activity, such as the cellular automaton \cite{viana14}, the Rulkov map \cite{rulkov01}, and differential equations \cite{hodgkin52,hindmarsh84}. One of the simplest mathematical models and that is widely used to depict neuronal behaviour is the integrate-and-fire \cite{lapicque07}, which is governed by a linear differential equation. A more realistic version of it is the adaptive exponential integrate-and-fire (aEIF) model which we consider in this work as the local neuronal activity of neurons in the network. The aEIF is a two-dimensional integrate-and-fire model introduced by Brette $\&$ Gerstner \cite{brette05}. This model has an exponential spike mechanism with an adaptation current. Touboul $\&$ Brette \cite{touboul08} studied the bifurcation diagram of the aEIF. They showed the existence of the Andronov-Hopf bifurcation and saddle-node bifurcations. The aEIF model can generate multiple firing patterns depending on the parameter and which fit experimental data from cortical neurons under current stimulation \cite{naud08}. In this work, we focus on the synchronisation phenomenon in a randomly connected network. This kind of network, also called Erd\"os-R\'enyi network \cite{erdos59}, has nodes where each pair is connected according to a probability. The random neuronal network was utilised to study oscillations in cortico-thalamic circuits \cite{gelenbe98} and dynamics of network with synaptic depression \cite{senn96}. We built a random neuronal network with unidirectional connections that represent chemical synapses. We show that there are clearly separated ranges of parameters that lead to spiking or bursting synchronisation. In addition, we analyse the robustness to external perturbation of the synchronisation. We verify that bursting synchronisation is more robustness than spiking synchronisation. However, bursting synchronisation requires larger chemical synaptic strengths, and larger voltage potential relaxation reset to appear than those required for spiking synchronisation. This paper is organised as follows: in Section II we present the adaptive exponential integrate-and-fire model. In Section III, we introduce the neuronal network with random features. In Section IV, we analyse the behaviour of spiking and bursting synchronisation. In the last Section, we draw our conclusions. \section{Adaptive exponential integrate-and-fire} As a local dynamics of the neuronal network, we consider the adaptive exponential integrate-and-fire (aEIF) model that consists of a system of two differential equations \cite{brette05} given by \begin{eqnarray}\label{eqIF} C \frac{d V}{d t} & = & - g_L (V - E_L) + {\Delta}_T \exp \left(\frac{V - V_T}{{\Delta}_T} \right) \nonumber \\ & & +I-w , \nonumber \\ \tau_w \frac{d w}{d t} & = & a (V - E_L) - w, \end{eqnarray} where $V(t)$ is the membrane potential when a current $I(t)$ is injected, $C$ is the membrane capacitance, $g_L$ is the leak conductance, $E_L$ is the resting potential, $\Delta_T$ is the slope factor, $V_T$ is the threshold potential, $w$ is an adaptation variable, $\tau_w$ is the time constant, and $a$ is the level of subthreshold adaptation. If $V(t)$ reaches the threshold $V_{\rm{peak}}$, a reset condition is applied: $V\rightarrow V_r$ and $w\rightarrow w_r=w+b$. In our simulations, we consider $C=200.0$pF, $g_L=12.0$nS, $E_L=-70.0$mV, ${\Delta}_T=2.0$mV, $V_T=-50.0$mV, $I=509.7$pA, $\tau_w=300.0$ms, $a=2.0$nS, and $V_{\rm{peak}}=20.0$mV \cite{naud08}. The firing pattern depends on the reset parameters $V_r$ and $b$. Table \ref{table1} exhibits some values that generate five different firing patterns (Fig. \ref{fig1}). In Fig. \ref{fig1} we represent each firing pattern with a different colour in the parameter space $b\times V_r$: adaptation in red, tonic spiking in blue, initial bursting in green, regular bursting in yellow, and irregular in black. In Figs. \ref{fig1}a, \ref{fig1}b, and \ref{fig1}c we observe adaptation, tonic spiking, and initial burst pattern, respectively, due to a step current stimulation. Adaptation pattern has increasing inter-spike interval during a sustained stimulus, tonic spiking pattern is the simplest regular discharge of the action potential, and the initial bursting pattern starts with a group of spikes presenting a frequency larger than the steady state frequency. The membrane potential evolution with regular bursting is showed in Fig. \ref{fig1}d, while Fig. \ref{fig1}e displays irregular pattern. \begin{table}[htbp] \caption{Reset parameters.} \centering \begin{tabular}{c c c c c} \hline Firing patterns & Fig. & b (pA) & $V_r$ (mV) & Layout \\ \hline adaptation &\ref{fig1}(a) & 60.0 & -68.0 & red \\ tonic spiking & \ref{fig1}(b) & 5.0 & -65.0 & blue\\ initial burst & \ref{fig1}(c) & 35.0 & -48.8 & green \\ regular bursting & \ref{fig1}(d) & 40.0 & -45.0 & yellow\\ irregular & \ref{fig1}(e) & 41.2 & -47.4 & black \\ \hline \end{tabular} \label{table1} \end{table} \begin{figure}[hbt] \centering \includegraphics[height=7cm,width=10cm]{fig1.eps} \caption{(Colour online) Parameter space for the firing patterns as a function of the reset parameters $V_r$ and $b$. (a) Adaptation in red, (b) tonic spiking in blue, (c) initial bursting in green, (d) regular bursting in yellow, and (e) irregular in black.} \label{fig1} \end{figure} As we have interest in spiking and bursting synchronisation, we separate the parameter space into a region with spike and another with bursting patterns (Fig. \ref{fig2}). To identify these two regions of interest, we use the coefficient of variation (CV) of the neuronal inter-spike interval (ISI), that is given by \begin{eqnarray}\label{CV} {\rm CV}=\frac{{\sigma}_{\rm{ISI}}}{\rm{\overline{ISI}}}, \end{eqnarray} where ${\sigma}_{\rm{ISI}}$ is the standard deviation of the ISI normalised by the mean $\bar{\rm ISI}$ \cite{gabbiani98}. Spiking patterns produce $\rm{CV}<0.5$. Parameter regions that represent the neurons firing with spiking pattern are denoted by gray colour in Fig. \ref{fig2}. Whereas, the black region represents the bursting patterns, which results in $\rm{CV} \geq 0.5$. \begin{figure}[hbt] \centering \includegraphics[height=7cm,width=9cm]{fig2.eps} \caption{Parameter space for the firing patterns as a function of the reset parameters $V_r$ and $b$. Spike pattern in region I ($\rm{CV}<0.5$) and bursting pattern in region II ($\rm{CV}\geq 0.5$) are separated by white circles.} \label{fig2} \end{figure} \section{Spiking or bursting synchronisation} In this work, we constructed a network where the neurons are randomly connected \cite{erdos59}. Our network is given by \begin{eqnarray}\label{eqIFrede} C \frac{d V_i}{d t} & = & - g_L (V_i - E_L) + {\Delta}_T \; \rm{exp} \left(\frac{V_i - V_T}{{\Delta}_T} \right) \nonumber \\ & + & I_i - w_i + g_{\rm{ex}} (V_{\rm{ex}} - V_i) \sum_{j=1}^N A_{ij} s_j + \Gamma_i, \nonumber \\ \tau_w \frac{d w_i}{d t} & = & a_i (V_i - E_L) - w_i, \nonumber \\ \tau_{\rm{ex}} \frac{d s_i}{d t} & = & - s_i. \end{eqnarray} where $V_i$ is the membrane potential of the neuron $i$, $g_{\rm{ex}}$ is the synaptic conductance, $V_{\rm{ex}}$ is the synaptic reversal potential, $\tau_{\rm{ex}}$ is the synaptic time constant, $s_i$ is the synaptic weight, $A_{ij}$ is the adjacency matrix, $\Gamma_i$ is the external perturbation, and $a_i$ is randomly distributed in the interval $[1.9,2.1]$. The schematic representation of the neuronal network that we have considered is illustrated in Fig \ref{fig3}. Each neuron is randomly linked to other neurons with a probability $p$ by means of directed connections. When $p$ is equal to 1, the neuronal network becames an all-to-all network. A network with this topology was used by Borges et al. \cite{borges16} to study the effects of the spike timing-dependent plasticity on the synchronisation in a Hodgkin-Huxley neuronal network. \begin{figure}[hbt] \centering \includegraphics[height=6cm,width=9cm]{fig3.eps} \caption{Schematic representation of the neuronal network where the neurons are connected according to a probability $p$.} \label{fig3} \end{figure} A useful diagnostic tool to determine synchronous behaviour is the complex phase order parameter defined as \cite{kuramoto03} \begin{equation} z(t)=R(t)\exp({\rm i}\Phi(t))\equiv\frac{1}{N}\sum_{j=1}^{N}\exp({\rm i}\psi_{j}), \end{equation} where $R$ and $\Phi$ are the amplitude and angle of a centroid phase vector, respectively, and the phase is given by \begin{equation} \psi_{j}(t)=2\pi m+2\pi\frac{t-t_{j,m}}{t_{j,m+1}-t_{j,m}}, \end{equation} where $t_{j,m}$ corresponds to the time when a spike $m$ ($m=0,1,2,\dots$) of a neuron $j$ happens ($t_{j,m}< t < t_{j,m+1}$). We have considered the beginning of the spike when $V_j>-20$mV. The value of the order parameter magnitude goes to 1 in a totally synchronised state. To study the neuronal synchronisation of the network, we have calculated the time-average order-parameter, that is given by \begin{equation} \overline{R}=\frac{1}{t_{\rm fin}-{t_{\rm ini}}}\sum_{t_{\rm ini}}^{t_{\rm fin}}R(t), \end{equation} where $t_{\rm fin}-t_{\rm ini}$ is the time window for calculating $\bar{R}$. Figs. \ref{fig4}a, \ref{fig4}b, and \ref{fig4}c show the raster plots for $g_{\rm ex}=0.02$nS, $g_{\rm ex}=0.19$nS, and $g_{\rm ex}=0.45$nS, respectively, considering $V_r=-58$mV, $p=0.5$, and $b=70$pA, where the dots correspond to the spiking activities generated by neurons. For $g_{\rm ex}=0.02$nS (Fig. \ref{fig4}a) the network displays a desynchonised state, and as a result, the order parameter values are very small (black line in Fig. \ref{fig4}d). Increasing the synaptic conductance for $g_{\rm ex}=0.19$nS, the neuronal network exhibits spike synchronisation (Fig. \ref{fig4}b) and the order parameter values are near unity (red line in Fig. \ref{fig4}d). When the network presents bursting synchronisation (Fig. \ref{fig4}c), the order parameter values vary between $R\approx 1$ and $R\ll 1$ (blue line in Fig. \ref{fig4}d). $R\ll 1$ to the time when the neuron are firing. \begin{figure}[hbt] \centering \includegraphics[height=11cm,width=10cm]{fig4.eps} \caption{(Colour online) Raster plot for (a) $g_{\rm ex}=0.02$nS, (b) $g_{\rm ex}=0.19$nS, and (c) $g_{\rm ex}=0.45$nS, considering $V_r = -58$mV, $p=0.5$, and $b=70$pA. In (d) the order parameter is computed for $g_{\rm ex}=0.02$nS (black line), $g_{\rm ex}=0.19$nS (red line), and $g_{\rm ex}=0.19$nS (blue line).} \label{fig4} \end{figure} In Fig. \ref{fig5}a we show ${\bar R}$ as a function of $g_{\rm ex}$ for $p=0.5$, $b=50$pA (black line), $b=60$pA (red line), and $b=70$pA (blue line). The three results exhibit strong synchronous behaviour (${\bar R}>0.9$) for many values of $g_{\rm ex}$ when $g_{\rm ex}\gtrsim 0.4$nS . However, for $g_{\rm ex}\lesssim 0.4$nS, it is possible to see synchronous behaviour only for $b=70$pA in the range $0.15{\rm nS}<g_{\rm ex}<0.25{\rm nS}$. In addition, we calculate the coefficient of variation (CV) to determine the range in $g_{\rm ex}$ where the neurons of the network have spiking or bursting behaviour (Fig. \ref{fig5}b). We consider that for CV$<0.5$ (black dashed line) the neurons exhibit spiking behaviour, while for CV$\geq 0.5$ the neurons present bursting behaviour. We observe that in the range $0.15{\rm nS}<g_{\rm ex}<0.25{\rm nS}$ for $b=70$pA there is spiking sychronisation, and bursting synchronisation for $g_{\rm ex}\gtrsim 0.4$nS. \begin{figure}[hbt] \centering \includegraphics[height=7cm,width=9cm]{fig5.eps} \caption{(Colour online) (a) Time-average order parameter and (b) CV for $V_r=-58$mV, $p=0.5$, $b=50$pA (black line), $b=60$pA (red line), and $b=70$pA (blue line).} \label{fig5} \end{figure} \section{Parameter space of synchronisation} The synchronous behaviour depends on the synaptic conductance and the probability of connections. Fig. \ref{fig6} exhibits the time-averaged order parameter in colour scale as a function of $g_{\rm ex}$ and $p$. We verify a large parameter region where spiking and bursting synchronisation is strong, characterised by ${\bar R}>0.9$. The regions I and II correspond to spiking and bursting patterns, respectively, and these regions are separated by a white line with circles. We obtain the regions by means of the coefficient of variation (CV). There is a transition between region I and region II, where neurons initially synchronous in the spike, loose spiking synchronicity to give place to a neuronal network with a regime of bursting synchronisation. \begin{figure}[hbt] \centering \includegraphics[height=6cm,width=9cm]{fig6.eps} \caption{(Colour online) $g_{\rm ex} \times p$ for $V_r=-58$mV and $b=70$pA, where the colour bar represents the time-average order parameter. The regions I (spike patterns) and II (bursting patterns) are separated by the white line with circles.} \label{fig6} \end{figure} We investigate the dependence of spiking and bursting synchronisation on the control parameters $b$ and $V_r$. To do that, we use the time average order parameter and the coefficient of variation. Figure \ref{fig7} shows that the spike patterns region (region I) decreases when $g_{\rm ex}$ increases. This way, the region I for $b<100$pA and $V_r=-49$mV of parameters leading to no synchronous behaviour (Fig. \ref{fig7}a), becomes a region of parameters that promote synchronised bursting (Fig. \ref{fig7}b and \ref{fig7}c). However, a large region of desynchronised bursting appears for $g_{\rm ex}=0.25$nS about $V_r=-45$mV and $b>100$pA in the region II (Fig. \ref{fig7}b). For $g_{\rm ex}=0.5$nS, we see, in Fig. \ref{fig7}c, three regions of desynchronous behaviour, one in the region I for $b<100$pA, other in region II for $b<200$pA, and another one is located around the border (white line with circles) between regions I and II for $b>200$pA. \begin{figure}[hbt] \centering \includegraphics[height=12cm,width=7cm]{fig7.eps} \caption{(Colour online) Parameter space $b \times V_r$ for $p=0.5$, $\gamma=0$ (a) $g_{\rm ex}=0.05$nS, (b) $g_{\rm ex}=0.25$nS, and (c) $g_{\rm ex}=0.5$nS, where the colour bar represents the time-average order parameter. The regions I (spike patterns) and II (bursting patterns) are separated by white circles.} \label{fig7} \end{figure} It has been found that external perturbations on neuronal networks not only can induce synchronous behaviour \cite{baptista06,zhang15}, but also can suppress synchronisation \cite{lameu16}. Aiming to study the robustness to perturbations of the synchronous behaviour, we consider an external perturbation $\Gamma_i$ (\ref{eqIFrede}). It is applied on each neuron $i$ with an average time interval of about $10$ms and with a constant intensity $\gamma$ during $1$ms. Figure \ref{fig8} shows the plots $g_{\rm ex} \times p$ for $\gamma>0$, where the regions I and II correspond to spiking and bursting patterns, respectively, separated by white line with circles, and the colour bar indicates the time-average order parameter values. In this Figure, we consider $V_r=-58$mV, $b=70$pA, (a) $\gamma=250$pA, (b) $\gamma=500$pA, and (c) $\gamma=1000$pA. For $\gamma=250$pA (Fig. \ref{fig8}a) the perturbation does not suppress spike synchronisation, whereas for $\gamma=500$pA the synchronisation is completely suppressed in region I (Fig. \ref{fig8}b). In Fig. \ref{fig8}c, we see that increasing further the constant intensity for $\gamma=1000$pA, the external perturbation suppresses also bursting synchronisation in region II. Therefore,the synchronous behavior in region II is more robustness to perturbations than in the region I, due to the fact that the region II is in a range with high $g_{\rm ex}$ and $p$ values, namely strong coupling and high connectivity. \begin{figure}[hbt] \centering \includegraphics[height=12cm,width=7cm]{fig8.eps} \caption{(Colour online) $g_{\rm ex} \times p$ for $V_r=-58$mV, $b=70$pA, (a) $\gamma=250$pA, (b) $\gamma=500$pA, and (c) $\gamma=1000$pA.} \label{fig8} \end{figure} In order to understand the perturbation effect on the spike and bursting patterns, we consider the same values of $g_{\rm ex}$ and $p$ as Fig. \ref{fig7}a. Figure \ref{fig9} exhibits the space parameter $b\times V_r$, where $\gamma$ is equal to $500$pA. The external perturbation suppresses synchronisation in the region I, whereas we observe synchronisation in region II. The synchronous behaviour in region II can be suppressed if the constant intensity $\gamma$ is increased. Therefore, bursting synchronisation is more robustness to perturbations than spike synchronisation. \begin{figure}[hbt] \centering \includegraphics[height=5cm,width=7cm]{fig9.eps} \caption{(Colour online) $b \times V_r$ for $g_{\rm ex}=0.05$nS, $p=0.5$, and $\gamma=500$pA, where the colour bar represents the time-average order parameter. The regions I (spike patterns) and II (bursting patterns) are separated by white line with circles.} \label{fig9} \end{figure} \section{Conclusion} In this paper, we studied the spiking and bursting synchronous behaviour in a random neuronal network where the local dynamics of the neurons is given by the adaptive exponential integrate-and-fire (aEIF) model. The aEIF model can exhibit different firing patterns, such as adaptation, tonic spiking, initial burst, regular bursting, and irregular bursting. In our network, the neurons are randomly connected according to a probability. The larger the probability of connection, and the strength of the synaptic connection, the more likely is to find bursting synchronisation. It is possible to suppress synchronous behaviour by means of an external perturbation. However, synchronous behaviour with higher values of $g_{\rm ex}$ and $p$, which typically promotes bursting synchronisation, are more robust to perturbations, then spike synchronous behaviour appearing for smaller values of these parameters. We concluded that bursting synchronisation provides a good environment to transmit information when neurons are stron\-gly perturbed (large $\Gamma$). \section*{Acknowledgements} This study was possible by partial financial support from the following Brazilian government agencies: CNPq, CAPES, and FAPESP (2011/19296-1 and 2015/07311-7). We also wish thank Newton Fund and COFAP.
{'timestamp': '2016-07-18T02:09:37', 'yymm': '1607', 'arxiv_id': '1607.04618', 'language': 'en', 'url': 'https://arxiv.org/abs/1607.04618'}
arxiv
\section{Introduction} To write high-quality program code for a Multi-Processor System-on-Chip (MPSoC), software developers must fully understand how their code will be executed on-chip. Debugging and tracing tools can help developers to gain this understanding. They are a keyhole through which developers can peek and observe the software execution. Today, and even more in the future, this keyhole narrows as MPSoCs integrate more functionalities, while at the same time the amount of software increases dramatically. Furthermore, concurrency and deep interaction of software with hardware components beyond the instruction set architecture (ISA) boundary are on the rise. Therefore more, not less, insight into the system is needed to keep up or even increase developer productivity. Many of today's MPSoCs are executing concurrent code on multiple cores, interact with the physical environment (cyber-physical systems), or must finish execution in a bounded amount of time (hard real-time). In these scenarios, a non-intrusive observation of the software execution is required, like it is provided by tracing. Instead of stopping the system for observation, as done in run-control debugging, the observed data is transferred off-chip for analysis. Unfortunately, observing a full system execution would generate data streams in the range of petabits per second~\cite[p.~16]{vermeulen_debugging_2014}. This is the most significant drawback of tracing: the system insight is limited by the off-chip bottleneck. Today's tracing systems, like ARM CoreSight~\cite{CoreSightWebsite} or NEXUS 5001~\cite{_nexus_2003} are designed to efficiently capture the operation of a functional unit (like a CPU) as compressed trace stream. With filters and triggers it is possible to configure which and when a functional unit is traced (observed). The trace streams (or short, traces) are then transported across an off-chip interface (and possibly other intermediate devices) to a host PC. Upon arrival the compressed trace streams are first decompressed (reconstructed) using the program binary and other static information which was removed before. The reconstructed trace streams are then fed to a data analysis application, which extracts information out of the data. This information can then be presented to a developer or it can be used by other tools, e.g. for runtime verification. \medskip The \textbf{main idea} in this work is to move the data analysis (at least partially) from the host PC into the chip. Bringing the computation closer to the data sources reduces the off-chip bandwidth requirements, and ultimately increases insight into software execution. To realize this idea, we introduce \emph{DiaSys}, a replacement for the tracing system in an MPSoC. DiaSys does not stream full execution traces off-chip for analysis. Instead, it first creates events from observations on the chip. Events can signal any interesting state change of the observed system, like the execution of a function in the program code, a change in interconnect load beyond a threshold, or the read of a data word from a certain memory address. A \emph{diagnosis application} then processes the observed events to give them ``meaning.'' Given an appropriate diagnosis application, a software developer might not be presented with any more a sequence of events like ``a read/write request was issued'', but with the more meaningful output of the diagnosis application ``a race condition bug was observed.'' Analyzing the data on-chip is not only beneficial to reduce the off-chip bandwidth requirements, but also enables new use cases in the future, such as self-adapting or self-healing systems. However, doing all this processing on-chip would, in some cases (and markets), be too costly in terms of chip area. Therefore, we describe the diagnosis applications so that they can be transparently split into multiple parts: one part executing on-chip in dedicated, distributed hardware components close to the data source, and another part running on a host PC. In summary, our \textbf{key contributions} are: \begin{itemize} \item an architecture and component library of on-chip infrastructure to collect and analyze diagnosis data created during the software execution, and \item a model of computation which allows developers to describe data analysis tasks (the ``diagnosis application'') in a way which is independent of the specific hardware implementation of the diagnosis system. \end{itemize} Combining these two contributions, we show that \begin{itemize} \item DiaSys is a viable alternative to tracing systems in the two major fields where tracing is employed today: hypothesis testing (debugging) and the collection of runtime statistics. Two case studies explore these use cases (Section~\ref{sec:usage}). \item the diagnosis applications introduced by DiaSys are a beneficial representation of a data analysis task: they abstract from the implementation through a clearly defined model of computation to foster re-use and portability (Section~\ref{sec:method:diagnosis_applications}). \item DiaSys is implementable in hardware with reasonable system cost (Section~\ref{sec:hwimpl}). \end{itemize} In the following, we explore our diagnosis system in depth. We start with a thorough analysis of the state of the art in tracing systems in Section~\ref{sec:related_work}, based on which we developed our concept of the diagnosis system presented in Section~\ref{sec:method}. We include a detailed model of a diagnosis application and a discussion of its semantics in Section~\ref{sec:method:diagnosis_applications}. The architecture of our diagnosis system is presented next in Section~\ref{sec:arch}, followed by a discussion of its possible limitations. In Section~\ref{sec:hwimpl} we present our hardware implementation. Combining all parts, we show two usage examples in Section~\ref{sec:usage}, one to find a multi-core race condition bug, and one to create an application profile. \paragraph{A word on terminology} We use the terms ``diagnosis'' and ``diagnosis system'' to stress the fact that we integrate the on-chip observation of the software execution with the data analysis. We use ``tracing'' to refer to the method of obtaining insight into the SoC by transferring a stream of observations from a functional unit off-chip. ``Debugging'' is used as a synonym for ``hypothesis testing,'' the process of (usually manually) checking (by various means) if the software behaves as expected. \section{Background and Related Work} \label{sec:related_work} Our approach touches and integrates two usually separated topics: obtaining a software execution trace from a SoC, and processing the obtained information in order to generate useful information. In this section we present background and related work on both topics. \subsection{Gaining Insight into SoCs} \label{sec:related_work:insight} \begin{figure} \centering \includesvgnolatex{img/diagnosis_applications_existing} \caption{A schematic view of a common tracing system like ARM CoreSight or NEXUS 5001.} \label{fig:diagnosis_applications_existing} \end{figure} Today's tracing solutions for SoCs are designed to capture and transfer as much as possible of the SoC's internal state to an external observer. They are generally structured as shown in Figure~\ref{fig:diagnosis_applications_existing}. First, trace data streams are obtained from the observation of various functional units in the system, like CPUs, buses and memories. Then, this data is spatially and temporally reduced through the use of filters and triggers. Finally, the redundancy in the data is removed by the use of compression algorithms. The resulting trace data stream is then transferred off-chip (live or delayed through an on-chip memory buffer). On a host PC, the original trace streams are reconstructed using information from the program binary and other static information, which was discarded as part of the compression process. All major commercial SoC vendors offer tracing solutions based on this template. ARM provides its licensees the CoreSight intellectual property (IP) blocks~\cite{CoreSightWebsite}. They are used in SoCs from Texas Instruments, Samsung and STMicroelectronics, among others. Vendors such as Qualcomm (formerly Freescale) include tracing solutions based on the IEEE-ISTO~5001 (Nexus) standard~\cite{_nexus_2003}, while Infineon integrates the Multi-Core Debug Solution (MCDS) into its automotive microcontrollers~\cite{ipextreme_infineon_2008}. Since 2015 Intel also includes a tracing solution in their desktop, server and embedded processors called Intel Processor Trace (PT)~\cite{_intel_2015}. The main differentiator between the solutions is the configurability of the filter and trigger blocks. Driven by the off-chip bottleneck, a major research focus are lossless trace compression schemes. Program trace compression available in commercial solutions typically requires 1 to 4~bit per executed instruction~\cite{hopkins_debug_2006, orme_debug_2008}, while solutions proposed in academia claim compression ratios down to $0.036$~bit per instruction~\cite{uzelac_real-time_2010}. Even though data traces contain in general no redundancy, in practice compression rates of about 4:1 have been achieved \cite{hopkins_debug_2006}. \subsection{Analyzing System Behavior} \label{sec:related_work:analysis} A human is easily overwhelmed when asked to analyze multiple gigabits of trace data each second. Instead, automated analysis tools are used to extract useful information out of the vast amount of trace data. Such tools have one common goal: to help a developer better understand the software execution on the target system. The means to achieve this goal, however, vary widely. Diagnosis applications which analyze non-functional issues such as performance bugs often generate results in the form of ordered lists. They list for example applications which consume most processing or memory resources, or which generate most I/O traffic. This report can then be a starting point for a more fine-grained analysis of the problem. Diagnosis applications which target functional bugs are usually more specialized; in many cases, a diagnosis application is created just to confirm or negate one single hypothesis about the software execution on the chip. For example, a developer might want to confirm that a certain variable stays within defined bounds, e.g. to check if an array overflow occurred. Most analysis tools for SoCs are not stand-alone applications, but part of debugging and tracing software packages from vendors like Lauterbach, Green Hills or ARM. They are usually controlled through a graphical user interface. Of course, analysis applications used to understand software execution are not only developed for SoCs and other embedded systems. Most tools in this domains are intrusive: they run as part of the analyzed system and obtain the required system state through instrumentation. However, the general concepts are also relevant for the diagnosis of SoCs. This is especially true for scriptable or programmable debugging, which applies the concept of event-driven programming to debugging. Whenever a defined \emph{probe point} is hit, an event is triggered and an \emph{event handler} executes. Common probe points are the execution of a specific part of the program (like entering a certain program function), or the access to a given memory location. The best-known current implementations of this concept are DTrace and SystemTap, which run on, or are part of, BSDs, Linux, and macOS (where DTrace is integrated into the ``Apple Instruments'' product) \cite{cantrill_dynamic_2004,eigler_architecture_2005}. The concept, however, is much older. Dalek~\cite{olsson_dataflow_1991} is built on top of the GNU Debugger (GDB) and uses a dataflow approach to combine events and generate higher-level events out of primitive events. Marceau et al. extend the dataflow approach and apply it to the debugging of Java applications~\cite{marceau_dataflow_2004}. Coca~\cite{ducasse_coca_1999}, on the other hand, uses a language based on Prolog to define conditional breakpoints as a sequence of events described through predicates for debugging C programs. In a work targeting early multi-processor systems, but otherwise closely related to our approach, Lumpp et. al. present a debugging system which is based on an event/action model~\cite{lumpp_specification_1990}. A specification language is used to describe events in the system trigger which an action, and hardware units can be used to identify these events. None of the presented works directly tackle the observability problem in SoCs by moving the data analysis partially on-chip. However, they form a strong foundation of ideas, which inspired us in the design of the diagnosis system. It is presented in the following sections. \section{DiaSys, Our Diagnosis System} \label{sec:method} We have designed our diagnosis system to address the shortcomings of today's tracing systems. Based on a set of requirements, we discuss the design of the diagnosis system in depth, followed by a hardware/software architecture implementing the diagnosis system. First, however, we define some terms used in the following discussion. \subsection{Definitions} \paragraph{Observed system} The part of the SoC which is observed or monitored by the diagnosis system. In other works, the term ``target system'' is used. \paragraph{Functional unit} A subset of the observed system which forms a logical unit to provide a certain functionality. Examples for functional units are CPUs, memories, or interconnect resources such as a bus or NoC routers. \paragraph{State} The state of a system is the unity of all stored information in that system at a given point in time which is necessary to explain its future behavior.~\cite[p.~103]{harris_digital_2012} In a sequential circuit, the state is equal to the memory contents of the system. \subsection{Design Requirements for the Diagnosis System} \label{sec:method:requirements} A set of requirements guides the design of the diagnosis system. \paragraph{Distributed} The diagnosis system must be able to reduce the amount of observation data as close to the source, i.e. the functional units, as possible. Since the data sources are distributed across the chip, the diagnosis system must also be distributed appropriately. \paragraph{Non-Intrusive} The diagnosis system must be non-intrusive (passive). Non-intrusive observation preserves the event ordering and temporal relationships in concurrent executions, a requirement for debugging multi-core, real-time, or cyber-physical systems~\cite{fidge_fundamentals_1996}. Non-intrusiveness also gives a developer the confidence that he or she is observing a bug in the program code, not chasing a problem caused by the observation (a phenomenon often called ``Heisenbug''~\cite{gray_why_1986}). \paragraph{Flexible On-Chip/Off-Chip Cost Split} The diagnosis system must be flexible to implement. The implementation of the diagnosis system involves a trade-off between the provided level of observability and the system cost. The two main cost contributions are the off-chip interface and the chip area spent on diagnosis extensions. The diagnosis system concept must be flexible enough to give the chip designer the freedom to configure the amount of chip resources, the off-chip bandwidth and the pin count in a way that fits the chip's target market. At the same time, to provide flexibility on the observation, the system must be able to adapt to a wide range of bugs. \paragraph{Relaxed Timing Constraints} The diagnosis system must not assume a defined timing relationship between the individual distributed components. Today's larger SoCs are designed as globally asynchronous, locally synchronous (GALS) systems with different power and clock domains, where no fixed time relationship between components can be given. \subsection{The Concept of the Diagnosis System} \label{sec:method:concept} \begin{figure} \centering \includesvgnolatex{img/diasys_model} \caption{A schematic view of the diagnosis system.} \label{fig:diasys_model} \end{figure} Based on the discussed requirements this section gives an overview on the diagnosis system as shown in Figure~\ref{fig:diasys_model}. The \textit{input} to the diagnosis system is the state of the observed system over time, the \textit{output} are the diagnosis results, which can be represented in various forms. With respect to the input and output interfaces, the diagnosis system is identical to a traditional tracing system. The difference lies in the components which generate the output from the input. Three main components are responsible for this processing: the event generators, the diagnosis application together with its execution platform, and the event sinks. Between these components, data is exchanged as diagnosis events. \textit{Diagnosis events are the container for data} exchanged in the diagnosis system. In the general case, an event consists of a type identifier and a payload. Events are self-contained, i.e. they can be decoded without the help from previous or subsequent events. \textit{Event generators produce} primary events based on state changes in the observed system. They continuously compare the state of the observed system with a \emph{trigger condition}. If this condition holds, they \emph{trigger} the generation of a primary event. A \emph{primary event} is a specialized diagnosis event in which the type identifier is equal to a unique identifier describing the event generator. The payload contains a partial snapshot of the state of the observed system at the same instant in time as the event was triggered. Which parts of the state are attached to the event is specified by the event generator. For example, a CPU event generator might produce primary events when it observes a function call and attach the current value of a CPU register as payload. A primary event answers two questions: why was the event generated, and in which state was the observed system at this moment in time. \textit{The diagnosis application analyzes} the software execution on the observed system. It is modeled as transformational dataflow application, which transforms primary events into output events. The goal of this transformation is to interpret the state changes represented in primary events in a way that yields useful information for a developer or an automated tool. We describe diagnosis applications in more detail in Section~\ref{sec:method:diagnosis_applications}. \textit{The diagnosis application execution platform} executes diagnosis applications. The execution platform can span (transparent to the diagnosis application developer) across the chip boundary. On the chip, it consists of specialized hardware blocks which are able to execute (parts of) the diagnosis application. On the host PC, a software runtime environment enables execution of the remaining parts of the diagnosis application. The on- and off-chip part of the execution platform are connected through the off-chip interface. This split design of the execution platform allows hardware designers to trade off chip area with the bandwidth provided for the off-chip interface, while retaining the same level of processing power, and in consequence, system observability. \textit{Event sinks consume} output events produced by the diagnosis application. Their purpose is to present the data either to a human user in a suitable form (e.g. as a simple log of events, or as visualization), or to format the events in a way that makes them suitable for consumption by an automated tool, or possibly even for usage by an on-chip component. An example usage scenario for an automated off-chip user is runtime validation, in which data collected during the runtime of the program is used to verify properties of the software. Together, event generators, the diagnosis application and the event sink build a processing chain which provides a powerful way to distill information out of observations in the SoC. \subsection{Diagnosis Applications} \label{sec:method:diagnosis_applications} Diagnosis applications are the heart of the diagnosis system, as they perform the ``actual work'' of interpreting what happens on the observed system during the software execution. Diagnosis applications are transformational dataflow applications. We chose this model to enable the transparent mapping of the diagnosis application to an execution platform spanning across the chip boundary. Our goal is that the developer of the diagnosis application does not need to explicitly partition the diagnosis application into an on-chip and an off-chip part; instead, this mapping could be performed in an automated way. (Currently, however, we do not perform an automated mapping.) No matter how the diagnosis application is mapped onto the execution platform, the behavior of the application follows identical rules, i.e. the semantics of the application stay the same. The diagnosis application is a \emph{transformational application}, in contrast to reactive or interactive applications~\cite{halbwachs_synchronous_1991}. This means, starting from a given set of inputs, the application \emph{eventually} produces an output. The application code only describes the functional relationship between the input and the output, not the timing when the output is generated. The application also does not influence or interact in another way with the observed system from which its inputs are derived. The diagnosis application is structured as \emph{dataflow application}. Its computation is represented by a directed graph, in which the nodes model the computation, and the edges model communication links. In diagnosis applications we call the graph nodes \emph{transformation actors}, and the graph edges \emph{channels}. \begin{figure} \centering \includesvgnolatex{img/transformation_actor} \caption{A transformation actor with $n=3$ input channels and $m = 2$ output channels.} \label{fig:transformation_actor} \end{figure} Each transformation actor reads events from $n \in \mathbb{N}_0$ input channels, and writes events to $m \in \mathbb{N}_0$ output channels, as shown in Figure~\ref{fig:transformation_actor}. A transformation actor starts its processing, it ``fires,'' if a \emph{sufficient} number of events are available at its inputs. The definition of ``sufficient'' depends on the individual transformation actor. For example, one transformation actor might always read one event from each input before starting the processing, while another one might always read two events from input 1 and one event from input 2. When firing, the transformation actor applies an arbitrary transformation function $f$ to the input events. The generated output depends on \begin{itemize} \item the read input events, \item the ordering of the input events, and \item the internal state of the transformation actor. \end{itemize} Transformation actors may communicate only through the input and output channels, but not through additional side channels (e.g. shared variables). Diagnosis applications built out of such transformation actors are \emph{nondeterministic}, as defined by Kahn~\cite{kahn_semantics_1974,lee_dataflow_1995}. This means, the output not only depends on the history of inputs (i.e. the current input and the state of the actor), but also on the relative timing (the ordering) of events. Nondeterministic behavior of diagnosis applications is, in most cases, the expected and wanted behavior; it gives its authors much needed flexibility. An example of nondeterministic diagnosis applications are applications which aggregate data over time, like the lock contention profiling presented in Section~\ref{sec:usage:lockprofiling}. These applications consume an unspecified amount of input events and store an aggregate of these inputs. After a certain amount of time, they send a summary of the observations to an output channel. But at the same time, nondeterministic diagnosis applications prevent the static analysis of event rates, bandwidth and processing requirements. If wanted, application authors can therefore create deterministic diagnosis applications, if they restrict themselves to \begin{itemize} \item always reading the input channels in the same order without testing for data availability first (instead, block and wait until the data arrives), \item connecting one channel to exactly one input and one output of an actor, and \item using only transformation functions which are deterministic themselves. \end{itemize} Note that we only describe the diagnosis application itself as nondeterministic. Its execution, after being mapped to an execution platform, can be deterministic, i.e. multiple identical runs produce the same diagnosis result. \subsection{Diagnosis System Architecture} \label{sec:arch} \begin{figure} \includesvgnolatex{img/diasys_hwarch} \caption{The architecture of our diagnosis system implementation. Event generators (EG) observe the functional units (FU). They connect via an interconnect to different processing nodes (PN) and an off-chip interface. On a host PC processing nodes implemented in software further process the events. Finally, event sinks prepare the data for developers or automation. A diagnosis application can be mapped flexibly on the execution platform; a sample mapping is shown.} \label{fig:diasys_hwarch} \end{figure} In the previous sections we presented the diagnosis system from a functional perspective. We continue now by presenting an implementation architecture of the diagnosis system. It consists of extensions to the SoC, as well as software on a host PC; an exemplary architecture is shown in Figure~\ref{fig:diasys_hwarch}. In the SoC, different functional units (FU) can be observed, like a CPU, a memory, or a bus. Each functional unit can be attached to one or multiple event generators (EG). The resulting events are transmitted over a diagnosis interconnect to on-chip processing nodes. The processing nodes form the execution platform for the diagnosis application; they will be discussed in depth in Section~\ref{sec:arch:execution_platform}. Invisible to the diagnosis application, the execution platform spans across the chip boundary. Through an I/O interface, a host PC is connected to the SoC. The PC contains a software runtime environment to provide further processing nodes as part of the diagnosis application execution platform. If all processing has been accomplished, the output events are sent to an event sink application on the host PC, which formats the output events for developers or automation. Depending on the features and computational power provided by the processing nodes, a diagnosis application can be mapped to the execution platform in a flexible way. \subsection{Diagnosis Application Execution Platform} \label{sec:arch:execution_platform} The heart of the diagnosis system are the diagnosis applications, which are executed on the diagnosis application execution platform. As discussed before, this platform spans across the SoC and the host PC. On the SoC, it consists of processing nodes of different types which are connected by a shared interconnect (such as a NoC or a bus). Each processing node has an input and output interface to receive and send out events on the interconnect. Different types of processing nodes can offer different degrees of flexibility regarding their computation. Some might be able to perform only a single functionality specified at hardware design time, like a counter or a statistical aggregator, while others might be freely programmable. As an example, we present in Section~\ref{sec:arch:diagnosis_processor} the Diagnosis Processor, a programmable general-purpose processing node. As the chip area (economically) available for on-chip diagnosis processing is limited, the diagnosis application execution platform extends to the host PC. Connected through an arbitrary off-chip interface, a runtime layer in software provides a virtually unlimited number of ``soft'' processing nodes. Such PNs are implemented in software on the host PC and accept, like their on-chip counterpart, events as input and produce events as output. By being executed on a host PC, they provide more compute and memory resources. \medskip The transformation or computation in a diagnosis application is represented by transformation actors. For execution, they are mapped to the available processing nodes, as shown exemplary in Figure~\ref{fig:diasys_hwarch}. An $n$:1 mapping of transformation actors to processing nodes is possible, if the combined transformation of all $n$ transformation actors can be executed by the processing node. To achieve the greatest possible reduction in off-chip traffic, as much computation as possible should be mapped to on-chip processing nodes. The remainder of processing is then mapped to processing nodes on a host PC, where significantly more processing power is available. \subsubsection{The Diagnosis Processor: A Multi-Purpose Processing Node} \label{sec:arch:diagnosis_processor} The diagnosis processor is a freely programmable general-purpose processing node. Like any processor design, it sacrifices computational density for flexibility. Its design is inspired by existing scriptable debugging solutions, like SystemTap or DTrace, which have shown to provide a very useful tool for software developers in a growingly complex execution environment. The usage scenario for this processing node are custom or one-off data analysis tasks. This scenario is very common when searching for a bug in software. First, a hypothesis is formed by the developer why a problem might have occurred. Then, this hypothesis must be validated in the running system. For this validation, a custom data analysis script must be written, which is highly specific to the problem (or the system state is manually inspected). This process is repeated multiple times, until the root cause of the problem is found. As this process is approached differently by every developer (and often also influenced by experience and luck), a very flexible processing node is required. We present the hardware design of our diagnosis processor implementation in Section~\ref{sec:hwimpl:diagnosis_processor}. We envision the programming of the diagnosis processor being done through scripts similar to the ones used by SystemTap or DTrace. They allow to write trace analysis tasks on a similar level of abstraction as the analyzed software itself, leading to good developer productivity. \subsection{Discussion} The presented diagnosis system is designed to fulfill the requirements outlined in Section~\ref{sec:method:requirements}. In the following, we discuss the consequences of the design decisions, which can limit the applicability of the diagnosis system approach in some cases. By transforming the observed system state close to the source into denser information, the off-chip bottleneck can be circumvented. As a downside, this lossy transformation thwarts a usage scenario of today's tracing systems. In many of these systems, it is possible to capture a trace once, store it, and run different analysis tasks on it. If major parts of the captured data are dismissed early, this is not possible any more. Instead, the analysis task must be defined (as diagnosis application) before the system is run. If the problem hypothesis changes and a different diagnosis application is required, the system must be run again. The severity of this limitation strongly depends on how hard it is to reproduce a bug or behavior across runs. Another feature present in many of today's tracing systems, which is explicitly not supported by the diagnosis system, are cross-triggers. Cross-triggers are a mechanism in the tracing system to start or stop the observation, or to observe different components, based on another observation in the system. For example, memory accesses could be traced only after a CPU executed a certain program counter. Cross-triggers are most useful if their timing behavior is predictable. For example, memory accesses are traced ``in the next cycle'' after the specified program counter was executed. In GALS SoCs, such timing guarantees cannot be given; for a diagnosis application spanning across a SoC and a host PC, it is equally impossible to give (reasonably low bounded) timing guarantees. We make this property explicit by modeling the diagnosis system as a transformational system, not a reactive system. The commercially available tracing systems today are less specific about this. For example, ARM CoreSight uses a handshaking protocol for cross-triggers delivered across clock boundaries, which guarantees save delivery of the signal, but does not guarantee any latency. Instead of relying on cross-triggers to collect data from different sources at the same instant in time, we capture this data already when creating primary events through event generators. The payload of primary events is the only way to pass multiple state observations with a defined timing relation to the diagnosis system. For example, an event generator attached to a CPU can trigger an event based on a program counter value, and attach current contents of certain CPU registers or stack contents to it. Using this method, it is possible to generate for example an event which informs about a function being called, and which function arguments (stored in CPU registers or on the stack) have been passed to it. We show an example of such an event generator as part of our hardware implementation. Finally, we discuss the system behavior in overload situations, i.e. if more input data is received than the diagnosis system can process. Given the generally unknown input data, and the generally nondeterministic behavior of the diagnosis application, it is not possible to statically dimension the diagnosis system to be able to handle all possible input sequences. Therefore, overload situations are unavoidable in the general (and most common) case. If an overload situation is detected, the diagnosis system can react in multiple ways. First, it could temporarily stall the observed system. This gives the diagnosis system time to process outstanding events without new events being produced. This approach is only feasible in a synchronous non-realtime system. A more common approach is to discard incoming data until further processing resources are available. Depending on the diagnosis application, a recovery strategy needs to be formulated. Some applications can deal easily with incomplete input data, e.g. diagnosis applications creating statistics. Others are not able to work with an incomplete input sequence and in consequence fail to be executed properly. \medskip This ends the discussion of DiaSys in general. In the following, we present a hardware implementation of our approach, and then continue then with two usage examples how DiaSys can be put to work. \section{Implementing DiaSys in Hardware} \label{sec:hwimpl} \begin{figure} \centering \scriptsize \includesvgnolatex{img/prototype_sys} \caption{Block diagram of the prototype implementation. The diagnosis extensions added to the $2\times2$ multi-core system are drawn in blue.} \label{fig:prototype_sys} \end{figure} DiaSys, as presented in the previous section, can be implemented in various ways in hardware. Our implementation, which we present in the following, is one such implementation. It was created to answer two questions: first, to show that DiaSys can be implemented in hardware, and second, to give resource usage numbers for one specific implementation. As dimensioning and optimization for speed or area usage strongly depends on how DiaSys is used, a general answer to this question must remain out of scope for this work. \medskip The diagnosis system extends a $2 \times 2$ tiled multi-core system as shown in Figure~\ref{fig:prototype_sys}. Our implementation runs on an FPGA and uses the OpTiMSoC framework~\cite{wallentowitz_open_2013}. The observed system consists of four mor1kx CPU cores (an implementation of the OR1K or ``OpenRISC'' ISA), each connected to a distributed memory and a mesh NoC interconnect (components with white background). This system is representative of the multi- and many-core architecture template currently in research and available early products, such as the Intel SCC or the Mellanox (formerly Tilera and EZchip) Tile processors. The diagnosis system, depicted in blue, consists of the following components. \begin{itemize} \item Four event generators attached to the CPUs (marked ``EG''). \item A single diagnosis processor. \item A 16~bit wide, unidirectional ring NoC, the ``diagnosis NoC,'' to connect the components of the diagnosis system. It carries both the event packets as well as the configuration and control information for the event generators and processing nodes. \item A USB~2.0 off-chip interface. \item Software support on the host PC to control the diagnosis system, and to display the results. \end{itemize} All components connected to the diagnosis NoC follow a common template to increase reusability. Common parts are the NoC interface and a configuration module, which exposes readable and writable configuration registers over the NoC. In the following, we explain the implementation of the main components in detail. \subsection{CPU Event Generator} \label{sec:hwimpl:implementation:eventgen_cpu} \begin{figure} \centering \scriptsize \includesvgnolatex{img/eventgen_cpu} \caption{Block diagram of the CPU event generator.} \label{fig:eventgen_cpu} \end{figure} The CPU event generator is attached to a single CPU core. Its main functionality is implemented in the trigger and the state capture modules. The trigger unit of the CPU event generator triggers on two types of conditions: either the value of the program counter (PC), or the return from a function call (the jump back to the caller). At each point in time, 12 independent trigger conditions can be monitored. The number of monitored trigger conditions is proportional to the used hardware resources. Our dimensioning was determined by statistical analysis of large collections of SystemTap and DTrace scripts: $\leq 9$ concurrent probes are used in 95~\% of SystemTap scripts, and $\leq 12$ concurrent probes cover 92~\% of the DTrace scripts. The partial system state snapshot can be configured to contain the CPU register contents and the function arguments passed to the function. A block diagram of the CPU event generator is shown in Figure~\ref{fig:eventgen_cpu}. The PC trigger is implemented as simple comparator. The ``function return'' trigger requires a special implementation, because no unique point in the program flow, i.e. no single PC value, describes the return from a function (a function can have multiple call sites and can return to the caller from different points in the function body). Instead, we use the following method: \begin{enumerate} \item A PC trigger is set to the first instruction of the called function. \item If the trigger fires, the link (a.k.a. return) address is pushed to a memory structure inside the return monitor, the ``return address stack.'' The link address is the program counter to jump to if the function has finished its execution and the execution returns to the caller. On OR1K (as common on RISC architectures, including ARM and MIPS) the link address is stored in a CPU register. On other architectures and calling conventions (such as x86 and x86\_64), the link address is pushed to the stack. \item Now the system monitors the program flow for the topmost PC value in the return address stack. If this PC is executed, a function returned to its caller and the function return monitor triggers the generation of a primary event. \end{enumerate} To capture the values inside CPU registers, the register writeback signal of the mor1kx CPU is observed, and a copy of the register file is created. This copy can then be included in the event packet if a trigger fires. The passing of function arguments to functions depends on the calling convention. On OR1K, the first six data words passed to a function are available in CPU registers, all other arguments are pushed to the stack before calling the function. This is common for RISC architectures; other architectures and calling conventions might pass almost all arguments on the stack (such as x86). To record the function arguments as part of the primary event we therefore need to create a copy of the stack memory that can be accessed non-intrusively. We do this by observing CPU writes to the stack memory location. In our implementation for the mor1kx CPU we create a copy of the stack memory by monitoring the instruction stream for a store word (\texttt{l.sw}) instruction with a target address \texttt{rA} equal to the stack pointer \texttt{R1}. The data in the source register \texttt{(rB)}, together with a write offset \texttt{I} (with $\texttt{I} \geq 0$, i.e. targeting the previous stack frame) can be then used to recreate the stack frame.% \footnote{In theory, data can be written to the stack in a different way. However, the described way is common across compilers and used by the default GCC compiler for OR1K.} \subsection{Diagnosis Processor} \label{sec:hwimpl:diagnosis_processor} \begin{figure} \centering \includesvgnolatex{img/dbg_coprocessor} \caption{Block diagram of the diagnosis processor, a freely programmable processing node.} \label{fig:diagnosis_processor} \end{figure} The diagnosis processor design is extended from a standard processor template like it is used in the observed system. The main components, shown in Figure~\ref{fig:diagnosis_processor}, are a single mor1kx CPU core and an SRAM block as program and data memory. This system is extended with components to reduce the runtime overhead of processing event packets. First, the network adapter, which connects the CPU to the diagnosis NoC, directly stores the incoming event packets in the memory through a DMA engine. All event packets are processed in a run-to-completion fashion. We can therefore avoid interrupting the CPU and instead store the address of the event to be processed next in a hardware ``run queue.'' A ``discard queue'' signals the hardware scheduler which events have been processed and can be purged from memory. \subsection{Resource Usage} \begin{table} \centering \footnotesize \begin{tabulary}{\linewidth}{lLrrr} \toprule \multicolumn{2}{l}{\textbf{Module}} &\textbf{LUTS} & \textbf{REGS} & \textbf{RAMS}\\ \midrule \multicolumn{2}{l}{observed system} & 40625 & 29638 & 80 \\ & 1 compute tile (system contains 4)& $\sim 7232$ & $\sim$ 4763 & 20\\ & $2\times2$ mesh NoC & 10791 & 9964 & 0\\ & support infrastructure (DRAM if, clock/reset mgr) & 904 & 623 & 0\\ \midrule \multicolumn{2}{l}{diagnosis extensions} & 19556 & 19140 & 147\\ & 1 CPU Event Generator (fully featured)& 3603 & 6521 & 2 \\ & 1 CPU Event Generator (reduced CoreSight-like functionality) & 1365 & 1594 & 0 \\ & 1 Diagnosis Processor & 8614 & 4549 & 145\\ & diagnosis NoC & 2520 & 2926 & 0\\ \bottomrule \end{tabulary} \medskip \caption{The resource usage of a CPU diagnosis unit. Either the fully-featured or the reduced-functionality CPU Event Generator can be used.} \label{tab:resourceusage} \end{table} The prototype of the tiled MPSoC with the diagnosis extensions was synthesized for a ZTEX~1.15d board with a Xilinx Spartan-6 XC6SLX150 FPGA. The relevant hardware utilization numbers as obtained from a Synplify Premier FPGA synthesis are given in Table~\ref{tab:resourceusage}. The functional system, even though it consists of four CPU cores, is relatively small, as the used mor1kx CPU cores are lightweight (comparable to small ARM Cortex M cores). The functional system contains no memory, but uses an external DDR memory. In this scenario, the full diagnosis system is rather large. We have implemented two types of CPU event generators. A ``lite'' variant of the event generator can trigger only on a program counter value, and not on the return from a function call. This reduced functionality makes the event generator comparable to the feature set of the ARM CoreSight ETM trace unit, which is said to use $\sim$~7,000 NAND gate equivalents~\cite{orme_debug_2008}, making it similarly sized as our event generator. The possibility to trigger also on the return from a function call significantly increases the size of the event generator, mostly due to additional memory. The diagnosis processor is about 20~percent larger than a regular compute tile, as it contains an additional DMA engine and the packet queues. It also contains 30~kByte of SRAM as program and data memory, which is not present in a regular compute tile. In summary, the resource usage of the diagnosis system is acceptable, especially if used in larger functional systems with more powerful CPU cores. At the same time, the implementation still contains many opportunities for optimization, which we plan to explore in the future. Also, a full system optimization to determine a suitable number of diagnosis processors and other processing nodes for a given number of CPU cores is future work. \section{Usage Examples} \label{sec:usage} We designed DiaSys as general-purpose approach to gain insight into SoCs, similar to today's tracing systems. Unfortunately, no benchmarks exist to evaluate such systems in a standardized way. We therefore rely on two spotlight usage examples to highlight important aspects of our approach. The first example is a hypothesis testing or ``debugging'' scenario which could also be performed using a trace-based debugger. We included this example as a demonstration of the flexibility of our approach: the process of debugging is usually a one-time effort, and the debugger is used as a tool to observe the program execution at various places in order to validate an hypothesis in a developer's head. In the second example we show how to create a lock contention profile with DiaSys. This example is taken from the area of runtime analysis, the other major area in which tracing is employed today. While the analysis tasks in this area are more standardized (thus need a less flexible diagnosis system), they usually require the long-time observation of the whole program execution, therefore producing large data rates in todays implementations. The creation of a lock contention profile therefore serves as a good example for the data reduction capabilities of DiaSys. \subsection{Hypothesis Testing: Finding a Race Condition} \label{sec:usage:racecondition} Hypothesis testing, or simply ``debugging,'' is the most common scenario in which software developers need to get insight into the software execution. While in many cases an intrusive debugging tool is sufficient, the more tricky bugs are related to timing, and thus require non-intrusive system insight. Today, developers use trace-based debugging for this task. In this example we show that DiaSys is equally suitable for such a scenario. In the following we discuss the debugging of a race condition which occurs in an application distributed over three compute tiles. We implement this example on our hardware implementation of DiaSys, as discussed in Section~\ref{sec:hwimpl}. \subsubsection{Problem Description} The application in this usage example consists of three tasks, running on three different processors concurrently. Core 0 runs the task \texttt{bank}, which is holds a variable \texttt{balance}. The other two cores 1 and 2 run the tasks \texttt{atm0} and \texttt{atm1}, respectively. All communication is handled through message passing. A message \texttt{get\_balance} reads the value of \texttt{balance} from core 0, and \texttt{set\_balance} writes it back. The tasks \texttt{atm0} and \texttt{atm1} periodically wait for a random amount of time, then get \texttt{balance}, decrement it by 1, and write it back. When running the application, we notice that sometimes $n$ calls to \texttt{set\_balance} do not, as expected, decrement \texttt{balance} by $n$, but by $m < n$. \subsubsection{Debugging Approach I: Observe exchanged messages} \begin{figure} \footnotesize \begin{sequencediagram} \newthread{atm1}{:atm0 (core 1)} \newinst[1.5]{bank}{:bank (core 0)} \newinst[1.5]{atm2}{:atm1 (core 2)} \stepcounter{threadnum} \node[below of=inst\theinstnum,node distance=0.8cm] (thread\thethreadnum) {}; \tikzstyle{threadcolor\thethreadnum}=[fill=gray!30] \tikzstyle{instcoloratm2}=[fill=gray!30] \begin{call}{atm1}{\shortstack{get\_balance\_req}}{bank}{\shortstack{get\_balance\_resp}} \end{call} \begin{call}{atm2}{\shortstack{get\_balance\_req}}{bank}{\shortstack{get\_balance\_resp}} \end{call} \begin{messcall}{atm1}{\shortstack{set\_balance}}{bank} \end{messcall} \begin{messcall}{atm2}{\shortstack{set\_balance}}{bank} \end{messcall} \end{sequencediagram} \caption{Sequence diagram showing the race condition in the first case study.} \label{fig:evaluation:racecondition_msc} \end{figure} Initially, we don't know where the problem is located. However, we assume that something in the exchange of messages goes wrong. We therefore use DiaSys to print out all incoming and outgoing messages at task \texttt{bank} for manual analysis. We start by configuring the CPU event generator at core 0 (running the task \texttt{bank}) to generate types of primary events: \begin{enumerate} \item One event if the message passing send function is called. As payload we capture the identifier of the destination core and the type of the message (e.g. \texttt{get\_balance\_resp}) \item Another event if the message passing receive function is called. As payload we capture the identifier of the source core and the type of the message. \end{enumerate} To create an event log, all events are sent directly to the host PC, where they are displayed to the developer in the form of a text log. For the purpose of easier understanding in this paper, Figure~\ref{fig:evaluation:racecondition_msc} presents the interesting section of this text log in the form of a sequence diagram. Looking at this diagram, experienced developers will notice the bug: two read-modify-write sequences are interleaved, causing the value written by \texttt{atm0} to be overwritten by \texttt{atm1}. Such behavior is a textbook example of a race condition. \subsubsection{Debugging Approach II: Transaction checking} The first debugging approach used DiaSys only to gather data, not to analyze it. The less often the race condition occurs, the more trace data is generated in the first approach, which must be transferred and manually checked. In our second approach, we also automate this checking. As result, the developer is only informed if an actual race condition occurred. In the correct scenario, the sequence of getting the balance, modifying it, and writing it back is an atomic transaction. We therefore form the hypothesis ``the read-modify-write sequence is atomic,'' and use DiaSys to check it. If the hypothesis does not hold, we have found a race condition. We first configure the event generator at core 0 (running the task \texttt{bank}) to create two primary events: \begin{itemize} \item An event \texttt{EV\_GET\_BALANCE\_CALL} when entering the function \texttt{get\_balance()} on core 0. This function is called if a \texttt{get\_balance\_req} message is received. \item Another event \texttt{EV\_SET\_BALANCE\_RETURN} when returning from the function \texttt{set\_balance()}. This function returns when the \texttt{set\_balance} message has been fully processed. \end{itemize} For both events, the source of the message (i.e. \texttt{atm0} or \texttt{atm1}) is included as payload. Furthermore, we program the diagnosis processor to execute a transformation actor shown in pseudo code in Listing~\ref{lst:tn_check_transaction}. (In our hardware implementation, we programmed the diagnosis processor in C with an equivalent program.) \begin{lstlisting}[label=lst:tn_check_transaction, caption={Pseudo code of the transformation actor checking the balance updating transaction.},float] TA_CHECK_BALANCE_TRANS { bool in_transaction = false; bool transaction_owner = NULL; event = wait(EV_GET_BALANCE_CALL or EV_SET_BALANCE_RETURN); // get_balance(src) and set_balance(src) // are both passed the source of the request // message as first function argument msg_src = event.data.args['src']; if (in_transacation && transaction_owner != msg_src) { // race condition found event_type = EV_RACE_DETECTED; event_data = {}; return new Event(event_type, event_data); } if (event.type == EV_GET_BALANCE_CALL) { // start of new transaction in_transacation = true; transaction_owner = msg_src; return; } if (event.type == EV_SET_BALANCE_RETURN && in_transacation && transaction_owner != msg_src) { // race condition found event_type = EV_RACE_DETECTED; event_data = {}; return new Event(event_type, event_data); } } \end{lstlisting} The two primary events are now routed from core 0 to the diagnosis processor, which checks the hypothesis that all transactions are atomic. If a violation, i.e. a race condition, is found, a new event \texttt{EV\_RACE\_DETECTED} is generated. This event is sent to the host PC and displayed as an event log to the developer. \subsubsection{Event and Data Rates} The most significant benefit from automating the hypothesis checking, as shown in the previous section, is the increase in productivity for the developer: even in long-running programs, testing the hypothesis becomes straightforward. At the same time, the automation also reduces the required trace bandwidth. The first approach of creating events for all received and transmitted messages for manual inspection required a trace bandwidth of 57.09~KBit/s. When automating the checking in the second approach, the bandwidth was reduced to 5.66~KBit/s, a reduction by $10.1\times$. The bandwidth requirements are heavily dependent on the program characteristics. In the program executions on our hardware platform running at 50~MHz, we observed 44~\% of transactions were interleaved, i.e. a race condition. Doing the same analysis in a tracing system would require an instruction and a data trace to be captured. Even though our evaluation platform is not able to produce such traces, we can estimate the required trace bandwidth by measuring the number of executed instructions and data memory accesses. Assuming an instruction trace compressed to 2~bit/instruction and a data trace compressed to 16 bit/access (for data and address, following \cite{hopkins_debug_2006}), we get a total trace stream of 246.31~MBit/s. It must be noted, however, that this number is an upper bound on the required bandwidth for a tracing system. Depending on the used tracing system implementation (such as CoreSight), not a full instruction or data trace is captured, but filters and triggers can be used to reduce this stream to just relevant parts, similar to what our event generators do. \subsubsection{Outlook: Programming DiaSys} In our first case study, we have shown how to use DiaSys to obtain data for manual analysis from the SoC, and how to automate the manual checking as hypothesis test running on-chip on the diagnosis processor. In this example, we wrote the transformation actor manually as C program, which is called upon receiving events. In the future, we envision also other means to describe the diagnosis application executed by DiaSys. In this example, a description of the desired system behavior as linear temporal logic (LTL) expression could be applied, as it commonly done in runtime validation systems. Using such LTL expressions for the validation of the correct hardware configuration by the software has been presented in \cite{li_rule-based_2016}. \subsection{Runtime Analysis: Creating a Lock Contention Profile} \label{sec:usage:lockprofiling} In our second usage example, we present a diagnosis application which generates a ``profile,'' a statistic about some software behavior. Examples for such commonly used profiles are the various \texttt{*top} Linux commands which present an ordered list of processes or threads with the highest usage of CPU, I/O, memory, or other resources. We include this usage example as it represents, next to debugging, the second large motivation to use a tracing tool today: runtime analysis. Other examples from this category of applications are code coverage and runtime profiling. Most runtime analysis tasks today require a full (instruction) trace to be recorded, which requires a high off-chip bandwidth. Using DiaSys, we can show how this trace bandwidth can be reduced by on-chip processing. To give meaningful insight into data rates generated when analyzing large real-life applications, we use in this example not a self-created example application, but an application from the PARSEC benchmark suite. \subsubsection{Evaluation Prototype} \label{sec:usage:lockprofiling:software_prototype} \begin{figure} \includesvgnolatex{img/software_prototype} \caption{The software prototype of the diagnosis system. All calls in the observed application are recorded in an event log file by an preloaded library. The event log file is read by the diagnosis system implemented as Python application. The figure shows the monitoring of all \texttt{pthread\_mutex\_lock()} calls and returns as used by the usage example in Section~\ref{sec:usage:lockprofiling}.} \label{fig:software_prototype} \end{figure} The hardware implementation prototype of DiaSys presented in Section~\ref{sec:hwimpl} is only able to run a very limited set of applications, as it only provides bare-metal programming support (comparable to a microcontroller without operating system), and no full POSIX environment as it can be found on Linux for example. To run larger applications, such as standard benchmarks, we therefore created a software prototype of the diagnosis system. It runs purely in software on a Linux PC and is best suited for an evaluation of event rates inside the diagnosis system, as well as the design of new diagnosis applications. Since no hardware extensions are used, its operation is intrusive, i.e. the timing of the observed application is slightly changed. The prototypical event generators can only trigger on the call of and return from a C library function, and the function arguments can be included in the event as data items. The software prototype consists of two parts, which are shown in Figure~\ref{fig:software_prototype}. The first part is a ``preload library.'' It is a small software library written in C which is able to monitor all calls to C library functions and write them into an event log file. This event log file is then used by a prototype of the diagnosis system implemented in Python. It consists of event generators, which read the event log file. A set of Python functions connected by channel objects represent the transformation actors. (We assume a one-to-one mapping of transformation actors to processing nodes in this prototype.) The output of the diagnosis application is directly printed to a console, as specialized event sinks are not necessary for our evaluations. We now use this software prototype to create the lock contention profile. \subsubsection{Problem Description} A \emph{lock contention} occurs in concurrent programs if multiple threads try to acquire a mutex lock at the same time~\cite[p. 147]{herlihy_art_2008}. In this case, all but one threads have to wait for the lock to be released before they can continue processing. Therefore, the lock acquisition time is a good metric for program efficiency: the less time it takes, the earlier the thread is done with its work. In order for a developer to get insight into the lock contention behavior of the program, a contention profile can be created. It lists all acquired locks, together with the summarized and averaged times the acquisition took. Such a profile can be generated in an intrusive way with tools like Intel VTune Amplifier or mutrace\footnote{\url{http://0pointer.de/blog/projects/mutrace.html}}, and is traditionally formatted as shown in Listing~\ref{lst:lockprofile_output}. \subsubsection{Measurement Approach} The lock acquisition time can be measured by obtaining the time the mutex lock function took to execute. In applications using pthreads, as it is the case for almost all applications running on Linux, macOS or BSD, the mutex lock function is named \verb|pthread_mutex_lock()|. \begin{lstlisting}[label=lst:mutex_lock, caption={A sketch of the \texttt{pthread\_mutex\_lock()} function. This function must be executed atomically, i.e. without interruption.}] int pthread_mutex_lock(pthread_mutex_t *mutex) { blocking_wait_until_mutex_is_free(mutex); lock_mutex(mutex); return 0 /* success */; } \end{lstlisting} As shown in the simplified code sketch in Listing~\ref{lst:mutex_lock}, the function blocks for an indefinite amount of time until a lock is available. If it is available, it acquires the lock and returns. To create a lock contention profile, we need to measure the execution times of all \verb|pthread_mutex_lock()| function calls in all threads. We then group this measurement by lock, given by the argument \verb|mutex| of the lock function, to obtain the number of times a lock was acquired, how long all lock acquisitions took in summary, and on average. \subsubsection{Diagnosis Application} \begin{figure} \includesvgnolatex{img/evaluation_lockprofile_appmodel} \caption{A diagnosis application to create a lock contention profile.} \label{fig:evaluation_lockprofile_appmodel} \end{figure} To perform the analysis outlined in the previous section, we configure the diagnosis system as shown in Figure~\ref{fig:evaluation_lockprofile_appmodel}. First, we attach two event generators to each CPU in the observed system. We configure them to generate two primary events which together measure the execution time of the lock acquisition function \texttt{pthread\_mutex\_lock()}. \begin{itemize} \item One primary event \texttt{EV\_LOCK\_CALL} is triggered if the CPU \emph{enters (calls)} the \texttt{pthread\_mutex\_lock()} function. The first function argument to \texttt{pthread\_\-mutex\_\-lock}, the \texttt{mutex}, is attached to the event as data item, together with a timestamp containing the current time. \item Another primary event \texttt{EV\_LOCK\_RETURN} is triggered if the CPU \emph{returns} from the \texttt{pthread\_mutex\_lock()} function. For this event, only a timestamp is attached as event data. \end{itemize} To calculate the execution time of the function \texttt{pthread\_\-mutex\_\-lock()}, we create a transformation actor \texttt{TA\_DIFF}, the pseudo code of which is shown in Listing~\ref{lst:tn_time_diff}. \begin{lstlisting}[label=lst:tn_time_diff, caption={Pseudo code of the transformation actor calculating the lock acquisition time.},float] TA_DIFF { lock_call = wait(EV_LOCK_CALL); lock_return = wait(EV_LOCK_RETURN); uint16_t time = lock_return.data.timestamp - lock_call.data.timestamp; uint16_t mutex_hash = hash(lock_call.data.args['mutex']); event_type = lock_acq_time; event_data = { time: time, lock: mutex_hash }; return new Event(event_type, event_data); } \end{lstlisting} It waits for both primary events \texttt{EV\_\-LOCK\_\-CALL} and \texttt{EV\_\-LOCK\_\-RETURN}, calculates the difference between the timestamps, and creates a new event \texttt{EV\_LOCK\_ACQ\_TIME} with two data items, the lock acquisition time and a hash of the \texttt{mutex} argument to reduce the data size. As last step in the processing, all \texttt{EV\_LOCK\_ACQ\_TIME} events are aggregated by another transformation actor called \texttt{TA\_STAT}. Again, a pseudo code implementation is given in Listing~\ref{lst:tn_stat}. \begin{lstlisting}[label=lst:tn_stat, caption={Pseudo code showing the functionality of the transformation actor creating a lock profile.},float] TA_STAT { event = wait(EV_LOCK_ACQ_TIME or EV_SEND_LOCK_PROFILE); // aggregate if (event.type == EV_LOCK_ACQ_TIME) { m = event.data.mutex; stat[m]['cnt']++; stat[m]['t_sum'] += event.data.time; return; } // send statistics output to host PC if (event.type == EV_SEND_LOCK_PROFILE) { event_type = EV_LOCK_PROFILE; event_data = {stat: stat}; return new Event(event_type, event_data); } } \end{lstlisting} If an event of type \texttt{EV\_LOCK\_ACQ\_TIME} is received, the timestamp is added to a hash data structure which records, grouped by the mutex, the number of calls to the lock function and the total time these calls took. After the program run, on request of the developer running the diagnosis, or in regular time intervals, a \texttt{EV\_SEND\_LOCK\_PROFILE} is generated. If this event is received, the aggregated statistics are sent to the event sink, which then presents the aggregated results to the developer. \subsubsection{Evaluation of the Diagnosis Application} In the evaluation of this usage example we focus on the event and data rates between the event generators and transformation nodes. In order to provide realistic inputs, we profiled the \emph{dedup} application from the PARSEC~3.0 Benchmark Suite with the large input data sets~\cite{bienia11benchmarking}. As PARSEC does not run on our custom-built prototype MPSoC platform, we used the software prototype described in Section~\ref{sec:usage:lockprofiling:software_prototype}. All transformation actors were implemented in Python code equivalent to the pseudo code listings presented in Listings~\ref{lst:tn_time_diff} and~\ref{lst:tn_stat}. \paragraph{Output of the Diagnosis Application} Before we analyze the diagnosis application itself, we discuss the output it generates, i.e. the lock contention profile shown in Listing~\ref{lst:lockprofile_output}. PARSEC was instructed to use at least 4 threads; ultimately 16 threads were spawned by the dedup application. (There is no option in PARSEC to specify the exact number of threads used.) The execution of the observed application took 2.68~s. \begin{lstlisting}[label=lst:lockprofile_output, caption={Output of the lock contention profile diagnosis application observing the PARSEC dedup application.}] mutex # acq. sum [ns] avg [ns] (01) 0x7fd9ac018988 47785 8835387 184.90 (02) 0x7fd9d1ed2978 47784 226012031 4729.87 (03) 0x1c36500 9426 53724035 5699.56 (04) 0x1c36660 9423 21904608 2324.59 (05) 0x1c36710 4638 12528702 2701.32 (06) 0x1c365b0 105 46999 447.61 (07) 0x7fd9d2091430 8 1974 246.75 (08) 0x7fd9b41948f8 8 2277 284.62 (09) 0x7fd9b42b9ad8 8 2560 320.00 (10) 0x7fd9d20f8928 8 2215 276.88 \end{lstlisting} The output shows the top ten most acquired mutexes, together with the total and averaged lock acquisition time. Notable in this profile are mutexes 2 to 5, which take on average significantly longer to acquire: these locks are called to be ``contended.'' A profile helps to understand the program behavior and serves as a starting point to fix possible bugs or inefficiencies. If lock contention is observed (and performance goals of the application are not met), it is common to replace coarse-grained locks with more fine-grained locks, i.e. locks which protect a shorter critical section. However, fixing a bug is not in the scope of this work. Instead, we now turn our discussion to the event and data rates generated when executing the diagnosis application that generated the profile as shown. \paragraph{Event and Data Rates} We designed the diagnosis system to reduce the off-chip traffic by moving the data analysis partially into the SoC. To evaluate if the data rates are in fact reduced, we analyze event rates within the diagnosis application. We use the following event sizes: \begin{itemize} \item An \texttt{EV\_LOCK\_CALL} event requires 14 bytes: two bytes for the event type identifier, four bytes for the timestamp, and eight bytes for the \texttt{mutex} argument. \item An \texttt{EV\_LOCK\_RETURN} event requires six bytes: two bytes for the event type identifier and four bytes for the timestamp. \item An \texttt{EV\_LOCK\_ACQ\_TIME} event requires six bytes: two bytes for the event type identifier, two bytes for the lock acquisition time, and two bytes for the hashed \texttt{mutex} argument. \end{itemize} Over the whole program run, the event generators attached to the 16 CPUs generate a total of 516,254 events, which equals 4.9~MByte of transmitted data or, over the program runtime, an average data rate of 14.7~MBit/s. The \texttt{TA\_DIFF} transformation actors half the number of events, resulting in a data rate of 4.4~MBit/s, or a reduction to 30~\%. Finally, after being aggregated by \texttt{TA\_STAT}, the full result can be transferred off-chip with roughly 204~bytes \medskip A direct comparison of our results to existing tracing systems is challenging. For our analysis we need access to the \texttt{mutex} function argument through a data trace, which is not supported by higher-speed tracing implementations such as CoreSight PTM and Intel PT. However, as a first lower-bound estimation of the data rate generated by a state-of-the-art tracing system, we created a full instruction trace using Intel PT. The same PARSEC dedup application created a trace file of 1.82~GB, which corresponds to 5.4~GBit/s over the program runtime. In summary, DiaSys was able to reduce the required trace bandwidth compared to an Intel PT instruction trace significantly due to on-chip analysis. When transferring data off-chip after processing in the \texttt{TA\_DIFF} processing nodes, the bandwidth is reduced from more than 5.4~GBit/s to 4.4~MBit/s, a reduction by $1233 \times$. \paragraph{Discussion} Depending on the feature set and timestamp granularity of the various tracing implementations, the bandwidth reduction that DiaSys is able to achieve can vary. However, a general observation holds: the most significant bandwidth savings result from the fact that we very precisely capture only data in the event generators which is relevant to our problem. The subsequent processing step \texttt{TA\_DIFF} of calculating the time difference between two events is further able to discard roughly $\nicefrac{2}{3}$ of the data. Both operations are simple enough to be implemented even in resource-constraint on-chip environments. The final step \texttt{TA\_STAT} is again able to give large percentage-wise reductions in data rate, however the absolute savings might not justify an on-chip processing any more. This last step could therefore be executed on the host PC -- without changing the diagnosis application. \section{Conclusions} \label{sec:conclusion} In this paper we introduced DiaSys, a diagnosis system which aims to replace tracing systems in MPSoCs, where software observability is limited by the off-chip bottleneck. To avoid this bottleneck, we move parts of the data analysis into the chip and closer to the data source. The diagnosis system consists of event generators, which observe the functional units executing software on the SoC, the diagnosis application and event sinks. Diagnosis applications describe the data analysis task in a way that is understandable for the developer and portable across different SoCs. In detail we discussed their properties and semantics. Diagnosis applications are portable by design, because components of the application can be freely mapped to distributed diagnosis extensions inside the SoC, or to a runtime environment on the host PC. The implementation of such a mapping tool is future work. In our evaluation we showed on two prototypes that the implementation of the required diagnosis extensions is feasible with reasonable hardware overhead. We also showed in two usage examples from different domains that the envisioned reduction in off-chip bandwidth requirements can be achieved. In the future, we plan to extend this system with more specialized processing nodes, which are suited for common analysis tasks. We also investigate how machine-learning approaches can be used to dynamically adjust the analysis tasks during runtime. \subsection*{Acknowledgments} This work was funded by the Bayerisches Staatsministerium für Wirtschaft und Medien, Energie und Technologie (StMWi) as part of the project ``SoC Doctor,'' and by the German Research Foundation (DFG) as part of the Transregional Collaborative Research Centre ``Invasive Computing'' (SFB/TR 89). The responsibility for the content remains with the authors. We would like to thank Ignacio Alonso and Markus Göhrle for their contributions to the implementation of the evaluation platform. We especially thank Stefan Wallentowitz for the creation and ongoing support of OpTiMSoC. \bibliographystyle{elsarticle-num}
{'timestamp': '2017-01-19T02:06:50', 'yymm': '1607', 'arxiv_id': '1607.04549', 'language': 'en', 'url': 'https://arxiv.org/abs/1607.04549'}
arxiv
\section{Introduction} Spectral embedding methods are based on analyzing Markov chains on a high-dimensional data set $\left\{x_i\right\}_{i=1}^{n} \subset \mathbb{R}^d$. There are a variety of different methods, see e.g. Belkin \& Niyogi \cite{belk}, Coifman \& Lafon \cite{coif1}, Coifman \& Maggioni \cite{coif2}, Donoho \& Grimes \cite{donoho}, Roweis \& Saul \cite{rs}, Tenenbaum, de Silva \& Langford \cite{ten}, and Sahai, Speranzon \& Banaszuk \cite{sahai}. A canonical choice for the weights of the graph is declare that the probability $p_{ij}$ to move from point $x_j$ to $x_i$ to be $$ p_{ij} = \frac{ \exp\left(-\frac{1}{\varepsilon}\|x_i - x_j\|^2_{\ell^2(\mathbb{R}^d)}\right)}{\sum_{k=1}^{n}{ \exp\left(-\frac{1}{\varepsilon}\|x_k - x_j\|^2_{\ell^2(\mathbb{R}^d)}\right)}},$$ where $\varepsilon > 0$ is a parameter that needs to be suitably chosen. This Markov chain can also be interpreted as a weighted graph that arises as the natural discretization of the underlying 'data-manifold'. Seminal results of Jones, Maggioni \& Schul \cite{jones} justify considering the solutions of $$ -\Delta \phi_n = \lambda_n^2 \phi_n$$ as measuring the intrinsic geometry of the weighted graph. Here we always assume Neumann-boundary conditions whenever such a graph approximates a manifold. \begin{figure}[h!] \begin{tikzpicture}[scale=0.2\textwidth, node distance=1.2cm,semithick] \node[origVertex] (0) {}; \node[origVertex] (1) [right of=0] {}; \node[origVertex] (2) [above of=0] {}; \node[origVertex] (3) [above of=1] {}; \node[origVertex] (4) [above of=2] {}; \path (0) edge[origEdge, out=-45, in=-135] node[newVertex] (m0) {} (1) edge[origEdge, out= 45, in= 135] node[newVertex] (m1) {} (1) edge[origEdge] node[newVertex] (m2) {} (2) (1) edge[origEdge] node[newVertex] (m3) {} (3) (2) edge[origEdge] node[newVertex] (m4) {} (3) edge[origEdge] node[newVertex] (m5) {} (4) (3) edge[origEdge, out=125, in= 55, looseness=30] node[newVertex] (m6) {} (3); \path (m0) edge[newEdge, out= 135, in=-135] (m1) edge[newEdge, out= 45, in= -45] (m1) edge[newEdge, out=-145, in=-135, looseness=1.7] (m2) edge[newEdge, out= -35, in= -45, looseness=1.7] (m3) (m1) edge[newEdge] (m2) edge[newEdge] (m3) (m2) edge[newEdge] (m4) edge[newEdge, out= 135, in=-135] (m5) (m3) edge[newEdge] (m4) edge[newEdge, out= 45, in= 15] (m6) (m4) edge[newEdge] (m5) edge[newEdge, out= 90, in= 165] (m6) ; \draw [thick, xshift=0.006cm,yshift=0.005cm] plot [smooth, tension=1] coordinates { (0.03,0.01) (0.04,-0.01) (0.06,0.01) (0.055,0.02) (0.05, 0.01) (0.04, 0.01) (0.035, 0.01) (0.03, 0.02) (0.03,0.01) }; \end{tikzpicture} \caption{Graphs that approximate smooth manifolds.} \end{figure} The cornerstone of spectral embedding is the realization that the map \begin{align*} \Phi: \left\{x_i\right\}_{i=1}^{n} &\rightarrow \mathbb{R}^k \\ x &\rightarrow (\phi_1(x), \phi_2(x), \dots, \phi_k(x)). \end{align*} can be used as an effective way of reducing the dimensionality. One useful explanation that is often given is to observe that the Feynman-Kac formula establishes a link between random walks on the weighted graph and the evolution of the heat equation. We observe that random walks have a tendency to be trapped in clusters and are unlikely to cross over bottlenecks and, simultaneously, that the evolution of the heat equation can be explicitely given as $$ \left[e^{t \Delta} f\right](x) = \sum_{n=1}^{\infty}{e^{-\lambda_n^2 t} \left\langle f, \phi_n \right\rangle \phi_n(x)}.$$ The exponential decay $e^{-\lambda_n^2 t}$ implies that the long-time dynamics is really governed by the low-lying eigenfunctions who then have to be able to somehow reconstruct the random walks' inclination for getting trapped in clusters and should thus be able to reconstruct the cluster. We believe this intuition to be useful and our further exposition will be based on this. \section{The Wave equation} \subsection{Introduction.} Once the eigenfunctions of the Laplacian have been understood, they imply complete control over the Cauchy problem for the wave equation \begin{align*} (\partial_t^2 - \Delta)u(x,t) = 0 \\ u(x,0) = f(x) \\ \partial_t u(x,0) = g(x) \end{align*} given by the eigenfunction expansion $$ u(t,x) = \sum_{n = 1}^{\infty}{ \left[ \cos{(\lambda_ n t)} \left\langle f, \phi_n \right\rangle + \sin{(\lambda_ n t)} \left\langle g, \phi_n \right\rangle \right] \phi_n(x) }.$$ Throughout the rest of the paper, we will understand a solution of a wave equation as an operator of that form, which is meaningful on both smooth, compact manifolds equipped with the Laplace-Beltrami operator $\Delta_g$ as well as on discrete weighted graphs equipped with the Graph Laplacian $\mathcal{L}$. A notable difference is the lack of decay associated with the contribution coming from higher eigenfunctions -- this is closely related to the fact that the heat equation is highly smoothing while the wave equation merely preserves regularity. In one dimension, this is is easily seen using $$ (\partial_t^2 - \partial_x^2) = (\partial_t - \partial_x)( \partial_t + \partial_x)$$ implying that translations $u(x,t) = f(x+t)$ and $u(x,t) = f(x-t)$ are particular solutions of the wave equation which preserve their initial roughness). However, the dynamics is still controlled by low-lying eigenfunctions in a time-averaged sense: note that $$ \frac{1}{b-a}\int_{a}^{b}{u(t,x) dt} = \sum_{n = 1}^{\infty}{ \left[ \left( \frac{1}{b-a} \int_{a}^{b}{\cos{(\lambda_ n t)} dt}\right) \left\langle f, \phi_n \right\rangle + \left( \frac{1}{b-a} \int_{a}^{b}{ \sin{(\lambda_ n t)} dt}\right) \left\langle g, \phi_n \right\rangle \right] \phi_n(x) }$$ where the integrals decay as soon as $\lambda_n^{-1} \lesssim b-a$ since $$ \frac{1}{b-a} \int_{a}^{b}{ \sin{(\lambda_ n t)} dt} \lesssim \min \left( 1, \frac{1}{\lambda_n} \frac{1}{b-a} \right).$$ Put differently, the average behavior over a certain time interval is much smoother than the instantenous behavior. We will now prove that 'average' considerations within the framework of the wave equation allow us to reconstruct the classical distance used in spectral embedding: then, after seeing that 'average' considerations recover the known framework, we will investigate the behavior on shorter time-scales and use that as a way of deriving a finer approximation of the underlying geometry of the given data. \subsection{Recovering the spectral distance.} We start by defining the usual spectral distance between two elements $x_0, y_0 \in \mathcal{M}$ w.r.t. the first $N$ eigenfunctions as $$ d_N(x_0, y_0)^2 = \sum_{n=1}^{N}{(\phi_n(x_0) - \phi_n(y_0))^2}.$$ Equivalently, this may be understood as the Euclidean distance of the embedding $$ d_N(x_0, y_0)^2 = \|\Phi_N(x_0) - \Phi_N(y_0)\|_{\ell^2(\mathbb{R}^N)}^2.$$ Given the dynamical setup of a wave equation, there is another natural way of measuring distances. Given a point $z \in \mathcal{M}$, we define $u_{z}(x,t)$ as the solution of \begin{align*} (\partial_t^2 - \Delta)u_{z}(x,t) &= 0 \\ u_{z}(x,0) &= \delta_{z} \\ \partial_t u_{z}(x,0) &= 0, \end{align*} where $\delta_z$ is the Dirac $\delta-$function in the point $z$. The solution starts out being centered at $z$ and then evolves naturally according to the heat equation. Since we are mainly interested in computational aspects, we will use $u_{z,N}$ to denote the projection of $u_z$ onto the first $N$ Laplacian eigenfunctions. It is natural to assume that if $x_0, y_0 \in \mathcal{M}$ are close, then $u_{x_0}(x,t)$ and $u_{y_0}(x,t)$ should be fairly similar on most points of the domain for most of the time. \begin{figure}[h!] \minipage{0.5\textwidth} \begin{center} \includegraphics[width=0.9\textwidth]{realwave.pdf} \end{center} \endminipage\hfill \minipage{0.45\textwidth} \begin{center} \begin{tikzpicture}[scale=1.2] \draw [ultra thick] (0,0) circle (0.02cm); \draw [ultra thick] (0,0) circle (0.2cm); \draw [ultra thick] (0,0) circle (0.4cm); \draw [ultra thick] (0,0) circle (0.6cm); \draw [ultra thick] (0,0) circle (0.8cm); \draw [ultra thick] (0,0) circle (1cm); \draw [ultra thick] (0,0) circle (1.2cm); \draw [ultra thick] (0,0) circle (1.4cm); \draw [ultra thick] (1.3,0) circle (0.02cm); \draw [ultra thick] (1.3,0) circle (0.2cm); \draw [ultra thick] (1.3,0) circle (0.4cm); \draw [ultra thick] (1.3,0) circle (0.6cm); \draw [ultra thick] (1.3,0) circle (0.8cm); \draw [ultra thick] (1.3,0) circle (1cm); \draw [ultra thick] (1.3,0) circle (1.2cm); \draw [ultra thick] (1.3,0) circle (1.4cm); \end{tikzpicture} \end{center} \endminipage\hfill \captionsetup{width=0.9\textwidth} \caption{An evolving Dirac $\delta-$function and the overlap between two solutions.} \end{figure} We will now prove the Main Theorem stating that this notion fully recovers the spectral distance. \begin{thm}[Wave equation can recover spectral distance.] Assume $\mathcal{M}$ is connected (in the sense of $\lambda_1 > 0$). Then the average $L^2-$distance of the wave equation arising from Dirac measures placed in $x_0, y_0$ allows to reconstruct the spectral distance $d_N(x_0,y_0)$ via $$ \lim_{T \rightarrow \infty}{\frac{1}{T} \int_{0}^{T}{ \int_{\Omega}{(u_{x_0,N}(x,t) - u_{x_0,N}(x,t))^2 dx} dt}} = \frac{1}{2} d_N(x_0, y_0)^2.$$ \end{thm} \begin{proof} By definition, we have that $$ u_{N,x_0}(x,t) = \sum_{n = 0}^{N}{\cos{(\lambda_ n t)} \left\langle \phi_n, \delta_{x_0} \right\rangle \phi_n(x) } \quad \mbox{and} \quad u_{N,y_0}(x,t) = \sum_{n = 0}^{N}{\cos{(\lambda_ n t)} \left\langle \phi_n, \delta_{y_0} \right\rangle \phi_n(x) } $$ We explicitly have that $$ \phi_0(x) = \frac{1}{\sqrt{|\mathcal{M}|}} \qquad \mbox{and} \quad \left\langle \phi_n, \delta_{z} \right\rangle = \phi_n(z).$$ Since the $\phi_n$ are orthonormal in $L^2(\Omega)$, the Pythagorean theorem applies and \begin{align*} \int_{\Omega}{(u_N(x,t) - w_N(x,t))^2 dx} &= \int_{\Omega}{ \left( \sum_{n = 1}^{N}{ \cos{(\lambda_ n t)} (\phi_n(x_0) - \phi_n(y_0)) \phi_n(x) } \right)^2 dx}\\ &= \sum_{n=1}^{N}{\cos{(\lambda_ n t)}^2 (\phi_n(x_0) - \phi_n(y_0))^2 \int_{\Omega}{\phi_n(x)^2 dx}}\\ &= \sum_{n=1}^{N}{\cos{(\lambda_ n t)}^2 (\phi_n(x_0) - \phi_n(y_0))^2} \end{align*} and, since $\lambda_k \geq \lambda_1 > 0$, we easily see that $$ \lim_{T \rightarrow \infty}{\frac{1}{T} \int_{0}^{T}{\cos{(\lambda_n z)}^2dz}} = \frac{1}{2}$$ and therefore $$ \lim_{T \rightarrow \infty}{\frac{1}{T} \int_{0}^{T}{ \sum_{n=1}^{N}{\cos{(\lambda_ n t)}^2 (\phi_n(x_0) - \phi_n(y_0))^2} dt}} = \frac{1}{2} \sum_{n=1}^{N}{ (\phi_n(x_0) - \phi_n(y_0))^2}.$$ \end{proof} \textit{Remark.} If $\mathcal{M}$ is not connected but has multiple connected components, then the argument shows $$ \frac{1}{2} d_N(x_0, y_0)^2 \leq \lim_{T \rightarrow \infty}{\frac{1}{T} \int_{0}^{T}{ \int_{\Omega}{(u_{x_0,N}(x,t) - u_{x_0,N}(x,t))^2 dx} dt}} \leq d_N(x_0, y_0)^2.$$ \section{The Algorithm} \begin{flushright} \textit{If you want to see something, you send waves in its general direction, you don't throw heat at it.}\\ -- attributed to Peter Lax \end{flushright} \subsection{Spectral Echolocation.} The Theorem discussed in the preceeding section suggests that we lose no information when using distances induced by the wave equation. The main underlying idea of our approach is that we naturally obtain \textit{additional} information. We emphasize that the algorithm we describe here is \textit{not} a dimension-reduction algorithm -- instead, it can be regarded as a natural pre-processing step to enhance the effectiveness of spectral methods. Furthermore, it is more appropriate to speak of an entire family of algorithms: there are a variety of parameters and norms one could define and the optimal choice is not a priori clear.\\ \begin{mdframed} \textbf{Spectral Echolocation Algorithm.} \begin{quote} \begin{enumerate} \item \textbf{Input.}~A weighted graph $G = (V,E,w)$. \item Compute the first $N$ Laplacian eigenfunctions $\left\{\phi_1, \phi_2, \dots, \phi_N\right\}$. \item Pick $k$ random points $v_1, v_2, \dots, v_k \in V$. \item Define $k$ functions $f_1, \dots, f_k: V \rightarrow \mathbb{R}$ as 'mollifications' of the indicator functions associated to the $k$ points. We propose taking the existing affinities given by the weights $$ f_i(x) = w_{i,x}. $$ \item Pick $\varepsilon > 0$. The projection of the solution of the attenuated wave equation with $f_i$ as initial datum onto the first $N$ eigenfunctions is $$ u_i(t,x) = \sum_{n=1}^{N}{ \cos{(\lambda_k t)} e^{-\varepsilon \lambda_k t} \left\langle f_i, \phi_n\right\rangle\phi_n(x)}$$ \item Define a new weight between any two points $v_1, v_2 \in V$ given by $$ d_i(v_1, v_2) =\| u_i(t,v_1) - u_i(t,v_2)\|^{\alpha}_{X} + \| (u_i)_t(t,v_1) - (u_i)_t(t,v_2)\|^{\beta}_{Y},$$ where $u_t$ is the derivative in time and $X,Y$ are any norms on the space of continuous functions $C[0,T]$ and $\alpha, \beta > 0$. \item \textbf{Output.} A distance $d:V \times V \rightarrow \mathbb{R}_{+}$ synthesized out of $d_1, \dots, d_k$, examples being $$d(v_1,v_2) = \min_{1 \leq i \leq k}{ d_i(v_1, v_2)} \quad \mbox{and} \quad d(v_1,v_2) = \frac{1}{k}\sum_{i=1}^{k}{ d_i(v_1, v_2)}.$$ \end{enumerate} \end{quote} \end{mdframed} \vspace{10pt} The underlying idea is quite simple: we start with various initial distributions of 'water' at rest. We want these initial configurations to be relatively smooth so as to avoid drastic shocks. Given this initial configuration, we follow the evolution of the wave equation at our desired level of resolution (given by restricting to $N$ eigenfunctions). Points that are nearby should always have comparable levels of water and comparable levels of change in water level and this is measured by the integral norm. The exponentially decaying term $\exp(-\varepsilon \lambda_k t)$ in the evolution of the solution $$ u_i(t,x) = \sum_{n=1}^{N}{ \cos{(\lambda_k t)} e^{-\varepsilon \lambda_k t} \left\langle f_i, \phi_n\right\rangle \phi_n(x)}$$ comes from actually solving for the attenuated wave equation which further reduces high-frequency shocks and increases stability. As described above, setting $X = L^2$, $\varepsilon = 0$, squaring the norm, ignoring the derivative term completely and letting $T \rightarrow \infty$ recovers the original weights of the graph completely. In practice, we have found that $T = 1, \varepsilon = \lambda_1^{-1}$, $X = Y = L^1[0,1]$ and $\alpha=\beta=1$ yield the best results, however, this is a purely experimental finding -- identifying the best parameters and giving a theoretical justification for their success is still an open problem. \section{Examples of Noisy Clustering} \subsection{Parameters} We always consider $N=50$ eigenfunctions and $k=10$ randomly chosen initial spots from which to send out waves. The attenuation factor is always chosen as $\varepsilon = \lambda_1^{-1}$ and time is chosen so that the first eigenfunction performs one oscillation $T=\lambda_1^{-1}$. Further parameters are $X = L^1[0,T] = Y$ and $\alpha = 1 = \beta$. This uniquely defines the $1 \leq i \leq k$ individually induced distances, we always condense them into one distance using either $$d(v_1,v_2) = \min_{1 \leq i \leq k}{ d_i(v_1, v_2)} \qquad \mbox{or} \qquad d(v_1,v_2) = \frac{1}{k}\sum_{i=1}^{k}{ d_i(v_1, v_2)}.$$ Generally, continuous geometries benefit from taking the minimum because of increased smoothness whereas clustering problems are better treated using the second type of combined distance. \subsection{Geometric Clusters with Erroneous Edges}\label{geomClusterErroneousEdge} A benefit of the refined wave echolocation metric is that, unlike heat, the transmission between two clusters does not simply depend on the number of edges but also their topology. We consider two clusters in $\mathbb{R}^2$ each of which consists of a 1000 points arranged in a unit disk and the two unit disks are well-separated -- the obstruction comes from a large number of random edges; specifically, every point is randomly connected to 4\% in the other cluster. Heat diffuses quickly between these two clusters due to the large number of intra cluster connections. For this reason, the heat embedding of the fails to separate the clusters (however, it is does preserve some aspects of the topology, see Fig. \ref{fig:randErrorEmbeddings}). In contrast, however, the wave echolocation metric manages a clear separation of objects. \begin{figure}[h!] \begin{tabular}{cc} \includegraphics[width=.48\textwidth]{laplacianEmbedding2cluster.png} & \includegraphics[width=.48\textwidth]{waveEmbedding_affStart2.png} \end{tabular} \caption{Heat kernel embedding (left) and embedding of the wave echolocation metric (right). We used averaging across 10 starting positions.}\label{fig:randErrorEmbeddings} \end{figure} \subsection{Social Networks} Social networks are a natural application of spectral methods, and mirror the synthetic example in Section \ref{geomClusterErroneousEdge}. We examine spectral echolocation on the Facebook social circles dataset from \cite{facebookNetwork}, which consists of 4039 people in 10 friend groups. While there exist clear friend groups, edges within the clusters are still somewhat sparse, and there exist erroneous edges between clusters. One goal is to propagate friendship throughout the network and emphasize clusters. Figure \ref{fig:socialNetworkAffinity} shows the original affinity matrix, sorted by cluster number. We also compute the diffusion distance and spectral echolocation distance, and display the affinity matrix $W_{i,j} = exp(-d(v_i, v_j)^2)$ for both. Spectral echolocation not only compresses the inter cluster distances, it also discovers weak similarity between different clusters that share a number of connections. \begin{figure}[!h] \begin{tabular}{ccc} \includegraphics[width=.32\textwidth]{orginialAffinity.png} & \includegraphics[width=.32\textwidth]{laplacianAffinity.png} & \includegraphics[width=.32\textwidth]{waveEmbedding.png} \\ \includegraphics[width=.32\textwidth]{orginialAffinity_zoomed.png} & \includegraphics[width=.32\textwidth]{laplacianAffinity_zoomed.png} & \includegraphics[width=.32\textwidth]{waveEmbeddingAffinity_zoomed2.png} \\ \end{tabular} \captionsetup{width=0.95\textwidth} \caption{Original Facebook affinity matrix (left), heat kernel embedding affinity (center), and wave embedding affinity (right). Bottom is zoomed in version of the top.}\label{fig:socialNetworkAffinity} \end{figure} \textit{Substructures.} Another natural goal is to detect small ``friendship circles'' within the larger network. These circles are based off of the features that brought the group together (e.g. same university, same work, etc). Overall there are 193 circles, though many only contain two or three people, and many of the larger circles are nowhere close to a dense network. We compare the average affinity within the 100 largest circles across several techniques. For both the standard heat kernel embedding as well as the wave embedding, we build a new graph between people based on whether two people are ``10-times closer than chance'', which is defined as \begin{eqnarray*} \{x,y\}\in E \iff e^{-d(x,y)^2/\epsilon} > 10\cdot \mathbb{E}_{x'}\mathbb{E}_{y'} [e^{-d(x',y')^2/\epsilon}]. \end{eqnarray*} We now compare the typical number of edges in each circle for the original data as well as the two embeddings -- we observe a dramatic improvement. The results are displayed in Figure \ref{fig:circles}. \begin{figure}[h!] \begin{tabular}{ccc} \includegraphics[width=.32\textwidth]{origAffinityInCircle.png} & \includegraphics[width=.32\textwidth]{lapAffinityInCircle.png} & \includegraphics[width=.32\textwidth]{waveAffinityInCircle.png} \end{tabular} \caption{Number of friendship edges in original network (left), heat kernel embedding network (center), wave embedding network (right).}\label{fig:circles} \end{figure} \section{Examples with Heterogeneous Dimensionality} \subsection{Plane with Holes} We examine the behavior of waves in a porous medium. Figure \ref{fig:planeWithHoles} shows that the wave equation travels more quickly through the bridges (the wave speeds up while in a bottleneck), and gets caught in the intersections. preserves the topology of the data and emphasizes the holes. \begin{figure}[!h] \begin{tabular}{ccc} \includegraphics[height=.25\textwidth]{originalData2.png} & \includegraphics[height=.25\textwidth]{laplacianEmbedding2.png} & \includegraphics[height=.25\textwidth]{waveEmbedding3.png} \end{tabular} \captionsetup{width=0.95\textwidth} \caption{Original Data (left), heat kernel Embedding (center), and Wave Embedding (right). We used the minimum distance across 10 starting positions.}\label{fig:planeWithHoles} \end{figure} \subsection{Union of Manifolds} Another interesting property of the wave equation is that the change in position $u_t$ undergoes a dramatic change whenever the dimensionality of the manifold changes: waves are suddenly forced into a very narrow channel or -- going the other direction -- are suddenly evolving in many different directions. We demonstrate this first in Figure \ref{fig:6D1D}. The data consists of two six-dimensional spheres, connected by a one-dimensional line. The low frequency eigenfunctions of the heat kernel travel from one end to the other without much recognition of the varying dimensionality. However, the wave embedding creates a gap between the bridge and the two spheres, with the variation of the first non-trivial eigenfunction being supported almost entirely on the bridge. \begin{figure}[!h] \begin{tabular}{ccc} \includegraphics[width=.33\textwidth]{6DSpheres1DBridge2.png} & \includegraphics[width=.33\textwidth]{6DSpheres1DBridge_laplacianEmbedding2.png} & \includegraphics[width=.33\textwidth]{6DSpheres1DBridge_waveEmbedding2.png} \end{tabular} \caption{6D spheres with 1D bridge (left), heat kernel embedding (center), and wave embedding (right). For this problem, we use the min distance across 10 starting positions.}\label{fig:6D1D} \end{figure} \subsection{Union of Manifolds with different dimensions} We also consider the same problem with spheres of different dimensions as in Figure \ref{fig:6D3D1D}. The data consists of a six-dimensional sphere and a three-dimensional sphere connected by a one-dimensional line. The figure displays the affinity matrices of the points, with the first block representing the six-dimensional sphere, the second block representing the three-dimensional sphere, and the third small block for the bridge. Notice that, in the heat kernel affinity, the bridge has affinity to more points in the lower dimensional sphere than the higher dimensional sphere. Also notice that the wave embedding separates the six-dimensional sphere much further from the bridge than the three-dimensional sphere.\\ \begin{figure}[!h] \begin{tabular}{cc} \includegraphics[width=.48\textwidth]{6D3D1DBridge2.png} & \includegraphics[width=.48\textwidth]{6D3D1D_waveEmbeddingSorted2.png} \\ \includegraphics[width=.48\textwidth]{6D3D1D_lapAffinitySorted.png} & \includegraphics[width=.48\textwidth]{6D3D1D_waveAffinitySorted.png} \end{tabular} \captionsetup{width=0.95\textwidth} \caption{6D sphere in cluster 1 and 3D sphere in cluster 2 with 1D bridge (top left), wave embedding (top right), heat kernel affinity matrix (bottom left), and wave affinity matrix (bottom right). For this problem, we use the min distance across 10 starting positions.}\label{fig:6D3D1D} \end{figure} Finally, we consider two six-dimensional spheres connected via a two-dimensional bridge in Figure \ref{fig:6D2D}. Specifically, we examine the local affinities of several points on the bridge. Notice that, for the wave equation, the affinities of points on the bridge are far from isotropic and clearly distinguish the direction the wave is traveling between the two spheres. Moveover, points on the bridge near the spheres have much lower affinity to points on the sphere than their heat kernel counterparts. \begin{figure}[!h] \begin{tabular}{cc} \includegraphics[width=.48\textwidth]{waveAff1.png} & \includegraphics[width=.48\textwidth]{waveAff2.png} \\ \includegraphics[width=.48\textwidth]{lapAff1.png} & \includegraphics[width=.48\textwidth]{lapAff2.png} \end{tabular} \captionsetup{width=0.95\textwidth} \caption{Neighborhoods of chosen points in 6D spheres--2D bridge example for wave embedding using averaging across 10 starting positions (top) and heat kernel affinity (bottom).}\label{fig:6D2D} \end{figure} \section{Comments and Remarks} \subsection{Other partial differential equations} Spectral echolocation has two novel components: \begin{enumerate} \item the evolution of a dynamical system on an existing weighted graph \item and the construction of a refined metric using information coming from the behavior of the dynamical system. \end{enumerate} Our current presentation had its focus mainly on the case where the dynamical system is given by the wave equation, however, it is not restricted to that. Let us quickly consider a general linear partial differential equation of the type $$ \frac{\partial}{\partial t} u(t,x) = D u(t,x) \qquad \mbox{on}~\mathbb{R},$$ where $D$ is an arbitrary differential operator. The Fourier transform in the space variable yields a separation of frequencies $$ \frac{\partial}{\partial t} \widehat{u}(t,\xi) = i p(D, \xi) \widehat{u}(t, \xi),$$ where $p(D,\xi)$ is the symbol of the differential operator at frequency $\xi$. This is a simple ordinary differential equation whose solution can be written down explicitly as $$ \widehat{u}(t, \xi) = e^{i t p(D, \xi)} \widehat{u}(0, \xi)$$ and taking the Fourier transform again allows us to write the solution as $$ u(t,x) = \int_{\mathbb{R}}{ e^{i x \cdot \xi + i t p(D, \xi)} \widehat{u}(0, \xi) d\xi}.$$ Differential equations for which this scheme is applicable include the classical heat equation ($D = \Delta$) but also variants that include convolution with a sufficiently nice potential ($Du = \Delta u + V * u$), the Airy equation ($D = \partial_{xxx}$) and, more generally, any sufficiently regular pseudo-differential operator (for example $\sqrt{-\Delta + c^2}$). The crucial insight is that the abstract formulation via the Fourier transform has a direct analogue on weighted graphs: more precisely, given eigenfunctions $\phi_1, \dots, \phi_N$ associated to eigenvalues $\lambda_1, \dots, \lambda_N$, the natural `frequency' associated to $\phi_k$ is, of course, $\lambda_k$ and we may define the solution of $$ \frac{\partial}{\partial t} u(t,x) = D u(t,x)$$ in the same way via $$ u(t,x) = \sum_{k=1}^{N}{ e^{ p(\lambda) t} \left\langle u(0,x), \phi_k \right\rangle_{L^2} \phi_k(x)}.$$ \begin{figure}[h!] \begin{tabular}{ccc} \includegraphics[width=.32\textwidth]{waveAff12.png} & \includegraphics[width=.32\textwidth]{waveAff22.png} & \includegraphics[width=.32\textwidth]{waveAff3.png} \\ \includegraphics[width=.32\textwidth]{heatAff1.png} & \includegraphics[width=.32\textwidth]{heatAff2.png} & \includegraphics[width=.32\textwidth]{heatAff3.png} \\ \includegraphics[width=.32\textwidth]{airyAff1.png} & \includegraphics[width=.32\textwidth]{airyAff2.png} & \includegraphics[width=.32\textwidth]{airyAff3.png} \\ \includegraphics[width=.32\textwidth]{schrodAff1.png} & \includegraphics[width=.32\textwidth]{schrodAff2.png} & \includegraphics[width=.32\textwidth]{schrodAff3.png} \end{tabular} \caption{Wave (top), Heat ($2^{nd}$ row), Airy ($3^{rd}$ row), and Schrodinger (bottom).} \end{figure} Natural `symbols' include heat $p(\lambda) = - \lambda^2$, Airy $p(\lambda) = i \lambda^3$ or Schrodinger $p(\lambda) = i \lambda$. Naturally, the same analysis goes through for equations of the type $u_{tt} = Du$ and our analysis of the attenuated wave equation above follows that scheme. The analysis of partial differential equations on graphs is still in its infancy and our original motivation for using the wave equation is a number of desirable properties that seem uniquely suited for the task at hand: no dissipation of energy and finite speed of propagation. Numerical examples show that different symbols $p(\lambda)$ can induce very similar neighborhoods: we believe that this merits further study; in particular, a thorough theoretical analysis of the proposed family of algorithms is highly desired. \subsection{Special case: Heat equation} We want to emphasize that our approach is novel even when we chose to emulate the classical heat propagation. This method can outperform the classical (unrefined) embedding via Laplacian eigenmaps even in relatively simple toy examples: we consider the classical 2D dumbbell example in Figure \ref{fig:dumbbell2}. \begin{figure}[h!] \begin{tabular}{c} \includegraphics[width=.5\textwidth]{dumbbellData.png} \end{tabular} \caption{The dumbbell domain in our experiment.}\label{fig:dumbbell2} \end{figure} This example has a small Cheeger constant due to the bottleneck, which means the first non-trivial eigenfunction will be essentially constant on the boxes and change rapidly on the bottleneck. This classical examples illustrates well how the first nontrivial eigenfunction can be used as a classifier and the classical Laplacian eigenmap works spectacularly well without any further modifications. \begin{figure}[h!] \begin{tabular}{c} \includegraphics[width=.6\textwidth]{dumbbellEigenfunctions.png} \end{tabular} \caption{The values of the first eigenfunction for classical Laplacian eigenmaps (blue) vs. the refined heat metric (blue).}\label{fig:dumbbell} \end{figure} Figure \ref{fig:dumbbell} compares the eigenfunction $\phi_1$ of the Laplacian compared to the first non-trivial eigenfunction of the heat equation distance matrix. We observe that the refined heat metric is a much better approximation to the function \[f(x) = \begin{cases} -1 & x_1\leq -0.5 \\ 2x & -0.5< x_1< 0.5 \\ 1 & x_1\geq 0.5 \end{cases} \] than $\phi_1$ and allows for a more accurate reconstruction of the bridge. We also observe that the nontrivial eigenfunction is essentially and to a remarkable degree constant on the two clusters which further increases its value as a classifier. \section{Conclusions} \textit{Summary.} We have presented a new pre-processing technique for classical dimensionality reduction techniques based on spectral methods. The underlying new idea comes in three parts: (1) if one computes eigenfunctions of the Laplacian, then one might just as well use them so simulate the evolution of a partial differential equation on the existing weighted graph, (2) especially for physically meaningful dynamical systems such as the wave equation one would expect points with high affinity to behave similarly throughout time and (3) this motivates the construction of a refined metric extracting information coming from the behavior of the dynamical system. \\ \textit{The wave equation.} We were originally motivated by a series of desirable properties of the wave equation on $\mathbb{R}^n$: preservation of regularity and finite speed of propagation. Recall that one of the fundamental differences between the heat equation and the wave equation is that solutions of the heat equation experience an instanteneous gain in smoothness while the wave equation merely preserves the smoothness of the initial datum (and sometimes not even that). Our main point is to show that this is not arbitrary but due to physical phenomena whose counterparts in the world of data can provide a refined measurement: \textit{the lack of regularity can be helpful}! However, as we have shown, there are similar effects for most other partial differential equations and theoretical justifications on a precise enough level that they would distinguish between various dynamical systems are still missing -- we believe this to be a fascinating open problem.\\ \textit{Refined metrics.} Similarily, our way of refining metrics, either by taking the minimum or by compiling an average, is motivated by considerations (see also \cite{stein}) that are not specifically tuned to our use of partial differential equations -- another fascinating open question is whether there is a more natural and attuned way of extracting information.\\ \textbf{Acknowledgement.} The authors are grateful to Raphy Coifman for a series of fruitful discussions and helpful suggestions. A.C. is supported by an NSF Postdoctoral Fellowship \#1402254, S.S. is supported by an AMS Simons Travel Grant and INET Grant \#INO15-00038.
{'timestamp': '2016-07-18T02:08:18', 'yymm': '1607', 'arxiv_id': '1607.04566', 'language': 'en', 'url': 'https://arxiv.org/abs/1607.04566'}
arxiv
"\\section{Introduction}\n\\blfootnote{\n %\n \n %\n \n \n \n \n %\n \n %\n (...TRUNCATED)
"{'timestamp': '2016-10-04T02:07:07', 'yymm': '1607', 'arxiv_id': '1607.04853', 'language': 'en', 'u(...TRUNCATED)
arxiv
"\\section{Introduction}\\label{sec:intro}\n\n The constraint satisfaction problem (CSP) provides(...TRUNCATED)
"{'timestamp': '2018-01-09T02:13:26', 'yymm': '1607', 'arxiv_id': '1607.04787', 'language': 'en', 'u(...TRUNCATED)
arxiv
"\n\\section{Introduction}\n\\label{sec:intro}\n\nPolicy search algorithms based on supervised learn(...TRUNCATED)
"{'timestamp': '2016-07-18T02:09:29', 'yymm': '1607', 'arxiv_id': '1607.04614', 'language': 'en', 'u(...TRUNCATED)
arxiv
"\\section{Introduction}\nSpatio--temporal models are widely used by practitioners. Explaining econo(...TRUNCATED)
"{'timestamp': '2016-07-18T02:07:32', 'yymm': '1607', 'arxiv_id': '1607.04522', 'language': 'en', 'u(...TRUNCATED)
arxiv
"\\section{Introduction}\n\n\n Many problems, particularly in combinatorics, reduce to asking whethe(...TRUNCATED)
"{'timestamp': '2016-08-02T02:11:05', 'yymm': '1607', 'arxiv_id': '1607.04829', 'language': 'en', 'u(...TRUNCATED)
arxiv
"\\section{Handling batch insertions}\n\n In this section, we study the dynamic DFS tree prob(...TRUNCATED)
"{'timestamp': '2018-02-21T02:08:14', 'yymm': '1607', 'arxiv_id': '1607.04913', 'language': 'en', 'u(...TRUNCATED)
arxiv

Dataset Card for "RedPajama-Data-1T-arxiv-filtered"

More Information needed

Downloads last month
6
Edit dataset card