# Modeling Drug–Disease Relations
with Linguistic and Knowledge Graph Constraints

Bruno Godefroy
Roam Analytics
&Christopher Potts
Roam Analytics
Stanford University

###### Abstract

FDA drug labels are rich sources of information about drugs and drug–disease
relations, but their complexity makes them challenging texts to analyze in
isolation. To overcome this, we situate these labels in two health knowledge
graphs: one built from precise structured information about drugs and
diseases, and another built entirely from a database of clinical narrative
texts using simple heuristic methods. We show that Probabilistic Soft Logic
models defined over these graphs are superior to text-only and relation-only
variants, and that the clinical narratives graph delivers exceptional results
with little manual effort. Finally, we release a new dataset of drug labels
with annotations for five distinct drug–disease relations.

##  1 Introduction

The FDA Online Label Repository is a publicly available database of texts that
provide detailed information about pharmaceutical drugs, including active
ingredients, approved usage, warnings, and contraindications. Although the
labels have predictable subsections and use highly regulated language, they
are nuanced and presuppose deep medical knowledge, since they are intended for
use by healthcare professionals (Shrank and Avorn, 2007). This makes them a
formidable challenge for information extraction systems.

Figure 1: Illustrative knowledge graph for the prediction of the relation
between a drug (Medrol) and a disease (dermatitis). In favor of a Treats
relation: Medrol has the same pharmacologic class as Baycadron, which treats
dermatitis; dermatitis has the same morphology as neuritis, which is treated
by Medrol. Against a Treats relation: dermatitis has the same site as
hypersensitivity, which is not treated by Medrol. Our Probabilistic Soft Logic
approach learns to combine these factors.

At the same time, existing medical ontologies contain diverse structured
information about drugs and diseases. The drug labels can be situated in a
larger health knowledge graph that brings together these sources of
information, which can then be used to understand the labels. Figure 1
illustrates the guiding intuition; if our goal is to determine whether to add
the dashed Treats edge, we should take advantage of the label for Medrol as
well as the drug–drug, drug–disease, and disease–disease relations that are
observed. Hristovski et al. (2006) describe a similar intuition with what they
call “discovery patterns”.

In this paper, we show that Probabilistic Soft Logic (PSL; Bröcheler et al.
2010; Bach et al. 2013) is an effective tool for modeling drug labels situated
in larger health knowledge graphs. A PSL model is a set of logical statements
interpreted as defeasible relational constraints, and the relative weights of
these constraints are learned from data. In PSL, we can directly state
intuitions like ‘if some drugs share a substance, then they might treat the
same diseases’ and ‘if two diseases share a classification, they might be
treated by the same drugs’. Fakhraei et al. (2013) show the value of these
ideas for drug–disease relationships. We extend their basic idea by adapting
the method of West et al. (2014): our PSL models combine graph-based
constraints with constraints derived from a separate sequence-labeling model
applied to the drug label texts.

The most expensive parts of this model are the structured ontologies used to
build the graph. Each ontology is a large, highly specialized project
requiring extensive human expertise. This motivates us to seek out
alternatives. To this end, we also evaluate on a graph that is derived
entirely from clinical texts. Using only key-phrase matching, we instantiate a
large, noisy graph with the same core structure as in figure 1, and we show
that the PSL model is robust to such noisy inputs. By combining this graph
with our structured one, we achieve larger gains, but the clinical narratives
graph is effective on its own, and thus emerges as a viable option for domains
lacking pre-built ontologies.

Our evaluations are centered around a new dataset of annotated drug labels. In
this dataset, spans of text identifying diseases are annotated with labels
summarizing the drug–disease relationship expressed in the
label.111https://github.com/roamanalytics/roamresearch/tree/master/Papers/PSL-
drugs-diseases We show that our full PSL model yields superior predictions on
this dataset, as compared with ablations using only the texts and only the
graph edges derived from structured and textual sources.

##  2 Medical Ontologies Knowledge Graph

Our health knowledge graphs are focused on drugs and diseases related to
obesity. We first introduce the graph we built from structured sources (802
nodes, 883 edges).

###  2.1 FDA Online Label Repository

From the FDA Online Label Repository222https://labels.fda.gov we extracted the
drug labels matching at least one of the following keywords: “obesity”,
“overweight”, “asthma”, “coronary heart disease”, “hypercholesterolemia”,
“gallstones”, “gastroesophageal reflux”, “gout”, “hypertriglyceridemia”,
“sleep apnea”, “peripheral vascular disease”, “chronic venous
insufficiencies”. This is the set of diseases in the i2b2 Obesity Challenge
(Uzuner, 2009), with some omissions for the sake of precision.

The FDA individuates drugs in a very fine-grained way, resulting in many
duplicate or near-duplicate labels (there are usually multiple brands and
versions of a drug). To ensure no duplicates in the intuitive sense, we hand-
filtered to a set of 106 drug labels. These labels mention 198 distinct
diseases, resulting in 1,110 drug–disease pairs.

###  2.2 Drug–Disease Annotations

| Relations | Agreement
---|---|---
Prevents | 154 | 63.0
Treats | 4,425 | 67.3
Treats Outcomes | 2,268 | 67.1
Not Established | 241 | 35.1
Not Recommended | 262 | 49.5
other | 1,262 | 35.9
Table 1: Drug–disease relations collected using crowdsourcing. The “Agreement”
column gives the average agreement between workers and the labels inferred.
Higher agreement correlates strongly with the degree to which the information
is explicit in the label text.

Disease mentions in drug labels have a variety of senses. Guided by our own
analysis of the relevant sentences, we settled on the following set of
relational descriptions, with input from clinical experts acting as
consultants to us:

  * •

The drug prevents the disease (our label is Prevents).

  * •

The drug treats the disease (Treats).

  * •

The drug treats outcomes of the disease (Treats Outcomes).

  * •

The safety/effectiveness of the drug has not been established for the disease
(Not Established).

  * •

The drug is not recommended for the disease (Not Recommended).

We emphasize the clinical importance of distinguishing between treating a
disease and treating its outcomes. Cancer, for example, is not treated with
Depo-Medrol, but hypercalcemia associated with cancer is. Similarly, Not
Recommended identifies a contraindication, a specific kind of guidance,
whereas the superficially similar Not Established has a more open meaning: the
relation could be Treats, but this has not been tested or a clinical trial
failed to demonstrate its efficacy.

We crowdsourced the task of assigning these labels to disease mention spans.
Workers saw the entire label text, with our target diseases highlighted, and
were asked to select the best statement among those provided above. We
launched our task on Figure Eight, asking for 5 judgments for each
drug–disease pair. To infer a label for each example from these responses, we
applied Expectation Maximization (EM), which estimates the reliability of each
worker and weights their contributions accordingly (Dawid and Skene, 1979).
Table 1 reports average agreement between workers and the inferred label. The
Prevents, Treats, and Treats Outcomes relations are usually stated directly in
drug labels, leading to high agreement. In contrast, Not Established, Not
Recommended, and Other are more subtle and diverse, leading to lower
agreement. The label of Normosol-R, for example, states: “The solution is not
intended to supplant transfusion of whole blood or packed red cells in the
presence of uncontrolled hemorrhage”. What is the relation between Normosol-R
and hemorrhage? In this case, any of Not Established, Not Recommended, and
Other seems acceptable.

We observe a correlation between the number of distinct disease mentions in a
drug label and its ratio of Treats labels against the other labels. Some drugs
are more “general purpose” than others, in that they are involved in many
treatment relations. For example, the label for Prednisone contains mentions
of 50 distinct diseases it can treat. To prevent our system from predicting
treatment relations primarily using the out-degree of drug nodes (instead of
the domain knowledge provided by the graph), we manually removed 19 of these
high-degree drugs. After removing these drugs, our dataset contained 431
relations.

###  2.3 Structured Medical Ontologies

Our graph contains structured information about drugs and diseases from a
variety of sources. Our observations for drugs are route
(OpenFDA),333https://open.fda.gov pharmacologic class (OpenFDA), substances
(OpenFDA), and dosage form
(RxNorm).444https://www.nlm.nih.gov/research/umls/rxnorm/ Our observations for
diseases are all from SNOMED CT:555https://www.snomed.org finding sites,
associated morphologies, and courses.

In general, these ontologies are quite sparse; a missing edge is therefore not
necessarily evidence for a missing relationship. Broadly speaking, this is why
text analysis can be so meaningful in this context – structured resources
always fall behind because of the challenges of manual creation. This sparsity
also motivates the approximate, text-based graph we introduce next.

##  3 Clinical Narratives Knowledge Graph

The Medical Ontologies Knowledge Graph is precise, but the underlying
resources are expensive to build, which creates sparsity and can be an
obstacle to adapting the ideas to new domains. To try to address this, we
built a comparable graph using only de-identified clinical narratives –
reports (often transcribed voice recordings) of clinicians’ interactions with
patients.

Using lexicon-based matching methods, we extracted drug and disease mentions
from these texts. In the resulting graph, each text is a node, with edges to
the drug and disease nodes corresponding to these extracted mentions. The
resulting graph has 319,598 nodes and 421,502 edges.

This is a simpler graph structure than we are able to obtain from structured
resources (cf. section 2.3), but it supports our most important logical
connections. For example, we can say that if diseases $\mathit{d}_{1}$ and
$\mathit{d}_{2}$ are mentioned in the same narrative and $\mathit{d}_{1}$ is
treated by a specific drug, then $\mathit{d}_{2}$ might also be treated by
that drug. These hypotheses are often not supported; for example, a patient
with a number of unrelated medical conditions might lead to many false
instances of this claim. Nonetheless, we expect that, in aggregate, these
connections will prove informative.

##  4 Models

$\begin{array}[c]{@{} r @{\hspace{14pt}} c @{\hspace{24pt}} l @{\thickspace}
@{}}\hbox{\multirowsetup Priors}\hskip 14.0&\hfil\hskip
24.0&{\color[rgb]{1,1,1}\neg}\textbf{treats}(\mathit{c}_{i},\mathit{d}_{j})\\\
\hskip 14.0&\hfil\hskip
24.0&\neg\textbf{treats}(\mathit{c}_{i},\mathit{d}_{j})\\\\[8.61108pt]
\text{1a.}\hskip
14.0&\hbox{\multirowsetup\includegraphics[height=32.0pt]{configuration1.png}}\hfil\hskip
24.0&{\color[rgb]{1,1,1}\neg}\textbf{CRF\\_treats}(\mathit{c}_{i},\mathit{d}_{j})\thickspace\Rightarrow\thickspace{\color[rgb]{1,1,1}\neg}\textbf{treats}(\mathit{c}_{i},\mathit{d}_{j})\\\
\text{b.}\hskip 14.0&\hfil\hskip
24.0&\neg\textbf{CRF\\_treats}(\mathit{c}_{i},\mathit{d}_{j})\thickspace\Rightarrow\thickspace\neg\textbf{treats}(\mathit{c}_{i},\mathit{d}_{j})\\\\[8.61108pt]
\text{2a.}\hskip
14.0&\hbox{\multirowsetup\includegraphics[height=32.0pt]{configuration2.png}}\hfil\hskip
24.0&\textbf{R}(\mathit{d}_{1},x)\thickspace\wedge\thickspace\textbf{R}(\mathit{d}_{2},x)\thickspace\wedge\thickspace\mathit{d}_{1}\neq\mathit{d}_{2}\thickspace\wedge\thickspace{\color[rgb]{1,1,1}\neg}\textbf{treats}(\mathit{c}_{i},\mathit{d}_{1})\thickspace\Rightarrow\thickspace{\color[rgb]{1,1,1}\neg}\textbf{treats}(\mathit{c}_{i},\mathit{d}_{2})\\\
\text{b.}\hskip 14.0&\hfil\hskip
24.0&\textbf{R}(\mathit{d}_{1},x)\thickspace\wedge\thickspace\textbf{R}(\mathit{d}_{2},x)\thickspace\wedge\thickspace\mathit{d}_{1}\neq\mathit{d}_{2}\thickspace\wedge\thickspace\neg\textbf{treats}(\mathit{c}_{i},\mathit{d}_{1})\thickspace\Rightarrow\thickspace\neg\textbf{treats}(\mathit{c}_{i},\mathit{d}_{2})\\\\[8.61108pt]
\text{3a.}\hskip
14.0&\hbox{\multirowsetup\includegraphics[height=32.0pt]{configuration3.png}}\hfil\hskip
24.0&\hskip 1.2pt\textbf{S}\hskip
1.2pt(\mathit{c}_{1},x)\thickspace\wedge\thickspace\hskip
1.2pt\textbf{S}\hskip
1.2pt(\mathit{c}_{2},x)\thickspace\wedge\thickspace\mathit{c}_{1}\neq\mathit{c}_{2}\thickspace\wedge\thickspace{\color[rgb]{1,1,1}\neg}\textbf{treats}(\mathit{c}_{1},\mathit{d}_{j})\thickspace\Rightarrow\thickspace{\color[rgb]{1,1,1}\neg}\textbf{treats}(\mathit{c}_{2},\mathit{d}_{j})\\\
\text{b.}\hskip 14.0&\hfil\hskip 24.0&\hskip 1.2pt\textbf{S}\hskip
1.2pt(\mathit{c}_{1},x)\thickspace\wedge\thickspace\hskip
1.2pt\textbf{S}\hskip
1.2pt(\mathit{c}_{2},x)\thickspace\wedge\thickspace\mathit{c}_{1}\neq\mathit{c}_{2}\thickspace\wedge\thickspace\neg\textbf{treats}(\mathit{c}_{1},\mathit{d}_{j})\thickspace\Rightarrow\thickspace\neg\textbf{treats}(\mathit{c}_{2},\mathit{d}_{j})\end{array}$

