Skip to contentSkip to conversation

Chapterwise QQZ answers

PATCH In review Akira Yokosawa 2 participants 7 messages Jul 29, 2020 Kbuild

lore
Share & tools
lore
#0 lore raw

cover Chapterwise QQZ answers

Hi Paul,

So, in the mean time, I've attempted chapterwise QQZ answers. This patch series is the resulting changes.

Patch #1 fixes a typo in Makefile which I noticed during this development.

Patch #2 is the main change enabling chapterwise QQZ answers in perfbook-nq.pdf.
This patch becomes a large one, as the addition of argument to macros in qqz.sty requires tree-wide changes for successful build. It also contains minor tweaks in howto.tex.

Patches #3--#5 are minor updates.
Patch #5 results in a table mostly identical to Table E.5. I don't think these quick quizzes are redundant, though.

The resulting perfbook-nq.pdf looks fairly reasonable to me. Some of the question parts have room to improve so that they are less context-dependent.

Let me know what you think.

Thanks, Akira
--
Akira Yokosawa (5):
Makefile: Fix typo in CREFPTN
Enhance qqz scheme for chapterwise QQZ answers perfbook-lt.tex: Tell cleveref not to capitalize 'page' in \cpageref{}
datastruct: Use nbsp in captions (State (a), State (b), etc.)
formal: Retouch Table E.4

 .gitignore                           |  2 +-
 Makefile                             | 17 ++++++++---
 SMPdesign/SMPdesign.tex              |  4 ++-
 advsync/advsync.tex                  |  4 ++-
 appendix/questions/questions.tex     |  4 ++-
 appendix/toyrcu/toyrcu.tex           |  4 ++-
 appendix/whymb/whymemorybarriers.tex |  4 ++-
 count/count.tex                      |  4 ++-
 cpu/cpu.tex                          |  4 ++-
 datastruct/datastruct.tex            | 12 ++++----
 debugging/debugging.tex              |  4 ++-
 defer/defer.tex                      |  4 ++-
 easy/easy.tex                        |  4 ++-
 formal/axiomatic.tex                 | 26 ++++++++++-------
 formal/formal.tex                    |  4 ++-
 future/future.tex                    |  4 ++-
 howto/howto.tex                      | 27 ++++++++++++++----
 intro/intro.tex                      |  4 ++-
 locking/locking.tex                  |  4 ++-
 memorder/memorder.tex                |  4 ++-
 owned/owned.tex                      |  4 ++-
 perfbook-lt.tex                      |  5 ++++
 qqz.sty                              | 22 +++++++++++++--
 together/together.tex                |  4 ++-
 toolsoftrade/toolsoftrade.tex        |  4 ++-
 utilities/divideqqz.pl               | 42 ++++++++++++++++++++++++++++
 26 files changed, 179 insertions(+), 46 deletions(-)
 create mode 100755 utilities/divideqqz.pl
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/5 Makefile: Fix typo in CREFPTN

From ad129055142dfaa6a816d541c767c1cd86c0cf73 Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <[email protected]>
Date: Mon, 27 Jul 2020 16:10:26 +0900
Subject: [PATCH 1/5] Makefile: Fix typo in CREFPTN

This regular expression is supposed to catch a pattern of \cref{ref:a} {ref:b}, which will result in something like:

    Section 1.2 ref:b ...

Due to a typo in the expression, it catches

    ... { ... \cref{ref:a} ... } { ... }

, which is a false positive.

Fixing the pattern to "[^}]+}" will avoid the false positive.

Fixes 962cbb73ce0c ("Makefile: Add check of \crefrange and \clnrefrange misuse")
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
index 802d638e..4e2b65ab 100644
@@ -135,7 +135,7 @@ LINEREF_ENV_END     := $(shell grep -l -F '\end{lineref}'     $(LATEXSOURCES))
 LINELABEL_ENV := $(sort $(LINELABEL_ENV_BEGIN) $(LINELABEL_ENV_END))
 LINEREF_ENV   := $(sort $(LINEREF_ENV_BEGIN) $(LINEREF_ENV_END))
 
-CREFPTN    := '\\[Cc](ln)?ref{[^{]+}\s*{[^}]+}'
+CREFPTN    := '\\[Cc](ln)?ref{[^}]+}\s*{[^}]+}'
 CREFPAIR   := $(shell grep -l -zo -E $(CREFPTN)   $(LATEXSOURCES))
 
 SOURCES_OF_SNIPPET_ALL := $(shell grep -r -l -F '\begin{snippet}' CodeSamples)
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/5 Enhance qqz scheme for chapterwise QQZ answers

In reply to Akira Yokosawa

From fe2a375d55b744d48f776586caafa261bc6486fa Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <[email protected]>
Date: Mon, 27 Jul 2020 20:45:35 +0900
Subject: [PATCH 2/5] Enhance qqz scheme for chapterwise QQZ answers

This commit enables chapterwise QQZ answers in target perfbook-nq.pdf. To achieve this, following changes are made.