Table 2: PSL rules. The diagrams show inferred edges (black) based on observed
nodes and edges (gray), drug nodes (green), and disease nodes (red). Variables
$\mathit{c}_{i}$ and $\mathit{d}_{j}$ range over drugs and diseases,
respectively. The first two rules serve as priors on the Treats relation. The
relation R can be has_associated_morphology, has_course, or has_finding_site.
The relation S can be has_route, has_substance, has_doseform, or
has_pharmclass. The variable $x$ in turn ranges over the semantically
appropriate entities given the relation in question. For the Clinical
Narratives Graph, both R and S have only the value is_mentioned_in and $x$
ranges over clinical narratives.

Our core task is to identify drug–disease Treats relations based on the drug’s
label text. We consider text-only, graph-only, and combined approaches to this
problem.

###  4.1 Text-Only Model

Our text-only model is a separately optimized conditional random fields (CRF;
Lafferty et al. 2001) model trained on 2,000 annotated sentences sampled from
the full dataset of FDA drug labels. When this CRF is used in isolation, we
say that a drug $\mathit{c}_{i}$ treats a disease $\mathit{d}_{j}$ just in
case our trained CRF identifies at least one Treats span describing
$\mathit{d}_{j}$ in the label for $\mathit{c}_{i}$. To incorporate this CRF
into our PSL models, we simply add two logical statements: one to influence
the prediction confidence positively, another negatively (table 2, rules
1a,b). This encodes the goal of agreeing with this model’s predictions.

###  4.2 PSL Graph Rules

Our PSL rules fall into a few major classes. The guiding intuitions are that
(i) relations connecting the same drug–disease pairs should have the same
confidence, (ii) drugs that have nodes in common should treat the same
diseases, and (iii) diseases that have nodes in common should be treated by
the same drugs. Table 2 schematizes the full set of rules that we define over
both our graphs.

###  4.3 Optimization

We use the Probabilistic Soft Logic package.666http://psl.linqs.org Details
about our optimization choices are given in appendix A.2. The rules for our
full model (all instances of the schemas in table 2), along with their learned
weights and groundings (supporting graph configurations), are given in
appendix A.3.

##  5 Experiments

Figure 2 reports our main results (see appendix A.1 for additional
experimental details). Both the CRF and the graph rules make positive
contributions, and any combination of these two sources of information is
superior to its text-only or graph-only ablations. Furthermore, our Clinical
Narratives Graph proves extremely powerful despite its simplistic
construction. Numerically, our best model for essentially any amount of
evidence is one that includes rules that reason about both graphs in addition
to the CRF predictions, though using the Narratives Graph alone is highly
competitive with this larger one. These findings strongly support our core
hypothesis that information extraction from drug labels can benefit from both
text analysis and graph-derived information.

Figure 2: Area under the Precision-Recall curve (AUC) as function of evidence
ratio (proportion of drug-disease edges that are observed). We favor AUC over
receiver–operator curve (ROC) because the dataset is highly imbalanced – only
24.8% of relations are positive for the Treats label. Results are averaged
over 100 runs for each model.

##  6 Conclusion

We presented evidence that combining text analysis with PSL rules defined over
a knowledge graph can improve predictions about drug–disease treatment
relations, and we showed that this can be effective even where the graph is
derived heuristically from clinical texts, which means that the techniques can
be applied even in domains that lack rich, broad coverage ontologies.

## References

  * Bach et al. (2013) Stephen Bach, Bert Huang, Ben London, and Lise Getoor. 2013.  Hinge-loss Markov random fields: Convex inference for structured prediction.  arXiv:1309.6813.
  * Boyd et al. (2011) Stephen Boyd, Neal Parikh, Eric Chu, Borja Peleato, Jonathan Eckstein, et al. 2011\.  Distributed optimization and statistical learning via the alternating direction method of multipliers.  _Foundations and Trends in Machine learning_ , 3(1):1–122.
  * Bröcheler et al. (2010) Matthias Bröcheler, Lilyana Mihalkova, and Lise Getoor. 2010.  Probabilistic similarity logic.  In _Proceedings of the Twenty-Sixth Conference on Uncertainty in Artificial Intelligence_ , UAI’10, pages 73–82, Arlington, Virginia, United States. AUAI Press.
  * Dawid and Skene (1979) Alexander Philip Dawid and Allan M Skene. 1979.  Maximum likelihood estimation of observer error-rates using the EM algorithm.  _Applied statistics_ , pages 20–28.
  * Fakhraei et al. (2013) Shobeir Fakhraei, Louiqa Raschid, and Lise Getoor. 2013.  Drug-target interaction prediction for drug repurposing with probabilistic similarity logic.  In _Proceedings of the 12th International Workshop on Data Mining in Bioinformatics_ , pages 10–17. ACM.
  * Hristovski et al. (2006) Dimitar Hristovski, Carol Friedman, Thomas C Rindflesch, and Borut Peterlin. 2006\.  Exploiting semantic relations for literature-based discovery.  In _AMIA annual symposium proceedings_ , volume 2006, page 349. American Medical Informatics Association.
  * Lafferty et al. (2001) John Lafferty, Andrew McCallum, and Fernando Pereira. 2001.  Conditional random fields: Probabilistic models for segmenting and labeling sequence data.  In _Proceedings of ICML-01_ , pages 282–289.
  * Shrank and Avorn (2007) William H Shrank and Jerry Avorn. 2007.  Educating patients about their medications: the potential and limitations of written drug information.  _Health Affairs_ , 26(3):731–740.
  * Uzuner (2009) Özlem Uzuner. 2009.  Recognizing obesity and comorbidities in sparse data.  _Journal of the American Medical Informatics Association_ , 16(4):561–570.
  * West et al. (2014) Robert West, Hristo S. Paskov, Jure Leskovec, and Christopher Potts. 2014.  Exploiting social network structure for person-to-person sentiment analysis.  _Transactions of the Association for Computational Linguistics_ , 2(2):297–310.

##  Appendix A Supplemental Material

###  A.1 Experimental Details

For each run, we sample two distinct sets of diseases. Then, with each set, we
create a subgraph by considering all the drugs adjacent to these diseases, and
the edges between these drugs and diseases. The two subgraphs have distinct
disease nodes, distinct edges, and some drug nodes in common. One of these
subgraphs is used for training, the other one for evaluation. In each
subgraph, we sample 25% of the edges that are used for prediction. Depending
on the evidence ratio, some of the remaining 75% of the edges are provided as
observations to the model. For evidence ratio = 0.75 for example, 75% of the
edges in each subgraph are observed and the other 25% are predicted by models.

###  A.2 Optimization details

In training, initial weight values are very important. Whatever the learning
rate and number of steps, it is easy to get stuck in local optima. We computed
the initial weights using the number of groundings for each rule, such that
(i) each source of information (CRF, ontologies, narratives) has the same
contribution, and (ii) for a given source of information, each rule has the
same contribution.

The weights were learned by optimizing the pseudo-log-likelihood of the data
using the voted perceptron algorithm, as implemented by the PSL package. We
preferred the pseudo-log-likelihood to the log-likelihood for scalability
reasons.

Each model was trained over 10 iterations, with a training step of 1.

For inference, we used the Alternating Direction Method of Multipliers (ADMM;
Boyd et al. 2011), as implemented by the PSL package. Consensus and local
variables were initialized to a fixed value (0.25, close to the true positive
Treats edge ratio), instead of randomly, to speed up convergence. The absolute
and relative error components of stopping criteria were set to $10^{-6}$, with
a maximum of 25,000 iterations.

###  A.3 Learned weights and groundings

Rule | Relative learned weight | Groundings
---|---|---
Prior (positive) | 1.10 | 431
Prior (negative) | 0.87 | 431
Rule 1a | 1.02 | 107
Rule 1b | 0.98 | 324
Rule 2a with $\textbf{R}=\textbf{has\\_associated\\_morphology}$ | 1.05 | 3
Rule 2b with $\textbf{R}=\textbf{has\\_associated\\_morphology}$ | 1.11 | 30
Rule 2a with $\textbf{R}=\textbf{has\\_course}$ | $-$ | 0
Rule 2b with $\textbf{R}=\textbf{has\\_course}$ | 0.97 | 14
Rule 2a with $\textbf{R}=\textbf{has\\_finding\\_site}$ | 1.13 | 37
Rule 2b with $\textbf{R}=\textbf{has\\_finding\\_site}$ | 0.88 | 45
Rule 3a with $\hskip 1.2pt\textbf{S}\hskip 1.2pt=\textbf{has\\_route}$ | 3.09 | 347
Rule 3b with $\hskip 1.2pt\textbf{S}\hskip 1.2pt=\textbf{has\\_route}$ | 0.00 | 1,095
Rule 3a with $\hskip 1.2pt\textbf{S}\hskip 1.2pt=\textbf{has\\_substance}$ | 1.36 | 65
Rule 3b with $\hskip 1.2pt\textbf{S}\hskip 1.2pt=\textbf{has\\_substance}$ | 1.00 | 140
Rule 3a with $\hskip 1.2pt\textbf{S}\hskip 1.2pt=\textbf{has\\_doseform}$ | 1.99 | 164
Rule 3b with $\hskip 1.2pt\textbf{S}\hskip 1.2pt=\textbf{has\\_doseform}$ | 0.77 | 384
Rule 3a with $\hskip 1.2pt\textbf{S}\hskip 1.2pt=\textbf{has\\_pharmclass}$ | 1.00 | 52
Rule 3b with $\hskip 1.2pt\textbf{S}\hskip 1.2pt=\textbf{has\\_pharmclass}$ | 1.00 | 101
Rule 2a with $\textbf{R}=\textbf{is\\_mentioned\\_in}$ | 22.12 | 29,803
Rule 2b with $\textbf{R}=\textbf{is\\_mentioned\\_in}$ | 0.0 | 115,251
Rule 3a with $\hskip 1.2pt\textbf{S}\hskip 1.2pt=\textbf{is\\_mentioned\\_in}$ | 7.42 | 2,568
Rule 3b with $\hskip 1.2pt\textbf{S}\hskip 1.2pt=\textbf{is\\_mentioned\\_in}$ | 0.90 | 14,062
Table A1: Learned weights and groundings in our full model (evidence ratio =
0.75). Rule numbers refer to the schemas in table 2. Weights are relative to
their initial value (ratio of the learned weight over its respective initial
weight). Weights assigned to “positive” rules are often larger than the weight
of their respective negative rule, which suggests that positive groundings are
usually more informative than negative ones. For example, drugs that have the
same route are more likely to have the same positive Treats edges than to have
the same negative Treats edges.


# Magnonic spin Joule heating and rectification effects

Morten Amundsen  Nordita, KTH Royal Institute of Technology and Stockholm
University, Hannes Alfvéns väg 12, SE-106 91 Stockholm, Sweden  I. V. Bobkova
Institute of Solid State Physics, Chernogolovka, 142432 Moscow , Russia
Moscow Institute of Physics and Technology, Dolgoprudny, 141700 Moscow, Russia
National Research University Higher School of Economics, Moscow, 101000 Russia
Akashdeep Kamra  Condensed Matter Physics Center (IFIMAC) and Departamento de
Física Teórica de la Materia Condensada, Universidad Autónoma de Madrid,
E-28049 Madrid, Spain

###### Abstract

Nonlinear devices, such as transistors, enable contemporary computing
technologies. We theoretically investigate nonlinear effects, bearing a high
fundamental scientific and technical relevance, in magnonics with emphasis on
superconductor-ferromagnet hybrids. Accounting for finite magnon chemical
potential, we theoretically demonstrate magnonic spin-Joule heating, the spin
analogue of conventional electronic Joule heating. Besides suggesting a key
contribution to magnonic heat transport in a broad range of devices, it
provides insights into the thermal physics of non-conserved bosonic
excitations. Considering a spin-split superconductor self-consistently, we
demonstrate its interface with a ferromagnetic insulator to harbor large
tunability of spin and thermal conductances. We further demonstrate hysteretic
rectification I-V characteristics in this hybrid, where the hysteresis results
from the superconducting state bistability.

Introduction.–The spin carriers in magnetic insulators - magnons - constitute
a fertile platform for science and technology due to their nonconserved
bosonic nature as well as solid-state host that admits strong interactions.
Since they transport information without a movement of electrons, and Joule
heating due to charge current flow, they are also touted as low-dissipation
alternatives to electrons as information carriers [1, 2, 3, 4, 5, 6, 7, 8, 9,
10]. While magnon chemical potential vanishes in equilibrium due to their
nonconserved nature, it becomes nonzero in nonequilibrium situations due to
their almost conserved nature at short time scales. This underlies a vast
range of phenomena such as Bose-Einstein condensation [11, 12, 13] and spin
transport [14, 15, 16, 17], where the importance of nonzero chemical potential
in these phenomena has recently been, and continues to be, recognized [18,
14]. Overall, a broad range of magnonic devices have already been demonstrated
[19, 20, 21, 22, 23, 24, 25, 26, 17].

From the perspective of both devices and exciting physics, nonlinearities are
highly desired, whether for unconventional computing paradigms [27] or
Maxwell’s daemon-like switches [28, 29]. In this context, the high potential
of synergy between magnonics and superconductors has just begun to be realized
[30, 31, 32, 33]. The latter admit strong nonlinear effects since a new and
small energy scale - the superconducting gap - determines properties such as
quasiparticle density of states [34, 35, 36, 37]. Recent years have seen an
upsurge of activity in this context with several exciting phenomena discussed,
experimentally [38, 39, 40, 41, 42, 43, 33, 44, 45, 46] as well as
theoretically [35, 36, 37, 47, 48, 49, 50, 51, 52, 53]. However, the
possibility of transport influencing, and even destroying, the superconducting
state was not considered. This consideration is the pinnacle of nonlinearity
offered by superconductor and has been exploited successfully in various
charge transport based devices [54, 55, 56].

Here, we theoretically investigate spin and heat transport in hybrids
consisting of a superconductor (S) interfaced with a ferromagnetic insulator
(FI). Our focus is on exploiting the strong nonlinearities available in this
hybrid for new device concepts and fundamental physics. Hence, we evaluate the
superconducting state self-consistently. Our first key finding is that
magnonic spin current flow results in a spin-Joule heating given by
$I_{m}^{2}R_{m}$, where $I_{m}$ is the magnon current and $R_{m}$ is the spin
resistance. This finding is not specific to the hybrids considered and bears
relevance for magnon chemical potential driven spin transport in general. In
bulk magnets, the spin-Joule heating power per unit volume becomes
$\boldsymbol{j}_{m}^{2}\rho_{m}$. Here, $\boldsymbol{j}_{m}$ is the magnon
current density and $\rho_{m}$, the spin resistivity, is defined via
$\boldsymbol{j}_{m}=-\boldsymbol{\nabla}\mu_{m}/\rho_{m}$, where $\mu_{m}$ is
the magnon chemical potential [14]. Our second set of findings demonstrates a
control over the transport coefficients, such as spin and thermal
conductances, in the S-FI interface via spin-splitting in the S layer.
Further, via self-consistent calculations, we demonstrate a hysteretic
rectification effect in the spin current vs. spin chemical potential
difference. This is rooted in the dependence of the superconducting state on
the spin chemical potential, as the latter results in depairing of spin-
singlet Cooper pairs [30]. Besides the interesting directionality, such an
“I-V” characteristic could enable devices with inbuilt memory and threshold
behavior, beneficial in some unconventional computing architectures [27].

Figure 1: In (a) is shown a sketch of the system under consideration. A Zeeman
split superconductor is placed in contact with a ferromagnetic insulator. (b)
illustrates the physical picture, for a case where a magnon is absorbed at the
interface. Since the magnon has a spin of $-\hbar$, only a spin-flip process
in which a spin up ($+\hbar/2$) quasiparticle is converted to spin down
($-\hbar/2$) is then allowed. Due to the Zeeman splitting, the gap for such a
process to occur is higher when the exchange field $h$ is parallel to the
magnetization of the ferromagnetic insulator, and vice versa.

Spin-Joule heating.–Considering an interface between an FI and S [Fig. 1 (a)],
the heat generated per unit time in FI and S is given by
$\dot{Q}_{\text{FI}}=\dot{E}_{\text{FI}}-\mu_{m}\dot{N}_{m}$ and
$\dot{Q}_{S}=\dot{E}_{S}-\mu_{s}\dot{N}_{s}$. Here, $\dot{E}_{\text{FI}}$
($\dot{E}_{\text{S}}$) is the rate of energy change in FI (S), $\mu_{m}$ is
the magnon chemical potential in FI, $\mu_{s}$ is the spin accumulation in S,
$\dot{N}_{m}$ is the rate of magnon number change in FI, and $\dot{N}_{s}$ is
the rate of electron-hole pair change in S [13]. On account of energy and spin
conservation, we obtain: $\dot{E}_{\text{S}}=-\dot{E}_{FI}\equiv\dot{E}$ and
$\dot{N}_{s}=-\dot{N}_{m}\equiv\dot{N}\equiv I_{s}/\hbar$, with $I_{s}$ the
spin current across the interface. Here, the inclusion of $\mu_{m,s}$ terms in
the definition of heat [57] is necessary when considering effects, such as
heat generation, up to second order in $\mu_{m,s}$. The physical justification
of this contribution, which is well-known for electrons [58, 59], is as
follows. A particle added to an ensemble at an energy below the chemical
potential needs to absorb energy from other particles in order to respect the
statistical distribution enforced by a nonzero chemical potential [58]. Thus,
this causes a cooling of the ensemble as a whole.

The average heat flow from FI to S is obtained as
$\dot{Q}\equiv(\dot{Q}_{S}-\dot{Q}_{FI})/2=\dot{E}-\bar{\mu}I_{s}/\hbar$, with
$\bar{\mu}\equiv(\mu_{m}+\mu_{s})/2$. Before we evaluate the spin and heat
flow across the interface below, we pause to examine the total heat generation
$\Delta\dot{Q}\equiv\dot{Q}_{S}+\dot{Q}_{FI}$ in our system. Considering
temperature to remain uniform, the heat generation due to chemical potential
driven spin transport is simplified to:

$\displaystyle\Delta\dot{Q}$ $\displaystyle=I_{m}\Delta\mu=I_{m}^{2}R_{m},$
(1)

where $I_{m}\equiv I_{s}/\hbar$, $\Delta\mu\equiv\mu_{m}-\mu_{s}$, and the
linear response relation $I_{m}=\Delta\mu/R_{m}$ will be derived below. This
is the spin analogue of Joule heating expression for charge current flow
across an interface. A generalization of this result to an interface between
two FIs with different magnon chemical potentials leads to a similar
expression for the heating. In the continuum limit, this leads to magnonic
spin-Joule heating power per unit volume in the FI bulk:

$\displaystyle P$ $\displaystyle=\boldsymbol{j}_{m}^{2}\rho_{m},$ (2)

where $\boldsymbol{j}_{m}=-\boldsymbol{\nabla}\mu_{m}/\rho_{m}$ is the magnon
current density and $\rho_{m}$, the magnon spin resistivity.

Equation (2) is a general result with broad consequences for magnonic spin
transport in different materials, hybrids, and regimes. The charge
conservation allows for relating electronic Joule heating directly to work
done by the external battery [59]. Such a straightforward identification does
not appear possible for magnonic spin transport. Nevertheless, the spin-Joule
heating is also derived from the work done by external sources that maintain
nonzero chemical potentials in the system. Due to the high sensitivity of
superconductor-based thermometers [60], the FI/S hybrids investigated below
offer a suitable platform for an experimental measurement of the spin-Joule
heating.

Spin and heat currents in linear response.–We consider the system shown in
Fig. 1(a). A superconductor is placed in contact with a ferromagnetic
insulator, and a spin splitting field $h$ is introduced to the former. This
system may be influenced by a spin chemical potential on the superconductor
side, a nonequilibrium magnon chemical potential on the ferromagnetic
insulator side, or a temperature gradient across the system, all of which may
result in the flow of heat and spin currents due to exchange interactions
between electrons and magnons at the interface. We show that the spin
splitting field leads to a significant asymmetry in the transport properties
of the heterostructure, with respect to the orientation of $h$. The main
physics behind this effect illustrated in Fig. 1(b). Spin can be transmitted
between the two materials when, e.g., a spin down quasiparticle in the
superconductor experiences a spin flip upon reflection at the interface,
accompanied by the creation of a magnon in the ferromagnetic insulator, or
vice versa. At low temperatures, this process is suppressed due to the
presence of the superconducting gap. However, the size of this gap can be
tuned by $h$. In a spin split superconductor, the density of states for the
two spin species is shifted relative to each other by a value of $2h$ [35, 37,
30]. This means that the effective gap that must be overcome by a spin-down
quasiparticle undergoing a spin flip is increased if the spin splitting field
is parallel to the magnetization in the ferromagnetic insulator ($h>0$), or
reduced if it is antiparallel ($h<0$). Hence, the latter configuration is more
amenable to the generation of transport currents.

We study the interface between the superconductor and the ferromagnetic
insulator using a tunneling Hamiltonian approach [13, 15, 47, 48, 61],

$\displaystyle H=H_{\text{SC}}+H_{\text{FI}}+H_{\text{int}},$ (3)

where $H_{SC}$ describes a Zeeman split superconductor,

$\displaystyle H_{\text{SC}}=$
$\displaystyle\sum_{ks}\xi_{k}c^{\dagger}_{ks}c_{ks}-\sum_{k}\left[\Delta
c^{\dagger}_{k\uparrow}c^{\dagger}_{-k\downarrow}+\Delta^{*}c_{k\downarrow}c_{-k\uparrow}\right]$
$\displaystyle-\sum_{k}\sum_{ss^{\prime}}h\sigma^{z}_{ss^{\prime}}c^{\dagger}_{ks}c_{ks^{\prime}},$
(4)

with $\xi_{k}=\hbar^{2}\bm{k}^{2}/2m-\mu$, with chemical potential $\mu$, and
$h$ is the exchange field, assumed to be directed along the $z$ axis. The
Hamiltonian of the ferromagnetic insulator is given within the Holstein-
Primakoff approximation as [62]

$\displaystyle H_{\text{FI}}=\sum_{k}\hbar\omega_{k}a_{k}^{\dagger}a_{k},$ (5)

with magnon operators $a_{k}$ and $a_{k}^{\dagger}$. We assume a quadratic
dispersion of the form $\hbar\omega_{k}=\Delta_{m}+J_{m}\bm{k}^{2}$. The two
materials may communicate by the exchange of spin, in which a magnon on the
ferromagnet side is either absorbed or created by a quasiparticle spin flip on
the superconductor side. This process is captured by [48]

$\displaystyle
H_{\text{int}}=\sum_{kk^{\prime}}\left[W_{kk^{\prime}}s^{-}_{-k}a_{k^{\prime}}+W_{kk^{\prime}}^{*}s^{+}_{k}a_{k^{\prime}}^{\dagger}\right],$
(6)

with $s^{\pm}_{k}=s^{x}_{k}\pm s^{y}_{k}$, and
$s^{j}_{k}=\frac{\hbar}{2}\sum_{qss^{\prime}}\sigma^{j}_{ss^{\prime}}c^{\dagger}_{ks}c_{k+q,s^{\prime}}$.

The transport properties of this system are most conveniently studied on the
ferromagnetic insulator side, where the tunneling spin current becomes
$I_{s}=i\left\langle\left[N_{m},H\right]\right\rangle$, with
$N_{m}=\sum_{k}a^{\dagger}_{k}a_{k}$. This gives,

$\displaystyle I_{s}$
$\displaystyle=i\sum_{kk^{\prime}}\left\langle\left[W_{kk^{\prime}}s^{\dagger}_{k}a_{k^{\prime}}-W_{kk^{\prime}}^{*}s_{k}a_{k^{\prime}}^{\dagger}\right]\right\rangle.$
(7)

In a similar way, the average heat current is
$\dot{Q}=i\left\langle\left[H_{\text{FI}},H\right]\right\rangle/\hbar-\bar{\mu}I_{s}/\hbar$,
giving

$\displaystyle\dot{Q}$
$\displaystyle=\frac{i}{\hbar}\sum_{kk^{\prime}}\left(\hbar\omega_{k^{\prime}}-\bar{\mu}\right)\left\langle\left[W_{kk^{\prime}}s^{\dagger}_{k}a_{k^{\prime}}-W_{kk^{\prime}}^{*}s_{k}a_{k^{\prime}}^{\dagger}\right]\right\rangle.$
(8)

These quantities may be calculated by using Green function techniques [63],
resulting in

$\displaystyle I_{s}$ $\displaystyle=-2|W|^{2}V_{\text{FI}}\hbar\int
d\omega\;\nu_{m}(\hbar\omega)\chi_{s}(\hbar\omega)\times$ $\displaystyle\hskip
71.13188pt\left[n_{\text{FI}}(\hbar\omega-\mu_{m})-n_{\text{SC}}(\hbar\omega-\mu_{s})\right],$
(9) $\displaystyle\dot{Q}$ $\displaystyle=-2|W|^{2}V_{\text{FI}}\int
d\omega\;\left(\hbar\omega-\bar{\mu}\right)\nu_{m}(\hbar\omega)\chi_{s}(\hbar\omega)\times$
$\displaystyle\hskip
71.13188pt\left[n_{\text{FI}}(\hbar\omega-\mu_{m})-n_{\text{SC}}(\hbar\omega-\mu_{s})\right],$
(10)

under the approximation of $W_{kk^{\prime}}\simeq W$. Here, $V_{\text{FI}}$ is
the volume of the FI,
$n_{j}(\varepsilon)=\left[e^{\varepsilon/k_{\text{B}}T_{j}}-1\right]^{-1}$ is
the Bose-Einstein distribution function in material $j$,
$\nu_{m}(\varepsilon)=\sqrt{\varepsilon-\Delta_{m}}/4\pi^{2}J_{s}^{3/2}$ is
the magnon density of states and

$\displaystyle\chi_{s}(\hbar\omega)=-\pi\hbar^{2}$ $\displaystyle
V_{\text{SC}}^{2}\nu_{0}^{2}\int
d\varepsilon\;F_{\Delta}\nu(\varepsilon+h)\nu(\varepsilon+\hbar\omega-h)\times$
$\displaystyle\left[f(\varepsilon+\hbar\omega-\mu_{s}/2)-f(\varepsilon+\mu_{s}/2)\right]$
(11)