o Add a boolean "qqzchpend" in the preamble.
o In qqz.sty, add a 3rd argument to \QuickQuizChapter{} and \QuickQAC{}. It is used to specify basename of chapterwise QQZ .tex file. Also add a command \QuickQuizAnswerChp{} for conditionally including the chapterwise QQZ file.
o In chapter level .tex files, add the 3rd argument to \QuickQuizChapter{} at the top and add the \QuickQuizAnswersChp{} commands at the bottom.
Chapterwise QQZ files are named qqzhowto.tex, qqzintro.tex, and so on.
o Add a script "utilities/divideqqz.pl" to generate chapterwise qqz .tex files.
o Tweak howto.tex to deal with the lack of answers to QQZ in Appendix.
o Enable "qqzchpend" for target perfbook-nq.pdf.
o Update .gitignore (qqz*.tex)

---
 .gitignore                           |  2 +-
 Makefile                             | 15 ++++++++--
 SMPdesign/SMPdesign.tex              |  4 ++-
 advsync/advsync.tex                  |  4 ++-
 appendix/questions/questions.tex     |  4 ++-
 appendix/toyrcu/toyrcu.tex           |  4 ++-
 appendix/whymb/whymemorybarriers.tex |  4 ++-
 count/count.tex                      |  4 ++-
 cpu/cpu.tex                          |  4 ++-
 datastruct/datastruct.tex            |  4 ++-
 debugging/debugging.tex              |  4 ++-
 defer/defer.tex                      |  4 ++-
 easy/easy.tex                        |  4 ++-
 formal/formal.tex                    |  4 ++-
 future/future.tex                    |  4 ++-
 howto/howto.tex                      | 27 ++++++++++++++----
 intro/intro.tex                      |  4 ++-
 locking/locking.tex                  |  4 ++-
 memorder/memorder.tex                |  4 ++-
 owned/owned.tex                      |  4 ++-
 perfbook-lt.tex                      |  3 ++
 qqz.sty                              | 22 +++++++++++++--
 together/together.tex                |  4 ++-
 toolsoftrade/toolsoftrade.tex        |  4 ++-
 utilities/divideqqz.pl               | 42 ++++++++++++++++++++++++++++
 25 files changed, 156 insertions(+), 31 deletions(-)
 create mode 100755 utilities/divideqqz.pl
.gitignore +1 -1
index d0459aef..a25a00b7 100644
@@ -24,7 +24,7 @@
 *.pdfq
 *.synctex*
 perfbook_flat.tex
-qqz.tex
+qqz*.tex
 contrib.tex
 origpub.tex
 perfbook*.out