is the transverse spin susceptibility of the superconductor, with
$\nu(\varepsilon)=\Re\left[|\varepsilon|/\sqrt{\varepsilon^{2}-|\Delta|^{2}}\right]$
the superconducting density of states,
$F_{\Delta}=1+|\Delta|^{2}/(\varepsilon+h)(\varepsilon+\hbar\omega-h)$ the
coherence factor, and
$f(\varepsilon)=\left[e^{\varepsilon/k_{\text{B}}T}+1\right]^{-1}$ the Fermi-
Dirac distribution function.

Figure 2: The asymmetry of the linear-response coefficients with respect to
the direction of the exchange field $h$, as a function of $|h|$, shown here
for a selection of temperatures. Here
$P_{x}=(x_{\uparrow}-x_{\downarrow})/(x_{\uparrow}+x_{\downarrow})$, with the
arrows indicating the sign of the exchange field, and $x$ representing (a) the
spin conductance $G$, (b) the spin Seebeck coefficient, and (c) the heat
conductance. The sharp turns observed in the figure are due to the $h$
crossing the critical value $h_{c}$ at which superconductivity is destroyed.
Figure 3: The spin and heat current as a function of the chemical potential
difference, $\Delta\mu$, exhibiting a switching effect in which both $I_{s}$
and $\dot{Q}$ exhibit a jump in magnitude on the order of
$\mathrm{1}\mathrm{0}\mathrm{0}$. Here, an exchange field of $h=0.7\Delta_{0}$
is applied, which is close to the critical field at which superconductivity is
destroyed. We have set $T_{\text{SC}}=0.1T_{c}$, $T_{\text{FI}}=0.5T_{c}$, and
$\mu_{m}=0$. The red (blue) curve describes a situation in which
superconductivity is regained (destroyed). These two curves are different due
to the hysteresis caused by the bistability of the superconducting gap
$\Delta$ as a function of the effective spin splitting
$h_{\text{eff}}=h-\mu_{s}/2$, as shown in the inset. Here,
$I_{0}=|W|^{2}V_{\text{FI}}\hbar\chi_{0}\Delta_{0}/2\pi^{2}J_{s}^{2/3}$, with
$\chi_{0}=\pi\hbar^{2}V_{\text{SC}}^{2}\nu_{0}^{2}\Delta_{0}$, and
$Q_{0}=I_{0}\Delta_{0}/\hbar$.

For small temperature differences across the tunnel junction, $\Delta
T=T_{\text{FI}}-T_{\text{SC}}$, or a small difference in chemical potentials,
$\Delta\mu=\mu_{m}-\mu_{s}$, Eqs. 9 and 10 may be linearized, to obtain

$\displaystyle\begin{pmatrix}I_{s}\\\
\dot{Q}\end{pmatrix}\simeq\begin{pmatrix}G&\hbar\alpha\\\ \alpha&\kappa
T\end{pmatrix}\begin{pmatrix}\Delta\mu\\\ \Delta T/T\end{pmatrix},$ (12)

with $T=\left(T_{\text{FI}}+T_{\text{SC}}\right)/2$. This defines the spin
conductivity $G$, the spin-dependent Seebeck coefficient $\alpha$, and the
heat conductivity $\kappa$ as

$\displaystyle G$ $\displaystyle=-2|W|^{2}V_{\text{FI}}\hbar\int
d\omega\;\frac{\chi_{s}(\hbar\omega)\nu_{m}(\hbar\omega)}{4k_{\text{B}}T\sinh^{2}\frac{\hbar\omega-\bar{\mu}}{2k_{\text{B}}T}},$
(13) $\displaystyle\alpha$ $\displaystyle=-2|W|^{2}V_{\text{FI}}\int
d\omega\;\frac{\left(\hbar\omega-\bar{\mu}\right)\chi_{s}(\hbar\omega)\nu_{m}(\hbar\omega)}{4k_{\text{B}}T\sinh^{2}\frac{\hbar\omega-\bar{\mu}}{2k_{\text{B}}T}},$
(14) $\displaystyle\kappa$ $\displaystyle=-2|W|^{2}V_{\text{FI}}\int
d\omega\;\frac{\left(\hbar\omega-\bar{\mu}\right)^{2}\chi_{s}(\hbar\omega)\nu_{m}(\hbar\omega)}{4k_{\text{B}}T^{2}\sinh^{2}\frac{\hbar\omega-\bar{\mu}}{2k_{\text{B}}T}}.$
(15)

For concreteness, we set the critical temperature of the superconductor to
$T_{c}=$1\text{\,}\mathrm{K}$$, corresponding to a superconducting gap of
$\Delta_{0}=1.76k_{\text{B}}T_{c}\simeq$150\text{\,}\mathrm{\SIUnitSymbolMicro
eV}$$. This is consistent with the superconducting properties of aluminium
[64]. For the ferromagnetic insulator, a typical value the magnon gap is
$\Delta_{m}/k_{\text{B}}\simeq$1\text{\,}\mathrm{K}$$ [14], and so for
simplicity, we set $\Delta_{m}=\Delta_{0}$.

Control over the interfacial conductances and rectification.–To investigate
the effect of the spin splitting field $h$ on the transport coefficients given
in Eqs. 13, 14 and 15, we define the quantity
$P_{x}=(x_{\uparrow}-x_{\downarrow})/(x_{\uparrow}+x_{\downarrow})$, which we
refer to as the polarization of $x$, for
$x\in\left\\{G,\alpha,\kappa\right\\}$, where $\uparrow$ ($\downarrow$)
indicates $h>0$ ($h<0$). The result is shown in Fig. 2, for
$|h|\in\left[0,0.6\right]$ for a range of temperatures $T$. It is seen that
for the lowest temperature considered, $T/T_{c}=0.3$, there is a significant
polarization. It is negative, indicating that larger currents are to be
expected for $h<0$, consistent with the physical picture presented in Fig.
1(b). We also see that the effect diminishes as the temperature of the
heterostructure approaches $T_{c}$, at which point the superconductor
transitions to a normal metal, with no modulation of the density of states,
and thus no polarization.

The gap in the density of states, which is present in the superconducting
state, but not in the normal metal state, has the potential for an interesting
application. In the following, we set the temperature of the superconductor to
$T_{\text{SC}}=0.1T_{c}$, and in the FI to $T_{\text{FI}}=0.5T_{c}$. Hence, a
temperature gradient is maintained across the interface, and both spin and
heat currents are flowing between the two materials. On the other hand, the
magnitude of these currents is largely reduced compared to a normal metal due
to the superconducting gap. Next, we set the spin splitting field to
$h=0.7\Delta_{0}$. This is close to the critical field at which the
superconductor transitions to the normal state, but the size of the gap still
remains close to the maximal value $\Delta_{0}$, as evidenced by a self-
consistent determination of $\Delta(h)$. We note that the superconducting gap
responds to a spin chemical potential as [65]
$\Delta(h)\to\Delta(h_{\text{eff}})$, with $h_{\text{eff}}=h-\mu_{s}/2$.
Hence, if $\mu_{s}<0$, the two contributions will add up, which has the
potential of bringing the superconductor into the normal-state regime at some
critical field $h_{\text{eff}}^{-}$. In the opposite case, $\mu_{s}$ partially
cancels $h$, and the normal-state system returns to the superconducting state
at $h_{\text{eff}}^{+}$. We note that due to the hysteresis caused by the
bistability of $\Delta(h_{\text{eff}})$ in the transition region [66, 67, 68],
$h_{\text{eff}}^{+}$ is generally not equal to $h_{\text{eff}}^{-}$, as
indicated in the inset of Fig. 3. In any case, the point is that $\mu_{s}$ can
cause superconductivity to either be destroyed or regained, which produces an
abrupt change in the size of the currents. To illustrate this effect, we plot
$I_{s}$ and $\dot{Q}$, as given by Eqs. 9 and 10, in Fig. 3(a) and (b),
respectively, for $\Delta\mu/\Delta_{0}\in[-0.6,+0.6]$, keeping $\mu_{m}=0$
fixed. We find that both $I_{s}$ and $\dot{Q}$ feature jumps in magnitude on
the order of 100 when a transition takes place, for this parameter set.

Summary.– Exploiting the weaker energy scale of superconducting gap, we have
demonstrated a broad range of nonlinear effects in the context of magnonic
spin transport in superconductor-ferromagnetic insulator hybrids. The
predicted control over interfacial conductances and hysteretic rectification
I-V characteristics open avenues for integrating magnonic devices into
unconventional computing architectures, for example. Our theoretical
demonstration of magnonic spin-Joule heating provides valuable insights into
the wide range of studies and devices involving chemical potential-driven spin
transport.

###### Acknowledgements.

A.K. acknowledges financial support from the Spanish Ministry for Science and
Innovation – AEI Grant CEX2018-000805-M (through the “Maria de Maeztu”
Programme for Units of Excellence in R&D). I.V.B. acknowledges financial
support from Foundation for the Advancement of Theoretical Physics and
Mathematics “BASIS”.

## References

  * Bauer  _et al._ [2012] G. E. W. Bauer, E. Saitoh, and B. J. van Wees, Spin caloritronics, Nature Materials 11, 391 (2012).
  * Kruglyak  _et al._ [2010] V. V. Kruglyak, S. O. Demokritov, and D. Grundler, Magnonics, Journal of Physics D: Applied Physics 43, 264001 (2010).
  * Serga  _et al._ [2010] A. A. Serga, A. V. Chumak, and B. Hillebrands, YIG magnonics, Journal of Physics D: Applied Physics 43, 264002 (2010).
  * Chumak  _et al._ [2015] A. V. Chumak, V. Vasyuchka, A. Serga, and B. Hillebrands, Magnon spintronics, Nature Physics 2014 11:6 11, 453 (2015).
  * Chumak and Schultheiss [2017] A. V. Chumak and H. Schultheiss, Magnonics: spin waves connecting charges, spins and photons, Journal of Physics D: Applied Physics 50, 300201 (2017).
  * Althammer [2018] M. Althammer, Pure spin currents in magnetically ordered insulator/normal metal heterostructures, Journal of Physics D: Applied Physics 51, 313001 (2018).
  * Althammer [2021] M. Althammer, All-Electrical Magnon Transport Experiments in Magnetically Ordered Insulators, physica status solidi (RRL) – Rapid Research Letters 15, 2100130 (2021).
  * Pirro  _et al._ [2021] P. Pirro, V. I. Vasyuchka, A. A. Serga, and B. Hillebrands, Advances in coherent magnonics, Nature Reviews Materials 2021 , 1 (2021).
  * Barman  _et al._ [2021] A. Barman, G. Gubbiotti, S. Ladak, A. O. Adeyeye, M. Krawczyk, J. Gräfe, C. Adelmann, S. Cotofana, A. Naeemi, V. I. Vasyuchka, B. Hillebrands, S. A. Nikitov, H. Yu, D. Grundler, A. V. Sadovnikov, A. A. Grachev, S. E. Sheshukova, J.-Y. Duquesne, M. Marangolo, G. Csaba, W. Porod, V. E. Demidov, S. Urazhdin, S. O. Demokritov, E. Albisetti, D. Petti, R. Bertacco, H. Schultheiss, V. V. Kruglyak, V. D. Poimanov, S. Sahoo, J. Sinha, H. Yang, M. Münzenberg, T. Moriyama, S. Mizukami, P. Landeros, R. A. Gallardo, G. Carlotti, J.-V. Kim, R. L. Stamps, R. E. Camley, B. Rana, Y. Otani, W. Yu, T. Yu, G. E. W. Bauer, C. Back, G. S. Uhrig, O. V. Dobrovolskiy, B. Budinska, H. Qin, S. van Dijken, A. V. Chumak, A. Khitun, D. E. Nikonov, I. A. Young, B. W. Zingsem, and M. Winklhofer, The 2021 Magnonics Roadmap, Journal of Physics: Condensed Matter 33, 413001 (2021).
  * Nakata  _et al._ [2017] K. Nakata, P. Simon, and D. Loss, Spin currents and magnon dynamics in insulating magnets, Journal of Physics D: Applied Physics 50, 114004 (2017).
  * Demokritov  _et al._ [2006] S. O. Demokritov, V. E. Demidov, O. Dzyapko, G. A. Melkov, A. A. Serga, B. Hillebrands, and A. N. Slavin, Bose–Einstein condensation of quasi-equilibrium magnons at room temperature under pumping, Nature 2006 443:7110 443, 430 (2006).
  * Demidov  _et al._ [2008] V. E. Demidov, O. Dzyapko, S. O. Demokritov, G. A. Melkov, and A. N. Slavin, Observation of Spontaneous Coherence in Bose-Einstein Condensate of Magnons, Physical Review Letters 100, 047205 (2008).
  * Bender  _et al._ [2012] S. A. Bender, R. A. Duine, and Y. Tserkovnyak, Electronic pumping of quasiequilibrium bose-einstein-condensed magnons, Physical Review Letters 108, 246601 (2012).
  * Cornelissen  _et al._ [2016] L. J. Cornelissen, K. J. H. Peters, G. E. W. Bauer, R. A. Duine, and B. J. van Wees, Magnon spin transport driven by the magnon chemical potential in a magnetic insulator, Physical Review B 94, 014412 (2016).
  * Kamra and Belzig [2016] A. Kamra and W. Belzig, Magnon-mediated spin current noise in ferromagnet — nonmagnetic conductor hybrids, Physical Review B 94, 014419 (2016).
  * Olsson  _et al._ [2020] K. S. Olsson, K. An, G. A. Fiete, J. Zhou, L. Shi, and X. Li, Pure Spin Current and Magnon Chemical Potential in a Nonequilibrium Magnetic Insulator, Physical Review X 10, 021029 (2020).
  * Schlitz  _et al._ [2021] R. Schlitz, S. Vélez, A. Kamra, C.-H. Lambert, M. Lammel, S. T. Goennenwein, and P. Gambardella, Control of Nonlocal Magnon Spin Transport via Magnon Drift Currents, Physical Review Letters 126, 257201 (2021).
  * Du  _et al._ [2017] C. Du, T. van der Sar, T. X. Zhou, P. Upadhyaya, F. Casola, H. Zhang, M. C. Onbasli, C. A. Ross, R. L. Walsworth, Y. Tserkovnyak, and A. Yacoby, Control and local measurement of the spin chemical potential in a magnetic insulator, Science 357, 195 (2017).
  * Kajiwara  _et al._ [2010] Y. Kajiwara, K. Harii, S. Takahashi, J. Ohe, K. Uchida, M. Mizuguchi, H. Umezawa, H. Kawai, K. Ando, K. Takanashi, S. Maekawa, and E. Saitoh, Transmission of electrical signals by spin-wave interconversion in a magnetic insulator, Nature 2010 464:7286 464, 262 (2010).
  * Cornelissen  _et al._ [2015] L. J. Cornelissen, J. Liu, R. A. Duine, J. B. Youssef, and B. J. van Wees, Long-distance transport of magnon spin information in a magnetic insulator at room temperature, Nature Physics 2015 11:12 11, 1022 (2015).
  * Goennenwein  _et al._ [2015] S. T. B. Goennenwein, R. Schlitz, M. Pernpeintner, K. Ganzhorn, M. Althammer, R. Gross, and H. Huebl, Non-local magnetoresistance in YIG/Pt nanostructures, Applied Physics Letters 107, 172405 (2015).
  * Shan  _et al._ [2017] J. Shan, P. Bougiatioti, L. Liang, G. Reiss, T. Kuschel, and B. J. van Wees, Nonlocal magnon spin transport in NiFe2O4 thin films, Applied Physics Letters 110, 132406 (2017).
  * Cornelissen  _et al._ [2018] L. Cornelissen, J. Liu, B. van Wees, and R. Duine, Spin-Current-Controlled Modulation of the Magnon Spin Conductance in a Three-Terminal Magnon Transistor, Physical Review Letters 120, 097702 (2018).
  * Wimmer  _et al._ [2019] T. Wimmer, M. Althammer, L. Liensberger, N. Vlietstra, S. Geprägs, M. Weiler, R. Gross, and H. Huebl, Spin transport in a magnetic insulator with zero effective damping, Phys. Rev. Lett. 123, 257201 (2019).
  * Wimmer  _et al._ [2020] T. Wimmer, A. Kamra, J. Gückelhorn, M. Opel, S. Geprägs, R. Gross, H. Huebl, and M. Althammer, Observation of antiferromagnetic magnon pseudospin dynamics and the hanle effect, Phys. Rev. Lett. 125, 247204 (2020).
  * An  _et al._ [2021] K. An, R. Kohno, N. Thiery, D. Reitz, L. Vila, V. V. Naletov, N. Beaulieu, J. B. Youssef, G. de Loubens, Y. Tserkovnyak, and O. Klein, Short-range thermal magnon diffusion in magnetic garnet, Physical Review B 103, 174432 (2021).
  * Marković  _et al._ [2020] D. Marković, A. Mizrahi, D. Querlioz, and J. Grollier, Physics for neuromorphic computing, Nature Reviews Physics 2, 499 (2020).
  * Kish and Granqvist [2012] L. B. Kish and C.-G. Granqvist, Electrical maxwell demon and szilard engine utilizing johnson noise, measurement, logic and control, PLOS ONE 7, 1 (2012).
  * Koski and Pekola [2016] J. V. Koski and J. P. Pekola, Maxwell’s demons realized in electronic circuits, Comptes Rendus Physique 17, 1130 (2016), mesoscopic thermoelectric phenomena / Phénomènes thermoélectriques mésoscopiques.
  * Bergeret  _et al._ [2018] F. S. Bergeret, M. Silaev, P. Virtanen, and T. T. Heikkilä, Colloquium: Nonequilibrium effects in superconductors with a spin-splitting field, Reviews of Modern Physics 90, 041001 (2018), arXiv:1706.08245 .
  * Heikkilä  _et al._ [2019] T. T. Heikkilä, M. Silaev, P. Virtanen, and F. S. Bergeret, Thermal, electric and spin transport in superconductor/ferromagnetic-insulator structures, Progress in Surface Science 94, 100540 (2019).
  * Yang  _et al._ [2021] G. Yang, C. Ciccarelli, and J. W. A. Robinson, Boosting spintronics with superconductivity, APL Materials 9, 050703 (2021).
  * Jeon  _et al._ [2020a] K.-R. Jeon, J.-C. Jeon, X. Zhou, A. Migliorini, J. Yoon, and S. S. P. Parkin, Giant Transition-State Quasiparticle Spin-Hall Effect in an Exchange-Spin-Split Superconductor Detected by Nonlocal Magnon Spin Transport, ACS Nano 14, 15874 (2020a).
  * Strambini  _et al._ [2017] E. Strambini, V. N. Golovach, G. D. Simoni, J. S. Moodera, F. S. Bergeret, and F. Giazotto, Revealing the magnetic proximity effect in EuS/Al bilayers through superconducting tunneling spectroscopy, Physical Review Materials 1, 054402 (2017).
  * Machon  _et al._ [2013] P. Machon, M. Eschrig, and W. Belzig, Nonlocal Thermoelectric Effects and Nonlocal Onsager relations in a Three-Terminal Proximity-Coupled Superconductor-Ferromagnet Device, Physical Review Letters 110, 47002 (2013).
  * Machon  _et al._ [2014] P. Machon, M. Eschrig, and W. Belzig, Giant thermoelectric effects in a proximity-coupled superconductor–ferromagnet device, New Journal of Physics 16, 73002 (2014).
  * Ozaeta  _et al._ [2014] A. Ozaeta, P. Virtanen, F. S. Bergeret, and T. T. Heikkilä, Predicted very large thermoelectric effect in ferromagnet-superconductor junctions in the presence of a spin-splitting magnetic field, Physical Review Letters 112, 057001 (2014).
  * Wolf  _et al._ [2014] M. J. Wolf, C. Sürgers, G. Fischer, and D. Beckmann, Spin-polarized quasiparticle transport in exchange-split superconducting aluminum on europium sulfide, Physical Review B 90, 144509 (2014).
  * Golovchanskiy  _et al._ [2018] I. A. Golovchanskiy, N. N. Abramov, V. S. Stolyarov, V. V. Bolginov, V. V. Ryazanov, A. A. Golubov, and A. V. Ustinov, Ferromagnet/Superconductor Hybridization for Magnonic Applications, Advanced Functional Materials 28, 1802375 (2018).
  * Dobrovolskiy  _et al._ [2019] O. V. Dobrovolskiy, R. Sachser, T. Brächer, T. Böttcher, V. V. Kruglyak, R. V. Vovk, V. A. Shklovskij, M. Huth, B. Hillebrands, and A. V. Chumak, Magnon–fluxon interaction in a ferromagnet/superconductor heterostructure, Nature Physics 2019 15:5 15, 477 (2019).
  * Li  _et al._ [2019] Y. Li, T. Polakovic, Y.-L. Wang, J. Xu, S. Lendinez, Z. Zhang, J. Ding, T. Khaire, H. Saglam, R. Divan, J. Pearson, W.-K. Kwok, Z. Xiao, V. Novosad, A. Hoffmann, and W. Zhang, Strong Coupling between Magnons and Microwave Photons in On-Chip Ferromagnet-Superconductor Thin-Film Devices, Physical Review Letters 123, 107701 (2019).
  * Jeon  _et al._ [2019] K. R. Jeon, C. Ciccarelli, H. Kurebayashi, L. F. Cohen, X. Montiel, M. Eschrig, S. Komori, J. W. Robinson, and M. G. Blamire, Exchange-field enhancement of superconducting spin pumping, Physical Review B 99, 024507 (2019).
  * Lachance-Quirion  _et al._ [2020] D. Lachance-Quirion, S. P. Wolski, Y. Tabuchi, S. Kono, K. Usami, and Y. Nakamura, Entanglement-based single-shot detection of a single magnon with a superconducting qubit, Science 367, 425 (2020).
  * Jeon  _et al._ [2020b] K.-R. Jeon, X. Montiel, S. Komori, C. Ciccarelli, J. Haigh, H. Kurebayashi, L. F. Cohen, A. K. Chan, K. D. Stenning, C.-M. Lee, M. Eschrig, M. G. Blamire, and J. W. Robinson, Tunable Pure Spin Supercurrents and the Demonstration of Their Gateability in a Spin-Wave Device, Physical Review X 10, 031020 (2020b).
  * Golovchanskiy  _et al._ [2020] I. Golovchanskiy, N. Abramov, V. Stolyarov, V. Chichkov, M. Silaev, I. Shchetinin, A. Golubov, V. Ryazanov, A. Ustinov, and M. Kupriyanov, Magnetization dynamics in proximity-coupled superconductor-ferromagnet-superconductor multilayers, Phys. Rev. Applied 14, 024086 (2020).
  * Golovchanskiy  _et al._ [2021] I. Golovchanskiy, N. Abramov, V. Stolyarov, M. Weides, V. Ryazanov, A. Golubov, A. Ustinov, and M. Kupriyanov, Ultrastrong photon-to-magnon coupling in multilayered heterostructures involving superconducting coherence via ferromagnetic layers, Science Advances 7, eabe8638 (2021).
  * Ohnuma  _et al._ [2017] Y. Ohnuma, M. Matsuo, and S. Maekawa, Theory of the spin Peltier effect, Physical Review B 96, 134412 (2017).
  * Kato  _et al._ [2019] T. Kato, Y. Ohnuma, M. Matsuo, J. Rech, T. Jonckheere, and T. Martin, Microscopic theory of spin transport at the interface between a superconductor and a ferromagnetic insulator, Physical Review B 99, 144411 (2019).
  * Chakraborty and Heikkilä [2019] S. Chakraborty and T. T. Heikkilä, Thermalization of hot electrons via interfacial electron-magnon interaction, Physical Review B 100, 035423 (2019).
  * Vargas and Moura [2020a] V. S. U. A. Vargas and A. R. Moura, Spin current injection at magnetic insulator/superconductor interfaces, Physical Review B 102, 024412 (2020a).
  * Vargas and Moura [2020b] V. S. Vargas and A. R. Moura, Injection of spin current at the superconductor/ferromagnetic insulator interface, Journal of Magnetism and Magnetic Materials 494, 165813 (2020b).
  * Ojajärvi  _et al._ [2021] R. Ojajärvi, T. T. Heikkilä, P. Virtanen, and M. A. Silaev, Giant enhancement to spin battery effect in superconductor/ferromagnetic insulator systems, Physical Review B 103, 224524 (2021).
  * Ahari and Tserkovnyak [2021] M. T. Ahari and Y. Tserkovnyak, Superconductivity-enhanced spin pumping: Role of Andreev resonances, Physical Review B 103, L100406 (2021).
  * Bardeen [1962] J. Bardeen, Critical fields and currents in superconductors, Rev. Mod. Phys. 34, 667 (1962).
  * Moraru  _et al._ [2006] I. C. Moraru, W. P. Pratt, and N. O. Birge, Magnetization-dependent ${T}_{c}$ shift in ferromagnet/superconductor/ferromagnet trilayers with a strong ferromagnet, Phys. Rev. Lett. 96, 037004 (2006).
  * Li  _et al._ [2013] B. Li, N. Roschewsky, B. A. Assaf, M. Eich, M. Epstein-Martin, D. Heiman, M. Münzenberg, and J. S. Moodera, Superconducting spin switch with infinite magnetoresistance induced by an internal exchange field, Phys. Rev. Lett. 110, 097001 (2013).
  * Nakata and Ohnuma [2021] K. Nakata and Y. Ohnuma, Magnonic thermal transport using the quantum boltzmann equation, Phys. Rev. B 104, 064408 (2021).
  * Taylor  _et al._ [2002] P. Taylor, P. Taylor, and O. Heinonen,  _A Quantum Approach to Condensed Matter Physics_ (Cambridge University Press, 2002).
  * Heikkilä [2013] T. Heikkilä,  _The Physics of Nanoelectronics: Transport and Fluctuation Phenomena at Low Temperatures_ , Oxford Master Series in Physics (OUP Oxford, 2013).
  * Giazotto  _et al._ [2006] F. Giazotto, T. T. Heikkilä, A. Luukanen, A. M. Savin, and J. P. Pekola, Opportunities for mesoscopics in thermometry and refrigeration: Physics and applications, Rev. Mod. Phys. 78, 217 (2006).
  * Kamra  _et al._ [2018] A. Kamra, A. Rezaei, and W. Belzig, Spin splitting induced in a superconductor by an antiferromagnetic insulator, Phys. Rev. Lett. 121, 247702 (2018).
  * Holstein and Primakoff [1940] T. Holstein and H. Primakoff, Field dependence of the intrinsic domain magnetization of a ferromagnet, Phys. Rev. 58, 1098 (1940).
  * [63] See Supplemental Information at [URL] for a detailed derivation of the spin and heat currents.
  * Kittel [2005] C. Kittel,  _Introduction to solid state physics_ , 8th ed. (Wiley, 2005) p. 680.
  * Bobkova and Bobkov [2011] I. V. Bobkova and A. M. Bobkov, Recovering the superconducting state via spin accumulation above the pair-breaking magnetic field of superconductor/ferromagnet multilayers, Phys. Rev. B 84, 140508 (2011).
  * Sarma [1963] G. Sarma, On the influence of a uniform exchange field acting on the spins of the conduction electrons in a superconductor, Journal of Physics and Chemistry of Solids 24, 1029 (1963).
  * Larkin and Ovchinnikov [1965] A. I. Larkin and Y. N. Ovchinnikov, Nonuniform state of superconductors, Sov. Phys. JETP 20, 762 (1965).
  * Bobkova and Bobkov [2014] I. V. Bobkova and A. M. Bobkov, Bistable state in superconductor/ferromagnet heterostructures, Phys. Rev. B 89, 224501 (2014).