Makefile +12 -3
index 4e2b65ab..3e0503d7 100644
@@ -16,7 +16,12 @@ LATEXSOURCES = \
 LST_SOURCES := $(wildcard CodeSamples/formal/promela/*.lst) \
 	$(wildcard appendix/styleguide/*.c)
 
-LATEXGENERATED = autodate.tex qqz.tex contrib.tex origpub.tex
+SUB_QQZ := qqzhowto.tex qqzintro.tex qqzcpu.tex qqztoolsoftrade.tex \
+	qqzcount.tex qqzSMPdesign.tex qqzlocking.tex qqzowned.tex \
+	qqzdefer.tex qqzdatastruct.tex qqzdebugging.tex qqzformal.tex \
+	qqztogether.tex	qqzadvsync.tex qqzmemorder.tex qqzeasy.tex \
+	qqzfuture.tex qqzquestions.tex qqztoyrcu.tex qqzwhymb.tex
+LATEXGENERATED = autodate.tex qqz.tex contrib.tex origpub.tex $(SUB_QQZ)
 
 TWOCOLTARGETS := mstx msr msn msnt sf qq nq
 ABBREVTARGETS := lt hb a4 1c tcb msns mss $(TWOCOLTARGETS) $(foreach v,$(TWOCOLTARGETS),1c$(v))
@@ -245,6 +250,9 @@ contrib.tex: perfbook_flat.tex qqz.tex
 origpub.tex: perfbook_flat.tex
 	sh utilities/extractorigpub.sh < $< > $@
 
+$(SUB_QQZ): qqz.tex
+	utilities/divideqqz.pl
+
 perfbook.tex: $(PERFBOOK_BASE)
 	cp $< $@
 
@@ -328,7 +336,8 @@ perfbook-qq.tex perfbook-1cqq.tex:
 perfbook-nq.tex: $(PERFBOOK_BASE)
 perfbook-1cnq.tex: perfbook-1c.tex
 perfbook-nq.tex perfbook-1cnq.tex:
-	sed -e 's/setboolean{noqqz}{false}/setboolean{noqqz}{true}/' < $< > $@
+	sed -e 's/setboolean{noqqz}{false}/setboolean{noqqz}{true}/' \
+	    -e 's/{qqzchpend}{false}/{qqzchpend}{true}/' < $< > $@
 
 perfbook-a4.tex: perfbook-lt.tex
 perfbook-a4.tex:
@@ -458,7 +467,7 @@ help-full: help-official
 	@echo "Experimental targets:"
 	@echo "  Full,              Abbr."
 	@echo "  perfbook-qq.pdf,   qq:   framed Quick Quizzes"
-	@echo "  perfbook-nq.pdf,   nq:   without inline Quick Quizzes"
+	@echo "  perfbook-nq.pdf,   nq:   no inline Quick Quizzes (chapterwise Answers)"
 	@echo "  perfbook-msnt.pdf, msnt: newtxtt as monospace (non-slashed 0)"
 	@echo "  perfbook-mstx.pdf, mstx: txtt as monospace"
 	@echo "  perfbook-msr.pdf,  msr:  regular thickness courier clone as monospace"
SMPdesign/SMPdesign.tex +3 -1
index ef4d4c6c..c7570bae 100644
@@ -2,7 +2,7 @@
 % mainfile: ../perfbook.tex
 % SPDX-License-Identifier: CC-BY-SA-3.0
 
-\QuickQuizChapter{cha:Partitioning and Synchronization Design}{Partitioning and Synchronization Design}
+\QuickQuizChapter{cha:Partitioning and Synchronization Design}{Partitioning and Synchronization Design}{qqzSMPdesign}
 %
 \Epigraph{Divide and rule.}{\emph{Philip II of Macedon}}
 
@@ -1315,3 +1315,5 @@ System memory	  & Code locking   & Memory from/to system \\
 \end{table}
 
 \input{SMPdesign/beyond}
+
+\QuickQuizAnswersChp{qqzSMPdesign}
advsync/advsync.tex +3 -1
index 66cc797a..bfd3737d 100644
@@ -2,7 +2,7 @@
 % mainfile: ../perfbook.tex
 % SPDX-License-Identifier: CC-BY-SA-3.0
 
-\QuickQuizChapter{sec:advsync:Advanced Synchronization}{Advanced Synchronization}
+\QuickQuizChapter{sec:advsync:Advanced Synchronization}{Advanced Synchronization}{qqzadvsync}
 %
 \Epigraph{If a little knowledge is a dangerous thing, just think what
 	  you could do with a lot of knowledge!}{\emph{Unknown}}
@@ -455,3 +455,5 @@ However, once an appropriate body of theory becomes available,\footnote{
 it is wise to make use of it.
 
 \input{advsync/rt}
+
+\QuickQuizAnswersChp{qqzadvsync}
appendix/questions/questions.tex +3 -1
index f5b04d5f..4bb981bc 100644
@@ -2,7 +2,7 @@
 % mainfile: ../../perfbook.tex
 % SPDX-License-Identifier: CC-BY-SA-3.0
 
-\QuickQuizChapter{cha:app:Important Questions}{Important Questions}
+\QuickQuizChapter{cha:app:Important Questions}{Important Questions}{qqzquestions}
 %
 \Epigraph{Ask me no questions, and I'll tell you no fibs.}
 	 {\emph{``She Stoops to Conquer'', Oliver Goldsmith}}
@@ -31,3 +31,5 @@ pose an overwhelming challenge.
 \input{appendix/questions/concurrentparallel}
 \input{appendix/questions/time}
 \input{appendix/questions/ordering}
+
+\QuickQuizAnswersChp{qqzquestions}
appendix/toyrcu/toyrcu.tex +3 -1
index abfdf41a..6feff768 100644
@@ -2,7 +2,7 @@
 % mainfile: ../../perfbook.tex
 % SPDX-License-Identifier: CC-BY-SA-3.0
 
-\QuickQuizChapter{chp:app:``Toy'' RCU Implementations}{``Toy'' RCU Implementations}
+\QuickQuizChapter{chp:app:``Toy'' RCU Implementations}{``Toy'' RCU Implementations}{qqztoyrcu}
 %
 \Epigraph{The only difference between men and boys is the price of their toys.}
 	 {\emph{M. H\'ebert}}
@@ -1647,3 +1647,5 @@ create a new RCU implementation.
 	to a (mythical) unconditional read-to-write upgrade for
 	reader-writer locking.
 }\QuickQuizEnd
+
+\QuickQuizAnswersChp{qqztoyrcu}
appendix/whymb/whymemorybarriers.tex +3 -1
index a6e9fcdf..dff7fafc 100644
@@ -2,7 +2,7 @@
 % mainfile: ../../perfbook.tex
 % SPDX-License-Identifier: CC-BY-SA-3.0
 
-\QuickQuizChapter{chp:app:whymb:Why Memory Barriers?}{Why Memory Barriers?}
+\QuickQuizChapter{chp:app:whymb:Why Memory Barriers?}{Why Memory Barriers?}{qqzwhymb}
 %
 \Epigraph{Order!
 	  Order in the court!}
@@ -1669,3 +1669,5 @@ future such problems:
 \end{enumerate}
 
 Again, we encourage hardware designers to avoid these practices!
+
+\QuickQuizAnswersChp{qqzwhymb}
count/count.tex +3 -1
index 0dd35271..161ad2fc 100644
@@ -2,7 +2,7 @@
 % mainfile: ../perfbook.tex
 % SPDX-License-Identifier: CC-BY-SA-3.0
 
-\QuickQuizChapter{chp:Counting}{Counting}
+\QuickQuizChapter{chp:Counting}{Counting}{qqzcount}
 %
 \Epigraph{As easy as 1, 2, 3!}{\emph{Unknown}}
 
@@ -3247,3 +3247,5 @@ fundamental concurrency issues without the distraction of
 complex synchronization primitives or elaborate data structures.
 Such synchronization primitives and data structures are covered
 in later chapters.
+
+\QuickQuizAnswersChp{qqzcount}
cpu/cpu.tex +3 -1
index c563364a..85327a33 100644
@@ -2,7 +2,7 @@
 % mainfile: ../perfbook.tex
 % SPDX-License-Identifier: CC-BY-SA-3.0
 
-\QuickQuizChapter{chp:Hardware and its Habits}{Hardware and its Habits}
+\QuickQuizChapter{chp:Hardware and its Habits}{Hardware and its Habits}{qqzcpu}
 %
 \Epigraph{Premature abstraction is the root of all evil.}
 	 {\emph{A cast of thousands}}
@@ -68,3 +68,5 @@ Chapter~\ref{chp:Counting} will investigate problems and solutions to
 parallel counting, and
 Chapter~\ref{cha:Partitioning and Synchronization Design}
 will discuss design disciplines that promote performance and scalability.
+
+\QuickQuizAnswersChp{qqzcpu}
datastruct/datastruct.tex +3 -1
index 347b9381..16dc2286 100644
@@ -2,7 +2,7 @@
 % mainfile: ../perfbook.tex
 % SPDX-License-Identifier: CC-BY-SA-3.0
 
-\QuickQuizChapter{chp:Data Structures}{Data Structures}
+\QuickQuizChapter{chp:Data Structures}{Data Structures}{qqzdatastruct}
 %
 \Epigraph{Bad programmers worry about the code. Good programmers worry
 	  about data structures and their relationships.}
@@ -1938,3 +1938,5 @@ including:
 
 That said, performance and scalability are of little use without reliability,
 so the next chapter covers validation.
+
+\QuickQuizAnswersChp{qqzdatastruct}
debugging/debugging.tex +3 -1
index 4f13c4bc..39d46f9b 100644
@@ -2,7 +2,7 @@
 % mainfile: ../perfbook.tex
 % SPDX-License-Identifier: CC-BY-SA-3.0
 
-\QuickQuizChapter{chp:Validation}{Validation}
+\QuickQuizChapter{chp:Validation}{Validation}{qqzdebugging}
 %
 \Epigraph{If it is not tested, it doesn't work.}{\emph{Unknown}}
 
@@ -2657,3 +2657,5 @@ and, more speculatively, Section~\ref{sec:future:Formal Regression Testing?}.
 The topic of choosing a validation plan, be it testing, formal
 verification, or both, is taken up by
 \cref{sec:formal:Choosing a Validation Plan}.
+
+\QuickQuizAnswersChp{qqzdebugging}
defer/defer.tex +3 -1
index e972ddc1..738b13a5 100644
@@ -2,7 +2,7 @@
 % mainfile: ../perfbook.tex
 % SPDX-License-Identifier: CC-BY-SA-3.0
 
-\QuickQuizChapter{chp:Deferred Processing}{Deferred Processing}
+\QuickQuizChapter{chp:Deferred Processing}{Deferred Processing}{qqzdefer}
 %
 \Epigraph{All things come to those who wait.}{\emph{Violet Fane}}
 
@@ -113,3 +113,5 @@ ideal scalability and performance.
 \input{defer/rcuexercises}
 \input{defer/whichtochoose}
 \input{defer/updates}
+
+\QuickQuizAnswersChp{qqzdefer}
easy/easy.tex +3 -1
index ca4d1c14..455dffdd 100644
@@ -2,7 +2,7 @@
 % mainfile: ../perfbook.tex
 % SPDX-License-Identifier: CC-BY-SA-3.0
 
-\QuickQuizChapter{chp:Ease of Use}{Ease of Use}
+\QuickQuizChapter{chp:Ease of Use}{Ease of Use}{qqzeasy}
 %
 \Epigraph{Creating a perfect API is like committing the perfect crime.
 	  There are at least fifty things that can go wrong, and if you are
@@ -298,3 +298,5 @@ Figure~\ref{fig:easy:Shaving the Mandelbrot Set}.
 \caption{Shaving the Mandelbrot Set}
 \ContributedBy{Figure}{fig:easy:Shaving the Mandelbrot Set}{Melissa Broussard}
 \end{figure}
+
+\QuickQuizAnswersChp{qqzeasy}
formal/formal.tex +3 -1
index b37bbcb0..24289420 100644
@@ -2,7 +2,7 @@
 % mainfile: ../perfbook.tex
 % SPDX-License-Identifier: CC-BY-SA-3.0
 
-\QuickQuizChapter{chp:Formal Verification}{Formal Verification}
+\QuickQuizChapter{chp:Formal Verification}{Formal Verification}{qqzformal}
 %
 \Epigraph{Beware of bugs in the above code; I have only proved it correct,
 	  not tried it.}{\emph{Donald Knuth}}
@@ -376,3 +376,5 @@ In short, choosing a validation plan for concurrent software remains
 more an art than a science, let alone a field of engineering.
 However, there is every reason to expect that ordered approaches
 will continue to become more prevalent.
+
+\QuickQuizAnswersChp{qqzformal}
future/future.tex +3 -1
index e7832811..96cda4bb 100644
@@ -2,7 +2,7 @@
 % mainfile: ../perfbook.tex
 % SPDX-License-Identifier: CC-BY-SA-3.0
 
-\QuickQuizChapter{chp:Conflicting Visions of the Future}{Conflicting Visions of the Future}
+\QuickQuizChapter{chp:Conflicting Visions of the Future}{Conflicting Visions of the Future}{qqzfuture}
 %
 \Epigraph{Prediction is very difficult, especially about the future.}
 	 {\emph{Niels Bohr}}
@@ -151,3 +151,5 @@ that this long-touted methodology is starting to see credible
 competition on its formal-verification home turf.
 There is therefore continued reason to doubt the inevitability of
 functional-programming dominance.
+
+\QuickQuizAnswersChp{qqzfuture}
howto/howto.tex +21 -6
index c929aa10..23064a72 100644
@@ -2,7 +2,7 @@
 % mainfile: ../perfbook.tex
 % SPDX-License-Identifier: CC-BY-SA-3.0
 
-\QuickQuizChapter{chp:How To Use This Book}{How To Use This Book}
+\QuickQuizChapter{chp:How To Use This Book}{How To Use This Book}{qqzhowto}
 %
 \Epigraph{If you would only recognize that life is hard, things would be so
 	  much easier for you.}{\emph{Louis D. Brandeis}}
@@ -132,9 +132,11 @@ This chapter is followed by a number of appendices.
 The most popular of these appears to be
 Appendix~\ref{chp:app:whymb:Why Memory Barriers?},
 which delves even further into memory ordering.
+\IfQqzChpEnd{}{
 Appendix~\ref{chp:Answers to Quick Quizzes}
 contains the answers to the infamous Quick Quizzes, which are discussed in
 the next section.
+}
 
 \section{Quick Quizzes}
 \label{sec:howto:Quick Quizzes}
@@ -144,8 +146,15 @@ the next section.
 
 ``Quick quizzes'' appear throughout this book, and the answers may
 be found in
-Appendix~\ref{chp:Answers to Quick Quizzes} starting on
-page~\pageref{chp:Answers to Quick Quizzes}.
+\IfQqzChpEnd{
+the final section of each chapter.\footnote{
+	In the official release/edition of this book, all the answers are
+	gathered in an Appendix.
+}
+}{
+\cref{chp:Answers to Quick Quizzes} starting on
+\cpageref{chp:Answers to Quick Quizzes}.
+}
 Some of them are based on material in which that quick quiz
 appears, but others require you to think beyond that section, and,
 in some cases, beyond the realm of current knowledge.
@@ -160,9 +169,13 @@ of parallel programming.
 \QuickQuizB{
 	Where are the answers to the Quick Quizzes found?
 }\QuickQuizAnswerB{
-	In Appendix~\ref{chp:Answers to Quick Quizzes} starting on
-	page~\pageref{chp:Answers to Quick Quizzes}.
-
+\IfQqzChpEnd{
+	At the end of each chapter as you see here in
+        \cref{sec:qqzhowto:Answers to Quick Quizzes}.
+}{
+	In \cref{chp:Answers to Quick Quizzes} starting on
+	\cpageref{chp:Answers to Quick Quizzes}.
+}
 	Hey, I thought I owed you an easy one!
 }\QuickQuizEndB
 %
@@ -525,3 +538,5 @@ The style for this particular book is documented in
 As noted at the beginning of this section, I am this book's editor.
 However, if you choose to contribute, it will be your book as well.
 With that, I offer you Chapter~\ref{chp:Introduction}, our introduction.
+
+\QuickQuizAnswersChp{qqzhowto}
intro/intro.tex +3 -1
index 1de276b2..cfd6f91d 100644
@@ -2,7 +2,7 @@
 % mainfile: ../perfbook.tex
 % SPDX-License-Identifier: CC-BY-SA-3.0
 
-\QuickQuizChapter{chp:Introduction}{Introduction}
+\QuickQuizChapter{chp:Introduction}{Introduction}{qqzintro}
 %
 \Epigraph{If parallel programming is so hard, why are there so many
 	  parallel programs?}{\emph{Unknown}}
@@ -1240,3 +1240,5 @@ parallel-programming challenge here in the 21\textsuperscript{st} century!
 We are now ready to proceed to the next chapter, which dives into the
 relevant properties of the parallel hardware underlying our parallel
 software.
+
+\QuickQuizAnswersChp{qqzintro}
locking/locking.tex +3 -1
index ebcd0e35..89659d9c 100644
@@ -2,7 +2,7 @@
 % mainfile: ../perfbook.tex
 % SPDX-License-Identifier: CC-BY-SA-3.0
 
-\QuickQuizChapter{chp:Locking}{Locking}
+\QuickQuizChapter{chp:Locking}{Locking}{qqzlocking}
 %
 \Epigraph{Locking is the worst general-purpose synchronization mechanism
 	  except for all those other mechanisms that
@@ -2467,3 +2467,5 @@ need to one day run in parallel, locking should therefore not be the
 only tool in your parallel-programming toolbox.
 The next few chapters will discuss other tools, and how they can best
 be used in concert with locking and with each other.
+
+\QuickQuizAnswersChp{qqzlocking}
memorder/memorder.tex +3 -1
index fb623ca7..44e1d14d 100644
@@ -2,7 +2,7 @@
 % mainfile: ../perfbook.tex
 % SPDX-License-Identifier: CC-BY-SA-3.0
 
-\QuickQuizChapter{chp:Advanced Synchronization: Memory Ordering}{Advanced Synchronization: Memory Ordering}
+\QuickQuizChapter{chp:Advanced Synchronization: Memory Ordering}{Advanced Synchronization: Memory Ordering}{qqzmemorder}
 \OriginallyPublished{Chapter}{chp:Advanced Synchronization: Memory Ordering}{Advanced Synchronization: Memory Ordering}{the Linux kernel}{Howells2009membartxt}
 \OriginallyPublished{Chapter}{chp:Advanced Synchronization: Memory Ordering}{Advanced Synchronization: Memory Ordering}{Linux Weekly News}{JadeAlglave2017LWN-LKMM-1,JadeAlglave2017LWN-LKMM-2}
 %
@@ -4858,3 +4858,5 @@ One final word of advice: Use of raw memory-ordering primitives is
 a last resort.
 It is almost always better to use existing primitives, such as locking
 or RCU, thus letting those primitives do the memory ordering for you.
+
+\QuickQuizAnswersChp{qqzmemorder}
owned/owned.tex +3 -1
index b45fabb1..163f2d89 100644
@@ -2,7 +2,7 @@
 % mainfile: ../perfbook.tex
 % SPDX-License-Identifier: CC-BY-SA-3.0
 
-\QuickQuizChapter{chp:Data Ownership}{Data Ownership}
+\QuickQuizChapter{chp:Data Ownership}{Data Ownership}{qqzowned}
 %
 \Epigraph{It is mine, I tell you. My own. My precious. Yes, my precious.}
 	 {\emph{Gollum in ``The Fellowship of the Ring'', J.R.R.~Tolkien}}
@@ -435,3 +435,5 @@ greater performance and scalability coupled with reduced complexity.
 % populate with problems showing benefits of coupling data ownership with
 % other approaches. For example, work-stealing schedulers. Perhaps also
 % move memory allocation here, though its current location is quite good.
+
+\QuickQuizAnswersChp{qqzowned}
perfbook-lt.tex +3 -0
index 46b6ad06..6b339d51 100644
@@ -93,6 +93,9 @@
 \newboolean{noqqz}
 \setboolean{noqqz}{false}
 \newcommand{\IfNoQqz}[2]{\ifthenelse{\boolean{noqqz}}{#1}{#2}}
+\newboolean{qqzchpend}
+\setboolean{qqzchpend}{false}
+\newcommand{\IfQqzChpEnd}[2]{\ifthenelse{\boolean{qqzchpend}}{#1}{#2}}
 
 \input{autodate} % need to input here to reflect tag state
 \usepackage{qqz}
qqz.sty +20 -2
index 815ba2ad..6d87e192 100644
@@ -64,7 +64,7 @@
 \newcommand{\QuickQHeadingMiddle}[3]{\scriptsize\hyperref[#2.#3]{{ #3}}\label{#1.#3},}
 \newcommand{\QuickQHeadingEnd}[3]{\scriptsize\hyperref[#2.#3]{{ #3}}\label{#1.#3}}
 
-\newcommand{\QuickQuizChapter}[2]{
+\newcommand{\QuickQuizChapter}[3]{
 	\chapter{#2}
 	\label{#1}
 	}
@@ -168,6 +168,15 @@
 	\hyperref[QQA.#1]{Quick Quiz~#1}%
 }
 
+\IfQqzChpEnd{
+\newcommand{\QuickQuizAnswers}{}
+\newcommand{\QuickQuizAnswersChp}[1]{
+%	\renewcommand*{\theHNum}{\arabic{section}.\arabic{quickquizctrC}}
+%	\label{sec:#1:Answers to Quick Quizzes}
+	\setlength{\parskip}{0.0pt plus 1ex}
+	\input{#1}
+	\setlength{\parskip}{0.0pt plus 1.0pt}% return to default
+}}{
 \newcommand{\QuickQuizAnswers}{
 	\renewcommand*{\theHNum}{\arabic{section}.\arabic{quickquizctrC}}
 	\chapter{Answers to Quick Quizzes}
@@ -179,12 +188,21 @@
 	\input{qqz}
 	\setlength{\parskip}{0.0pt plus 1.0pt}% return to default
 }
+\newcommand{\QuickQuizAnswersChp}[1]{}
+}
 
 %% Internal interfaces generated by scripts.
 
-\newcommand{\QuickQAC}[2]{
+\IfQqzChpEnd{
+\newcommand{\QuickQAC}[3]{
+	\edef\QuickQuizAnswerChapter{\getrefnumber{#1}}
+	\section{Answers to Quick Quizzes}
+	\label{sec:#3:Answers to Quick Quizzes}}
+}{
+\newcommand{\QuickQAC}[3]{
 	\edef\QuickQuizAnswerChapter{\getrefnumber{#1}}
 	\section{#2}}
+}
 
 \IfQqzBg{
 \newcommand{\QuickQ}[1]{
together/together.tex +3 -1
index 88eb9568..4b558b71 100644
@@ -2,7 +2,7 @@
 % mainfile: ../perfbook.tex
 % SPDX-License-Identifier: CC-BY-SA-3.0
 
-\QuickQuizChapter{chp:Putting It All Together}{Putting It All Together}
+\QuickQuizChapter{chp:Putting It All Together}{Putting It All Together}{qqztogether}
 %
 \Epigraph{You don't learn how to shoot and then learn how to launch
 	  and then learn to do a controlled spin---you learn to
@@ -26,3 +26,5 @@ and finishing off with some hashing hassles in
 \input{together/hash.tex}
 % Later add section on updates: hashed arrays of locks, fifos/streaming,
 % batching to trade off latency for perf/scale.
+
+\QuickQuizAnswersChp{qqztogether}
toolsoftrade/toolsoftrade.tex +3 -1
index 71b935d7..034e72f0 100644
@@ -2,7 +2,7 @@
 % mainfile: ../perfbook.tex
 % SPDX-License-Identifier: CC-BY-SA-3.0
 
-\QuickQuizChapter{chp:Tools of the Trade}{Tools of the Trade}
+\QuickQuizChapter{chp:Tools of the Trade}{Tools of the Trade}{qqztoolsoftrade}
 %
 \Epigraph{You are only as good as your tools, and your tools are only
 	  as good as you are.}{\emph{Unknown}}
@@ -2629,3 +2629,5 @@ you realize that you are in trouble~\cite{DeadlockEmpire2016}.
 Therefore, it is necessary to make the right design choices as well as
 the correct choice of individual primitives,
 as will be discussed at length in subsequent chapters.
+
+\QuickQuizAnswersChp{qqztoolsoftrade}
utilities/divideqqz.pl new file +42 -0

42 lines not on this page · raw message

Signature · 1 line
2.17.1
#3 lore raw

PATCH 3/5 perfbook-lt.tex: Tell cleveref not to capitalize 'page' in \cpageref{}

In reply to Akira Yokosawa

From 9488aa3736a281a0f9be8b9f1748c25c9d60f970 Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <[email protected]>
Date: Tue, 28 Jul 2020 00:30:36 +0900
Subject: [PATCH 3/5] perfbook-lt.tex: Tell cleveref not to capitalize 'page' in \cpageref{}

Negate the "capitalise" option for "page" type reference.

---
 perfbook-lt.tex | 2 ++
 1 file changed, 2 insertions(+)
perfbook-lt.tex +2 -0
index 6b339d51..7432eecc 100644
@@ -225,6 +225,8 @@
 \crefname{sublisting}{Listing}{Listings}
 \crefname{sequencei}{step}{steps}
 \Crefname{sequencei}{Step}{Steps}
+\crefname{page}{page}{pages}
+\Crefname{page}{Page}{Pages}
 \newcommand{\crefrangeconjunction}{--}
 \newcommand{\creflastconjunction}{, and~}
 
Signature · 1 line
2.17.1
#4 lore raw

PATCH 4/5 datastruct: Use nbsp in captions (State (a), State (b), etc.)

In reply to Akira Yokosawa

From 05b67c1d4b598ac44fb159c1e6d8a56cdc17838f Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <[email protected]>
Date: Tue, 28 Jul 2020 11:33:56 +0900
Subject: [PATCH 4/5] datastruct: Use nbsp in captions (State (a), State (b), etc.)

---
 datastruct/datastruct.tex | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
datastruct/datastruct.tex +4 -4
index 16dc2286..c279115d 100644
@@ -840,14 +840,14 @@ concurrently with a resize operation (as well as with each other).
 \begin{figure}[tb]
 \centering
 \resizebox{3in}{!}{\includegraphics{datastruct/hashxu-a}}
-\caption{Growing a Double-List Hash Table, State (a)}
+\caption{Growing a Double-List Hash Table, State~(a)}
 \label{fig:datastruct:Growing a Double-List Hash Table; State (a)}
 \end{figure}
 
 \begin{figure}[tb]
 \centering
 \resizebox{3in}{!}{\includegraphics{datastruct/hashxu-b}}
-\caption{Growing a Double-List Hash Table, State (b)}
+\caption{Growing a Double-List Hash Table, State~(b)}
 \label{fig:datastruct:Growing a Double-List Hash Table; State (b)}
 \end{figure}
 
@@ -868,14 +868,14 @@ with readers still using the original two-bucket array.
 \begin{figure}[tb]
 \centering
 \resizebox{3in}{!}{\includegraphics{datastruct/hashxu-c}}
-\caption{Growing a Double-List Hash Table, State (c)}
+\caption{Growing a Double-List Hash Table, State~(c)}
 \label{fig:datastruct:Growing a Double-List Hash Table; State (c)}
 \end{figure}
 
 \begin{figure}[tb]
 \centering
 \resizebox{3in}{!}{\includegraphics{datastruct/hashxu-d}}
-\caption{Growing a Double-List Hash Table, State (d)}
+\caption{Growing a Double-List Hash Table, State~(d)}
 \label{fig:datastruct:Growing a Double-List Hash Table; State (d)}
 \end{figure}
 
Signature · 1 line
2.17.1
#5 lore raw

PATCH 5/5 formal: Retouch Table E.4

In reply to Akira Yokosawa

From 1316c9e3a238686385e8483bc0047d07c5e24d34 Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <[email protected]>
Date: Tue, 28 Jul 2020 16:10:22 +0900
Subject: [PATCH 5/5] formal: Retouch Table E.4

Use structured headers instead of tall rotated headers.

---
 formal/axiomatic.tex | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)
formal/axiomatic.tex +16 -10
index 494ea967..46a27708 100644
@@ -205,23 +205,29 @@ And in this case, the \co{herd} tool's output features the string
 	executions that fail to acquire the lock.
 
 \begin{table}[tb]
-\rowcolors{2}{}{lightgray}
+\rowcolors{10}{}{lightgray}
 \small
 \centering
-\newcommand{\lockfml}[1]{\multicolumn{1}{c}{\begin{picture}(6,150)(0,0)\rotatebox{90}{#1}\end{picture}}}
+\newcommand{\lockfml}[1]{\multicolumn{1}{c}{\begin{picture}(6,8)(0,0)\rotatebox{90}{#1}\end{picture}}}
 \begin{tabular}{rrrrrr}
-	\lockfml{\# Processes}
-	& \lockfml{Model}
-	& \lockfml{Emulate: \tco{cmpxchg_acquire()}, \tco{filter}}
-	& \lockfml{Emulate: \tco{xchg_acquire()}, \tco{filter}}
-	& \lockfml{Emulate: \tco{cmpxchg_acquire()}, \tco{exists}}
-	& \lockfml{Emulate: \tco{xchg_acquire()}, \tco{exists}}
+	\toprule
+	& Model & \multicolumn{4}{c}{Emulate} \\
+	\cmidrule(l){2-2} \cmidrule(l){3-6}
+	& & \multicolumn{2}{c}{\tco{filter}} & \multicolumn{2}{c}{\tco{exists}} \\
+	\cmidrule(l){3-4} \cmidrule(l){5-6}
+	\lockfml{\# Proc.}
+	& 
+	& \tco{cmpxchg}
+	& \tco{xchg}
+	& \tco{cmpxchg}
+	& \tco{xchg}
 	\\
-	\midrule
+	\cmidrule{1-1} \cmidrule(l){2-2} \cmidrule(l){3-4} \cmidrule(l){5-6}
 	2 & 0.004 &  0.022 &  0.027 &   0.039 &   0.058 \\
 	3 & 0.041 &  0.743 &  0.968 &   1.653 &   3.203 \\
-	4 & 0.374 & 59.565 & 74.818 & 151.962 & 500.96  \\
+	4 & 0.374 & 59.565 & 74.818 & 151.962 & 500.960 \\
 	5 & 4.905 \\
+	\bottomrule
 \end{tabular}
 \caption{Locking: Modeling vs. Emulation Time (s)}
 \label{tab:formal:Locking: Modeling vs. Emulation Time (s)}
Signature · 1 line
2.17.1
#6 lore raw
In reply to Akira Yokosawa
Quoted 18 lines · Akira Yokosawa

Hi Paul,

So, in the mean time, I've attempted chapterwise QQZ answers. This patch series is the resulting changes.

Patch #1 fixes a typo in Makefile which I noticed during this development.

Patch #2 is the main change enabling chapterwise QQZ answers in perfbook-nq.pdf.
This patch becomes a large one, as the addition of argument to macros in qqz.sty requires tree-wide changes for successful build. It also contains minor tweaks in howto.tex.

Patches #3--#5 are minor updates.
Patch #5 results in a table mostly identical to Table E.5. I don't think these quick quizzes are redundant, though.

Quoted 5 lines

The resulting perfbook-nq.pdf looks fairly reasonable to me. Some of the question parts have room to improve so that they are less context-dependent.

Let me know what you think.

Very nice!!! I have queued and pushed it. I removed an end-of-line space character on the last in the series, FYI.

The ability to jump back to the context makes the context-independence less of an emergency than it might be, but if you know of some that could use immediate help, please point them out to me. Longer term, it will of course be necessary to scan each quick quiz and update those that need to be more self-contained.

For a printed book, would it make sense to put the page number of the quick-quiz source (the location of the little box containing "QQ" and the quick-quiz number) into each answer? Or after each question?

Thanx, Paul

Quoted 41 lines

Thanks, Akira
--
Akira Yokosawa (5):
Makefile: Fix typo in CREFPTN
Enhance qqz scheme for chapterwise QQZ answers perfbook-lt.tex: Tell cleveref not to capitalize 'page' in \cpageref{}
datastruct: Use nbsp in captions (State (a), State (b), etc.)
formal: Retouch Table E.4

 .gitignore                           |  2 +-
 Makefile                             | 17 ++++++++---
 SMPdesign/SMPdesign.tex              |  4 ++-
 advsync/advsync.tex                  |  4 ++-
 appendix/questions/questions.tex     |  4 ++-
 appendix/toyrcu/toyrcu.tex           |  4 ++-
 appendix/whymb/whymemorybarriers.tex |  4 ++-
 count/count.tex                      |  4 ++-
 cpu/cpu.tex                          |  4 ++-
 datastruct/datastruct.tex            | 12 ++++----
 debugging/debugging.tex              |  4 ++-
 defer/defer.tex                      |  4 ++-
 easy/easy.tex                        |  4 ++-
 formal/axiomatic.tex                 | 26 ++++++++++-------
 formal/formal.tex                    |  4 ++-
 future/future.tex                    |  4 ++-
 howto/howto.tex                      | 27 ++++++++++++++----
 intro/intro.tex                      |  4 ++-
 locking/locking.tex                  |  4 ++-
 memorder/memorder.tex                |  4 ++-
 owned/owned.tex                      |  4 ++-
 perfbook-lt.tex                      |  5 ++++
 qqz.sty                              | 22 +++++++++++++--
 together/together.tex                |  4 ++-
 toolsoftrade/toolsoftrade.tex        |  4 ++-
 utilities/divideqqz.pl               | 42 ++++++++++++++++++++++++++++
 26 files changed, 179 insertions(+), 46 deletions(-)
 create mode 100755 utilities/divideqqz.pl
Signature · 1 line
2.17.1