Supplemental Material

The Hamiltonian considered in this work is given as

$\displaystyle H=H_{\text{SC}}+H_{\text{FI}}+H_{\text{int}},$ (S1)

where

$\displaystyle H_{\text{SC}}$
$\displaystyle=\sum_{ks}\xi_{k}c^{\dagger}_{ks}c_{ks}-\sum_{k}\left[\Delta
c^{\dagger}_{k\uparrow}c^{\dagger}_{-k\downarrow}+\Delta^{*}c_{k\downarrow}c_{-k\uparrow}\right]-\sum_{k}\sum_{\alpha\beta}h\sigma^{z}_{\alpha\beta}c^{\dagger}_{k\alpha}c_{k\beta},$
(S2) $\displaystyle H_{\text{FI}}$
$\displaystyle=\sum_{k}\hbar\omega_{k}a^{\dagger}_{k}a_{k},$ (S3)

represent the initial, unperturbed system, and

$\displaystyle H_{\text{int}}$
$\displaystyle=\sum_{kk^{\prime}}\left[W_{kk^{\prime}}s_{k}^{\dagger}a_{k^{\prime}}+W_{kk^{\prime}}^{*}s_{k}a_{k^{\prime}}^{\dagger}\right]$
(S4)

describes their interaction, assumed to be turned on at time $t=0$. Here,
$s_{k}=\hbar\sum_{q}c_{k\uparrow}^{\dagger}c_{k+q,\downarrow}$ describes a
spin flip processes, and $a_{k}$ is a magnon annihilation operator. As
described in the main text, the spin and heat currents are respectively given
as

$\displaystyle I_{s}(t)$
$\displaystyle=i\sum_{kk^{\prime}}\left\langle\left[W_{kk^{\prime}}(t)s^{\dagger}_{k}(t)a_{k^{\prime}}(t)-W_{kk^{\prime}}^{*}s_{k}(t)a_{k^{\prime}}^{\dagger}(t)\right]\right\rangle,$
(S5) $\displaystyle\dot{Q}(t)$
$\displaystyle=\frac{i}{\hbar}\sum_{kk^{\prime}}\left(\hbar\omega_{k^{\prime}}-\bar{\mu}\right)\left\langle\left[W_{kk^{\prime}}(t)s^{\dagger}_{k}(t)a_{k^{\prime}}(t)-W_{kk^{\prime}}^{*}(t)s_{k}(t)a_{k^{\prime}}^{\dagger}(t)\right]\right\rangle,$
(S6)

where the spin and magnon chemical potential has been introduced via the
transformation $c_{k\sigma}\to c_{k\sigma}e^{-i\mu_{\sigma}t/\hbar}$ and
$a_{k}\to a_{k}e^{-i\mu_{m}t/\hbar}$, such that
$W_{kk^{\prime}}(t)=W_{kk^{\prime}}e^{-i\left(\mu_{m}-\mu_{s}\right)t/\hbar}$,
where we have set $\mu_{\uparrow}=-\mu_{\downarrow}=-\mu_{s}/2$. We note
further that Eqs. S5 and S6 are given in the interaction representation, so
that the time evolution of $s_{k}$ and $a_{k}$ are governed by
$H_{0}=H_{\text{SC}}+H_{\text{FI}}$. To proceed, we define Green functions in
the two materials as

$\displaystyle\chi_{kk^{\prime}}(t,t^{\prime})$
$\displaystyle=-i\left\langle\mathcal{T}s_{k}(t)s_{k^{\prime}}^{\dagger}(t^{\prime})\right\rangle,$
(S7) $\displaystyle D_{kk^{\prime}}(t,t^{\prime})$
$\displaystyle=-i\left\langle\mathcal{T}a_{k}(t)a_{k^{\prime}}^{\dagger}(t^{\prime})\right\rangle,$
(S8)

where $\mathcal{T}$ is the time ordering operator, as well as a mixed Green
function of the form

$\displaystyle
G_{kk^{\prime}}(t,t^{\prime})=-i\left\langle\mathcal{T}a_{k}(t)s_{k^{\prime}}^{\dagger}(t^{\prime})\right\rangle.$
(S9)

In terms of Eq. S9, Eqs. S5 and S6 become

$\displaystyle I_{s}(t)$
$\displaystyle=-2\sum_{kk^{\prime}}\Re\left[W_{kk^{\prime}}(t)G^{<}_{k^{\prime}k}(t,t)\right],$
(S10) $\displaystyle\dot{Q}(t)$
$\displaystyle=-\frac{2}{\hbar}\sum_{kk^{\prime}}\left(\hbar\omega_{k^{\prime}}-\bar{\mu}\right)\Re\left[W_{kk^{\prime}}(t)G^{<}_{k^{\prime}k}(t,t)\right],$
(S11)

with $G^{<}_{kk^{\prime}}(t,t^{\prime})=-i\left\langle
s^{\dagger}_{k^{\prime}}(t^{\prime})a_{k}(t)\right\rangle$. To find this
lesser Green function, we first determine Eq. S9 on the Keldysh contour,

$\displaystyle
G_{kk^{\prime}}(\tau_{1},\tau_{2})=-i\left\langle\mathcal{T}_{K}a_{k}(\tau_{1})s^{\dagger}_{k^{\prime}}(\tau_{2})\right\rangle=-i\left\langle\mathcal{T}_{K}a_{k}(\tau_{1})s^{\dagger}_{k^{\prime}}(\tau_{2})\exp\left[-\frac{i}{\hbar}\int_{C}d\tau\;H_{\text{int}}(\tau)\right]\right\rangle_{0},$

where $\mathcal{T}_{K}$ implies time ordering along the Keldysh contour $C$,
and the subscript 0 indicates averaging over the unperturbed system. To lowest
order in the perturbation one finds

$\displaystyle
G_{kk^{\prime}}(\tau_{1},\tau_{2})\simeq\frac{(-i)^{2}}{\hbar}\sum_{qq^{\prime}}\int_{C}d\tau\left[W_{qq^{\prime}}(\tau)\left\langle\mathcal{T}_{K}a_{k}(\tau_{1})s^{\dagger}_{k^{\prime}}(\tau_{2})s^{\dagger}_{q}(\tau)a_{q^{\prime}}(\tau)\right\rangle_{0}+W^{*}_{qq^{\prime}}(\tau)\left\langle\mathcal{T}_{K}a_{k}(\tau_{1})s^{\dagger}_{k^{\prime}}(\tau_{2})s_{q}(\tau)a^{\dagger}_{q^{\prime}}(\tau)\right\rangle_{0}\right].$

The first term is immediately seen to vanish, as it only contains contractions
between magnon annihilation operators. From the second term we get

$\displaystyle
G_{kk^{\prime}}(\tau_{1},\tau_{2})=\frac{1}{\hbar}\int_{C}d\tau\;W_{k^{\prime}k}^{*}(\tau)D_{kk}(\tau_{1},\tau)\chi_{k^{\prime}k^{\prime}}(\tau,\tau_{2}),$
(S12)

by a straight forward application of Wick’s theorem. From the Langreth rules,
we thus find the lesser Green function to be

$\displaystyle G^{<}_{kk^{\prime}}(t_{1},t_{2})=\frac{1}{\hbar}\int
dt\;W^{*}_{k^{\prime}k}(t)\left[D^{R}_{kk}(t_{1},t)\chi^{<}_{k^{\prime}k^{\prime}}(t,t_{2})+D^{<}_{kk}(t_{1},t)\chi^{A}_{k^{\prime}k^{\prime}}(t,t_{2})\right],$
(S13)

where
$D^{R}_{kk^{\prime}}(t,t^{\prime})=-i\theta(t-t^{\prime})\left\langle\left[a_{k}(t)\;,\;a^{\dagger}_{k^{\prime}}(t^{\prime})\right]\right\rangle_{0}$,
$D^{A}_{kk^{\prime}}(t,t^{\prime})=+i\theta(t^{\prime}-t)\left\langle\left[a_{k}(t)\;,\;a^{\dagger}_{k^{\prime}}(t^{\prime})\right]\right\rangle_{0}$
are the retarded and advanced magnon Green functions, respectively. Similar
definitions apply to $\chi^{R}$ and $\chi^{A}$. Exploiting time translation
invariance (implying that we consider times long after the perturbation has
been switched on), we find

$\displaystyle G^{<}_{k^{\prime}k}(t,t)=\hbar
W^{*}_{kk^{\prime}}e^{i(\mu_{m}-\mu_{s})t/\hbar}\int\frac{d\omega}{2\pi}\left[D^{R}_{k^{\prime}k^{\prime}}\left(\omega-\frac{\mu_{m}}{\hbar}\right)\chi^{<}_{kk}\left(\omega-\frac{\mu_{s}}{\hbar}\right)+D^{<}_{k^{\prime}k^{\prime}}\left(\omega-\frac{\mu_{m}}{\hbar}\right)\chi^{A}_{kk}\left(\omega-\frac{\mu_{s}}{\hbar}\right)\right].$
(S14)

Insertion into Eqs. S10 and S11 thus gives

$\displaystyle I_{s}$
$\displaystyle=4\hbar\sum_{kk^{\prime}}\int\frac{d\omega}{2\pi}|W_{kk^{\prime}}|^{2}\Im
D^{R}_{k^{\prime}k^{\prime}}\left(\omega-\frac{\mu_{m}}{\hbar}\right)\Im\chi^{R}_{kk}\left(\omega+\frac{\mu_{s}}{\hbar}\right)\left[n_{\text{FI}}\left(\omega-\frac{\mu_{m}}{\hbar}\right)-n_{\text{SC}}\left(\omega-\frac{\mu_{s}}{\hbar}\right)\right],$
(S15) $\displaystyle\dot{Q}$
$\displaystyle=4\sum_{kk^{\prime}}\int\frac{d\omega}{2\pi}\left(\hbar\omega_{k^{\prime}}-\bar{\mu}\right)|W_{kk^{\prime}}|^{2}\Im
D^{R}_{k^{\prime}k^{\prime}}\left(\omega-\frac{\mu_{m}}{\hbar}\right)\Im\chi^{R}_{kk}\left(\omega+\frac{\mu_{s}}{\hbar}\right)\left[n_{\text{FI}}\left(\omega-\frac{\mu_{m}}{\hbar}\right)-n_{\text{SC}}\left(\omega-\frac{\mu_{s}}{\hbar}\right)\right],$
(S16)

where we have used the identities
$M^{A}(\omega)=\left(M^{R}(\omega)\right)^{*}$ and $M^{<}(\omega)=2i\Im
M^{R}(\omega)n_{j}(\omega)$, with $n_{j}$ the Bose-Einstein distribution
function in material $j$. In the following, we approximate $W_{kk^{\prime}}\to
W$. The retarded, noninteracting magnon Green function, albeit with a chemical
potential $\mu_{m}$, is given as

$\displaystyle
D^{R}_{kk}(\omega)=\frac{1}{\hbar\omega-\hbar\omega_{k}+\mu_{m}+i\delta},$
(S17)

where $\delta$ is an infinitesimal quantity. Hence, $\Im
D^{R}_{k^{\prime}k^{\prime}}(\omega-\mu_{m}/\hbar)=-\pi\delta(\hbar\omega-\hbar\omega_{k^{\prime}})$.
Furthermore, we let $\sum_{k^{\prime}}\to V_{\text{FI}}\int
d(\hbar\omega_{k})\nu_{m}(\hbar\omega_{k})$, where $V_{\text{FI}}$ is the
volume of the ferromagnetic insulator and
$\nu_{m}(\varepsilon)=\sqrt{\varepsilon-\Delta_{m}}/4\pi^{2}J_{s}^{3/2}$ is
the magnon chemical potential, so that we get

$\displaystyle I_{s}$ $\displaystyle=-2|W|^{2}V_{\text{FI}}\hbar\sum_{k}\int
d\omega\;\nu_{m}(\hbar\omega)\Im\chi^{R}_{kk}\left(\omega+\frac{\mu_{s}}{\hbar}\right)\left[n_{\text{FI}}\left(\omega-\frac{\mu_{m}}{\hbar}\right)-n_{\text{SC}}\left(\omega+\frac{\mu_{s}}{\hbar}\right)\right],$
(S18) $\displaystyle\dot{Q}$ $\displaystyle=-2|W|^{2}V_{\text{FI}}\sum_{k}\int
d\omega\;\left(\hbar\omega-\bar{\mu}\right)\nu_{m}(\hbar\omega)\Im\chi^{R}_{kk}\left(\omega+\frac{\mu_{s}}{\hbar}\right)\left[n_{\text{FI}}\left(\hbar\omega-\mu_{m}\right)-n_{\text{SC}}\left(\hbar\omega-\mu_{s}\right)\right],$
(S19)

Next, we require an expression for $\chi^{R}_{kk}(\omega)$. We begin from Eq.
S7, which is given in terms of the electron creation and annihilation
operators in imaginary time as

$\displaystyle\chi_{kk^{\prime}}(\tau_{1},\tau_{2})=-\hbar^{2}\sum_{qq^{\prime}}\left\langle\mathcal{T}c^{\dagger}_{q\uparrow}(\tau_{1})c_{q+k,\downarrow}(\tau_{1})c^{\dagger}_{q^{\prime}+k^{\prime},\downarrow}(\tau_{2})c_{q^{\prime}\uparrow}(\tau_{2})\right\rangle.$
(S20)

As we are considering a superconductor, it is convenient to introduce the
Nambu basis,
$\psi_{k}=\begin{pmatrix}c_{k\uparrow}&c_{k\downarrow}&c^{\dagger}_{-k\uparrow}&c^{\dagger}_{-k\downarrow}\end{pmatrix}^{T}$,
from which the superconducting Green function may be found as

$\displaystyle
C(\bm{k},\bm{k}^{\prime};\tau_{1},\tau_{2})=-i\left\langle\psi_{k}(\tau_{1})\psi^{\dagger}_{k^{\prime}}(\tau_{2})\right\rangle$
$\displaystyle=$
$\displaystyle-\begin{pmatrix}\left\langle\mathcal{T}c_{k\uparrow}(\tau_{1})c^{\dagger}_{k^{\prime}\uparrow}(\tau_{2})\right\rangle&0&0&\left\langle\mathcal{T}c_{k\uparrow}(\tau_{1})c_{-k^{\prime}\downarrow}(\tau_{2})\vphantom{c^{\dagger}_{k^{\prime}\uparrow}}\right\rangle\\\
0&\left\langle\mathcal{T}c_{k\downarrow}(\tau_{1})c^{\dagger}_{k^{\prime}\downarrow}(\tau_{2})\right\rangle&\left\langle\mathcal{T}c_{k\downarrow}(\tau_{1})c_{-k^{\prime}\uparrow}(\tau_{2})\vphantom{c^{\dagger}_{k^{\prime}\uparrow}}\right\rangle&0\\\
0&\left\langle\mathcal{T}c^{\dagger}_{-k\uparrow}(\tau_{1})c^{\dagger}_{k^{\prime}\downarrow}(\tau_{2})\vphantom{c^{\dagger}_{k^{\prime}\uparrow}}\right\rangle&\left\langle\mathcal{T}c^{\dagger}_{-k\uparrow}(\tau_{1})c_{-k^{\prime}\uparrow}(\tau_{2})\right\rangle&0\\\
\left\langle\mathcal{T}c^{\dagger}_{-k\downarrow}(\tau_{1})c^{\dagger}_{k^{\prime}\uparrow}(\tau_{2})\right\rangle&0&0&\left\langle\mathcal{T}c^{\dagger}_{-k\downarrow}(\tau_{1})c_{-k^{\prime}\downarrow}(\tau_{2})\vphantom{c^{\dagger}_{k^{\prime}\uparrow}}\right\rangle\end{pmatrix}$
$\displaystyle\equiv$
$\displaystyle\begin{pmatrix}G^{e}_{\uparrow\uparrow}(\bm{k},\bm{k}^{\prime};\tau_{1},\tau_{2})&0&0&F^{e}_{\uparrow\downarrow}(\bm{k},\bm{k}^{\prime};\tau_{1},\tau_{2})\\\
0&G^{e}_{\downarrow\downarrow}(\bm{k},\bm{k}^{\prime};\tau_{1},\tau_{2})&F^{e}_{\downarrow\uparrow}(\bm{k},\bm{k}^{\prime};\tau_{1},\tau_{2})&0\\\
0&F^{h}_{\uparrow\downarrow}(\bm{k},\bm{k}^{\prime};\tau_{1},\tau_{2})&G^{h}_{\uparrow\uparrow}(\bm{k},\bm{k}^{\prime};\tau_{1},\tau_{2})&0\\\
F^{h}_{\downarrow\uparrow}(\bm{k},\bm{k}^{\prime};\tau_{1},\tau_{2})&0&0&G^{h}_{\downarrow\downarrow}(\bm{k},\bm{k}^{\prime};\tau_{1},\tau_{2})\end{pmatrix}.$
(S21)

To find find Eq. S20 we employ Wick’s theorem, making sure to include all non-
zero contractions that contain correlators appearing in Eq. S21. The result is

$\displaystyle\chi_{kk^{\prime}}(\tau)=$
$\displaystyle-\hbar^{2}\delta_{kk^{\prime}}\sum_{q}G^{e}_{\uparrow\uparrow}(\bm{q};-\tau)G^{e}_{\downarrow\downarrow}(\bm{q}+\bm{k};\tau)-F^{h}_{\downarrow\uparrow}(\bm{q},-\tau)F^{e}_{\downarrow\uparrow}(\bm{q}+\bm{k};\tau)$
$\displaystyle-F^{e}_{\uparrow\downarrow}(\bm{q},-\tau)F^{h}_{\uparrow\downarrow}(\bm{q}+\bm{k};\tau)+G^{h}_{\downarrow\downarrow}(-\bm{q}-\bm{k};-\tau)G^{h}_{\uparrow\uparrow}(-\bm{q};\tau),$
(S22)

where we have used the identity
$F^{h}_{ss^{\prime}}(\bm{q},\tau)=-F^{h}_{s^{\prime}s}(-\bm{q},-\tau)$, as
well as defined $\tau=\tau_{1}-\tau_{2}$, and $G^{j}_{ss}(\bm{q})\equiv
G^{j}_{ss}(\bm{q},\bm{q})$. The superconductor Green function is given in
terms of the Matsubara frequencies as
$C(\bm{k},i\omega_{n})=1/(i\omega_{n}-H_{\text{SC}})$, from which we find

$\displaystyle
C(\bm{k},i\omega_{n})=\begin{pmatrix}\frac{i\omega_{n}+\xi_{k}+h-\frac{1}{2}\mu_{s}}{(i\omega_{n}+h-\frac{1}{2}\mu_{s})^{2}-\xi_{k}^{2}-|\Delta|^{2}}&0&0&\frac{\Delta}{(i\omega_{n}+h-\frac{1}{2}\mu_{s})^{2}-\xi_{k}^{2}-|\Delta|^{2}}\\\
0&\frac{i\omega_{n}+\xi_{k}-h+\frac{1}{2}\mu_{s}}{(i\omega_{n}-h+\frac{1}{2}\mu_{s})^{2}-\xi_{k}^{2}-|\Delta|^{2}}&\frac{-\Delta}{(i\omega_{n}-h+\frac{1}{2}\mu_{s})^{2}-\xi_{k}^{2}-|\Delta|^{2}}&0\\\
0&\frac{-\Delta^{*}}{(i\omega_{n}-h+\frac{1}{2}\mu_{s})^{2}-\xi_{k}^{2}-|\Delta|^{2}}&\frac{i\omega_{n}-\xi_{k}-h+\frac{1}{2}\mu_{s}}{(i\omega_{n}-h+\frac{1}{2}\mu_{s})^{2}-\xi_{k}^{2}-|\Delta|^{2}}&0\\\
\frac{\Delta^{*}}{(i\omega_{n}+h-\frac{1}{2}\mu_{s})^{2}-\xi_{k}^{2}-|\Delta|^{2}}&0&0&\frac{i\omega_{n}-\xi_{k}+h-\frac{1}{2}\mu_{s}}{(i\omega_{n}+h-\frac{1}{2}\mu_{s})^{2}-\xi_{k}^{2}-|\Delta|^{2}}\end{pmatrix}.$
(S23)

From this, the gap may be self-consistently determined from the relation

$\displaystyle\Delta=-\frac{1}{\beta}\sum_{k,i\omega_{n}}F^{e}_{\downarrow\uparrow}(\bm{k},i\omega_{n}).$
(S24)

In frequency space, Eq. S22 takes the form

$\displaystyle\chi_{kk^{\prime}}(i\omega_{n})=$
$\displaystyle-\frac{\hbar^{2}}{\beta}\delta_{kk^{\prime}}\sum_{q,i\omega_{m}}G^{e}_{\uparrow\uparrow}(\bm{q};i\omega_{m}+i\omega_{n})G^{e}_{\downarrow\downarrow}(\bm{q}+\bm{k};i\omega_{m})-F^{h}_{\downarrow\uparrow}(\bm{q},i\omega_{m}+i\omega_{n})F^{e}_{\downarrow\uparrow}(\bm{q}+\bm{k};i\omega_{m})$
$\displaystyle-F^{e}_{\uparrow\downarrow}(\bm{q},i\omega_{m}+i\omega_{n})F^{h}_{\uparrow\downarrow}(\bm{q}+\bm{k};i\omega_{m})+G^{h}_{\downarrow\downarrow}(-\bm{q}-\bm{k};i\omega_{m}+i\omega_{n})G^{h}_{\uparrow\uparrow}(-\bm{q};i\omega_{m}),$

and after inserting Eq. S23 we get

$\displaystyle\chi_{kk^{\prime}}(i\omega_{n})=-\frac{\hbar^{2}}{\beta}\delta_{kk^{\prime}}\sum_{q,i\omega_{m}}\sum_{\lambda,\lambda^{\prime}=\pm
1}\frac{1}{i\omega_{m}+i\omega_{n}+h-\frac{1}{2}\mu_{s}-\lambda
E_{q}}\frac{1}{i\omega_{m}-h+\frac{1}{2}\mu_{s}-\lambda^{\prime}E_{q+k}}\left[\frac{1}{2}+\frac{\xi_{q}\xi_{q+k}+|\Delta|^{2}}{2\lambda\lambda^{\prime}E_{q}E_{q+k}}\right],$

with $E_{q}=\sqrt{\xi_{q}^{2}+|\Delta|^{2}}$. Performing the Matsubara sum
thus gives

$\displaystyle\chi^{R}_{kk^{\prime}}(\hbar\omega)=\hbar^{2}\delta_{kk^{\prime}}\sum_{q}\sum_{\lambda\lambda^{\prime}=\pm
1}\left[\frac{1}{2}+\frac{\xi_{q}\xi_{q+k}+\Delta^{2}}{2\lambda\lambda^{\prime}E_{q}E_{q+k}}\right]\frac{f(\lambda^{\prime}E_{q+k}+h-\frac{1}{2}\mu_{s})-f(\lambda
E_{q}-h+\frac{1}{2}\mu_{s})}{\hbar\omega+i\delta-\lambda^{\prime}E_{q+k}+\lambda
E_{q}-2h+\mu_{s}},$ (S25)

after analytic continuation ($i\omega_{n}\to\hbar\omega+i\delta$), where
$f(E)$ is the Fermi-Dirac distribution function. We seek the quantity
$\sum_{k}\Im\chi_{kk}^{R}(\omega)$, which becomes

$\displaystyle\sum_{k}\Im\chi_{kk}^{R}(\omega)=$
$\displaystyle-\pi\hbar^{2}\sum_{kk^{\prime}}\sum_{\lambda,\lambda^{\prime}=\pm
1}\left[\frac{1}{2}+\frac{\xi_{k}\xi_{k^{\prime}}+\Delta^{2}}{2\lambda\lambda^{\prime}E_{k}E_{k^{\prime}}}\right]\left(f(\lambda^{\prime}E_{k^{\prime}}+h-\frac{1}{2}\mu_{s})-f(\lambda
E_{k}-h+\frac{1}{2}\mu_{s})\right)\times$
$\displaystyle\delta(\hbar\omega-\lambda^{\prime}E_{k^{\prime}}+\lambda
E_{k}-2h+\mu_{s}).$ (S26)

Next we approximate $\sum_{k}\simeq V_{\text{SC}}\nu_{0}\int d\xi_{k}$, where
$V_{\text{SC}}$ is the volume of the superconductor, and $\nu_{0}$ is the
density of states at the Fermi level. In addition, it’s convenient to change
integration variable from $\xi_{k}$ to $E_{k}\equiv E$, so that
$d\xi=\nu(E)dE$, where $\nu(E)=\Re\left[|E|/\sqrt{E^{2}-|\Delta|^{2}}\right]$
is the normalized superconducting density of states, with integration limits
$E\in\left[0,\infty\right]$. All in all, this gives

$\displaystyle\sum_{k}\Im\chi_{kk}^{R}(\omega)=$
$\displaystyle-\pi\hbar^{2}V_{\text{SC}}^{2}\nu_{0}^{2}\sum_{\lambda,\lambda^{\prime}=\pm
1}\int_{0}^{\infty}dE\;\nu(E)\nu(\lambda E+\hbar\omega-2h+\mu_{s})\times$
$\displaystyle\left[\frac{1}{2}+\frac{\lambda\lambda^{\prime}}{2\nu(E)\nu(\lambda
E+\hbar\omega-2h+\mu_{s})}+\frac{\Delta^{2}}{2\lambda E(\lambda
E+\hbar\omega-2h+\mu_{s})}\right]\times$ $\displaystyle\left(f(\lambda
E+\hbar\omega-h+\frac{1}{2}\mu_{s})-f(\lambda E-h+\frac{1}{2}\mu_{s})\right).$

Note that we may set $\nu(E)=\nu(\lambda E)$, and hence we find, after summing
over $\lambda$ and $\lambda^{\prime}$,

$\displaystyle\sum_{k}\Im\chi_{kk}^{R}(\omega)=$
$\displaystyle-\pi\hbar^{2}V_{\text{SC}}^{2}\nu_{0}^{2}\int_{-\infty}^{\infty}dE\;\left[1+\frac{\Delta^{2}}{E(E+\hbar\omega-2h+\mu_{s})}\right]\nu(E)\nu(E+\hbar\omega-2h+\mu_{s})\times$
$\displaystyle\left(f(E+\hbar\omega-h+\frac{1}{2}\mu_{s})-f(E-h+\frac{1}{2}\mu_{s})\right).$
(S27)

Finally, we define
$\chi_{s}(\hbar\omega)=\sum_{k}\chi_{kk}^{R}(\omega-\frac{\mu_{s}}{\hbar})$,
which gives

$\displaystyle\chi_{s}(\hbar\omega)=$
$\displaystyle-\pi\hbar^{2}V_{\text{SC}}^{2}\nu_{0}^{2}\int_{-\infty}^{\infty}dE\;F_{\Delta}\nu(E+h)\nu(E+\hbar\omega-h)\left(f(E+\hbar\omega-\frac{1}{2}\mu_{s})-f(E+\frac{1}{2}\mu_{s})\right),$
(S28)

where $F_{\Delta}=1+|\Delta|^{2}/(E+h)(E+\hbar\omega-h)$. The final expression
for the spin and heat currents is found by inserting into Eqs. S18 and S19.
One gets

$\displaystyle I_{s}$ $\displaystyle=-2|W|^{2}V_{\text{FI}}\hbar\int
d\omega\;\nu_{m}(\hbar\omega)\chi_{s}(\hbar\omega)\left[n_{\text{FI}}\left(\omega-\frac{\mu_{m}}{\hbar}\right)-n_{\text{SC}}\left(\omega-\frac{\mu_{s}}{\hbar}\right)\right],$
(S29) $\displaystyle\dot{Q}$ $\displaystyle=-2|W|^{2}V_{\text{FI}}\int
d\omega\;\left(\hbar\omega-\mu_{m}\right)\nu_{m}(\hbar\omega)\chi_{s}(\hbar\omega)\left[n_{\text{FI}}\left(\omega-\frac{\mu_{m}}{\hbar}\right)-n_{\text{SC}}\left(\omega-\frac{\mu_{s}}{\hbar}\right)\right],$
(S30)

which correspond to Eqs. 9 and 10 in the main article.


# Programming Language Assisted Waveform Analysis:
A Case Study on the Instruction Performance of SERV

Lucas Klemmer Daniel Große
https://wal-lang.org https://github.com/ics-jku/wal/tree/main/wawk Institute
for Complex Systems, Johannes Kepler University Linz, Austria
{lucas.klemmer<EMAIL_ADDRESS>
###### Abstract

RISC-V’s growing traction leads to the release of new _RISC-V_ cores on a near
monthly basis. In this growing and diverse ecosystem, understanding the
performance and other properties of a RISC-V core is of great importance since
selecting the best fitting core is mandatory for a successful project.
Analyzing RISC-V cores by hand is not possible due to the ever-increasing
number of available cores and available software benchmarks might not be fine-
grained enough to understand a core completely. Programming and powerful
programming languages have proven to provide the productivity that is required
to keep pace with these fast developments.

In this paper we present a case study111The code for the case study is
available at https://github.com/LucasKl/serv-cpi in which we use WAWK, a
front-end for the open-source _Waveform Analysis Language_ , to analyze the
performance of all instructions of SERV, a well known bit-serial RISC-V core.
With WAWK, only a few lines of code are necessary to calculate the respective
metric on the waveform generated during simulation.

##  I Introduction

RISC-V is an open and royalty free ISA [1] striving for innovation through
collaboration, thus enabling even small companies as well as community
projects to develop their own processors which take advantage from RISC-V’s
permissive license and its extensibility to explore new ideas and markets with
often highly specialized hardware. However, this openness and extensibility of
RISC-V brings its own set of challenges, since the sheer number of available
RISC-V cores, which are often highly configurable and extensible, makes it
very hard and time-consuming for both, designers and users, to compare
different cores against each other [2] [3].

In this paper, we use _Waveform AWK_ (WAWK), a front-end for the open-source
_Waveform Analysis Language_ (WAL) [4, 5]. WAWK programs have direct access to
all signal values of a waveform. Accessing signals in a WAWK program is
similar to accessing variables in regular programming languages with the
difference that the value returned depends on the loaded waveform and the time
at which the signal is accessed. Since WAWK is compiled down to WAL it has
access to a very rich feature set that provides a large collection of
functions which can be used to analyze waveforms. Thus WAWK allows creating
analysis programs using the values from the VCD waveforms generated during
simulation of a RISC-V core.

With WAWK, we show that the analysis of RISC-V cores is possible with only a
handful of lines which give developers crucial information about the
performance of their or others cores.

##  II Related Work

In the context of processor architecture research several processor simulators
have been proposed. A prominent example is gem5 [6] or multi2sim [7]. A
complimentary direction are emulators, such as qemu [8] or OVPSim [9]. Both
simulators, and emulators can partially be used to calculate (performance)
metrics. However, they are not as flexible as a programmable approach such as
WAWK for the problems considered. WAWK allows developers to create programs
and tailor them to the exact requirements, such as IPC count, pipeline
analysis and more [10].

##  III Preliminaries

###  III-A WAWK

In this paper we use WAWK, a language inspired from the popular text-
processing language _AWK_ , that is compiled down to WAL. In general, all WAWK
scripts consist of multiple statements that follow a condition: { action }
scheme. For each time index in a waveform, WAWK evaluates the condition of
each statement, and, if satisfied, executes the associated action.

###  III-B SERV

SERV is a bit-serial implementation of the RISC-V ISA with a heavy focus on
very low area usage. The bit-serial implementation dictates that all
instructions are executed bit by bit such that for example the RV32I add
instruction is split over at least 32 cycles, one for each bit of the result.

Figure 1: SERV Instuction Lifecycle

To analyze the runtime of individual instructions in the SERV core we can
observe the values of the instruction fetch bus. The start of a new
instruction is signalized by the core when the signal i_ibus_ack rises.
Therefore, the runtime of one instruction can be calculated by observing two
following rising edge events on i_ibus_ack and calculating the time difference
$event_{2}-event_{1}$ between those two events. This is shown in Figure 1
where the first instruction starts at time a. At time point b the next
instruction starts thus the CPI for this instruction can be calculated by the
difference between b and a.

##  IV CPI Analysis

The WAWK program for the CPI analysis is shown in Listing 1. The analysis
program consists of four WAWK statements. First, after the program is started
and before the waveform analysis is started the first statement (Line 1) is
executed once. This is triggered by the BEGIN condition which is a special
variable which is only true after the program starts. This WAWK program uses
the _riscv-model_ Python package to decode RISC-V instructions. Therefore, an
external Python script containing a few lines of Python glue code is imported
(Line 2) and the list of results which will store all measured CPI values is
initialized. Additionally, some aliases are created for often used signals.
Next, some aliases are declared which can be used instead of the long full
signal names.

The second statement (Line 9) is executed at the last cycle of each
instruction. However, the statement is only executed when the opcode of the
current instruction matches the opcode which we want to analyze. This opcode
has to be passed to the program as an command line argument and it is
available to the WAWK program in the args variable. At this point, the
difference to the starting time of this instruction is calculated and added to
the list of measured CPI values.

The next statement (Line 13) is executed whenever a new instruction starts
executing. At this moment, the current time index, which is used to calculate
the runtime of this instruction in the previous statement, is stored and the
current opcode is decoded and stored in the op variable.

Finally, after all indices were processed by the program, the final results,
which consist of the average, minimum, and maximum runtimes, are printed by
the last statement (Line 18).

⬇

1BEGIN: {

2 import(extern);

3 cpis = [];

4 alias(clk, TOP.servant_sim.dut.cpu.clk);

5 alias(fire, TOP.servant_sim.dut.cpu.i_ibus_ack);

6 alias(instruction, TOP.servant_sim.dut.cpu.i_ibus_rdt);

7}

8

9clk, !fire, fire@2, op == args[0]: {

10 cpis = cpis + ((INDEX - start) / 2);

11}

12

13clk, fire: {

14 start = INDEX;

15 op = call(extern.decode, instruction);

16}

17

18END: {

19 if (cpis) {

20 if (min(cpis) == max(cpis)) {

21 printf("%10s␣%10d\n", args[0], average(cpis));

22 } else {

23 printf("%10s␣%10d␣%10d␣%10d\n", args[0], average(cpis), min(cpis),
max(cpis));

24 };

25 };

26}

Listing 1: WAWK code for CPI the analysis

##  V Results

Opcode | Avg. | Min | Max
---|---|---|---
auipc | 35 |  |
lui | 35 |  |
add(i) | 35 |  |
sub | 35 |  |
and(i) | 35 |  |
or(i) | 35 |  |
xor(i) | 35 |  |
ecall | 35 |  |
slt(i) | 68 |  |
sltu | 68 |  |
sltiu | 68 |  |
sll(i) | 68 |  |
sra | 75 | 68 | 99
srai | 70 | 68 | 99
srl(i) | 75 | 68 | 99
jal | 68 | 68 | 70
jalr | 69 | 68 | 70
beq | 68 | 68 | 70
bge | 69 | 68 | 70
bgeu | 69 | 68 | 70
blt | 68 | 68 | 70
bltu | 69 | 68 | 70
bne | 68 | 68 | 70
lb | 69 |  |
lh | 69 | 69 | 70
lhu | 69 | 69 | 70
lw | 69 | 69 | 70
sh | 69 | 69 | 70
sw | 69 | 69 | 70
TABLE I: SERV CPI on Compliance Tests

Table I shows the analysis results for each of the instructions of the SERV
core. The first column lists the name of the instruction, the second lists the
average number of cycles this instruction requires to be executed, and the
last two columns show the minimum and maximum number of instructions required
to execute this instruction respectively. The table shows that the
instructions mainly fall into two categories. One half of the instructions
always finishes execution in constant time while the over half requires a
variable number of cycles.

##  VI Conclusion

In this paper we presented a programmable analysis of the performance of
individual instructions as implemented in the well-known RISC-V core SERV. The
analysis program is written in WAWK, a DSL for waveform analysis inspired by
the AWK text-processing language. In only a few lines of code the program
analyzes the number of cycles per instruction required to execute a specific
instruction.

## Acknowledgments

This work has partially been supported by the LIT Secure and Correct Systems
Lab funded by the State of Upper Austria.

## References

  * [1] A. Waterman and K. Asanović, _The RISC-V Instruction Set Manual; Volume I: Unprivileged ISA_ , SiFive Inc. and CS Division, EECS Department, University of California, Berkeley, 2019.
  * [2] A. Dörflinger, M. Albers, B. Kleinbeck, Y. Guan, H. Michalik, R. Klink, C. Blochwitz, A. Nechi, and M. Berekovic, “A comparative survey of open-source application-class risc-v processor implementations,” in _International Conference on Computing Frontiers_ , 2021, p. 12–20.
  * [3] E. Sperling, “Which Processor Is Best?” https://semiengineering.com/which-processor-is-best, 2022.
  * [4] L. Klemmer and D. Große, “WAL: a novel waveform analysis language for advanced design understanding and debugging,” 2022, pp. 358–364.
  * [5] ——, “Waveform-based performance analysis of RISC-V processors: late breaking results,” 2022, pp. 1404–1405.
  * [6] N. Binkert, B. Beckmann, G. Black, S. K. Reinhardt, A. Saidi, A. Basu, J. Hestness, D. R. Hower, T. Krishna, S. Sardashti, R. Sen, K. Sewell, M. Shoaib, N. Vaish, M. D. Hill, and D. A. Wood, “The gem5 simulator,” _SIGARCH Comput. Archit. News_ , vol. 39, no. 2, pp. 1–7, Aug. 2011.
  * [7] R. Ubal, J. Sahuquillo, S. Petit, and P. Lopez, “Multi2sim: A simulation framework to evaluate multicore-multithreaded processors,” in _SBAC-PAD_ , 2007, pp. 62–68.
  * [8] “QEMU a generic and open source machine emulator and virtualizer,” https://www.qemu.org/, 2022.
  * [9] “Technology OVPsim,” https://www.ovpworld.org/technology_ovpsim, 2022\.
  * [10] L. Klemmer, E. Jentzsch, and D. Große, “Programmable analysis of RISC-V processor simulations using WAL,” 2022.