<?xml version="1.0" encoding="UTF-8"?>
<Worksheet>
<Version major="11" minor="0"/>
<Label-Scheme value="2" prefix=""/>
<View-Properties presentation="false"><Zoom percentage="150"/></View-Properties>
<MapleNet-Properties warnlevel="3" longdelim="true" plotoptions="" echo="1" errorcursor="false" elisiontermsthreshold="10000" elisiontermsbefore="100" errorbreak="1" prettyprint="3" prompt="&gt; " latexwidth="6.0" useclientjvm="true" ansi="false" screenheight="25" labelwidth="20" plotdevice="inline" typesetting="standard" displayprecision="-1" indentamount="4" elisiondigitsthreshold="10000" quiet="false" plotoutput="terminal" rtablesize="10" preplot="" showassumed="1" plotdriver="openviz" elisiontermsafter="100" labelling="true" postplot="" screenwidth="79" elisiondigitsbefore="100" elisiondigitsafter="100" verboseproc="1" imaginaryunit="I" ShowLabels="true"/>
<Styles><Font name="Heading 4" background="[255,255,255]" bold="false" executable="false" family="Serif" foreground="[0,0,0]" italic="true" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Ordered List 5" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Ordered List 1" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Text Output" background="[255,255,255]" bold="false" executable="false" family="Monospaced" foreground="[0,0,255]" italic="false" opaque="false" readonly="true" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Bullet Item" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Equation Label" background="[255,255,255]" bold="true" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Author" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Text" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Diagnostic" background="[255,255,255]" bold="false" executable="false" family="Monospaced" foreground="[40,120,40]" italic="false" opaque="false" readonly="true" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Heading 2" background="[255,255,255]" bold="true" executable="false" family="Serif" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="16" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Page Number" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="10" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Ordered List 3" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Maple Plot" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Normal" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Maple Input" background="[255,255,255]" bold="true" executable="true" family="Monospaced" foreground="[255,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Annotation Title" background="[255,255,255]" bold="true" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="18" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="2D Output" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,255]" italic="false" opaque="false" readonly="true" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="2D Inert Output" background="[255,255,255]" bold="false" executable="true" family="Times New Roman" foreground="[144,144,144]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Dictionary Hyperlink" background="[255,255,255]" bold="false" executable="false" family="Serif" foreground="[147,0,15]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="true" placeholder="false"/>
<Font name="Dash Item" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Heading 3" background="[255,255,255]" bold="true" executable="false" family="Serif" foreground="[0,0,0]" italic="true" opaque="false" readonly="false" size="14" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Ordered List 4" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Maple Output" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="List Item" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="2D Input" background="[255,255,255]" bold="false" executable="true" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Line Printed Output" background="[255,255,255]" bold="false" executable="false" family="Monospaced" foreground="[0,0,255]" italic="false" opaque="false" readonly="true" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Maple Input Placeholder" background="[255,255,255]" bold="true" executable="true" family="Monospaced" foreground="[200,0,200]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="true"/>
<Font name="2D Math" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Error" background="[255,255,255]" bold="false" executable="false" family="Monospaced" foreground="[255,0,255]" italic="false" opaque="false" readonly="true" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Warning" background="[255,255,255]" bold="false" executable="false" family="Monospaced" foreground="[0,0,255]" italic="false" opaque="false" readonly="true" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Heading 1" background="[255,255,255]" bold="true" executable="false" family="Serif" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="18" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Annotation Text" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Title" background="[255,255,255]" bold="true" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="18" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Ordered List 2" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Hyperlink" background="[255,255,255]" bold="false" executable="false" family="Serif" foreground="[0,128,128]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="true" placeholder="false"/>
<Layout name="Ordered List 5" alignment="left" bullet="ROMAN" firstindent="0" leftmargin="144" rightmargin="0" linespacing="0.0" spaceabove="3" spacebelow="3" linebreak="space" pagebreak-before="false" initial="-1" bulletsuffix=""/>
<Layout name="Heading 4" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="0" spacebelow="0" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Text Output" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="0" spacebelow="0" linebreak="newline" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Ordered List 1" alignment="left" bullet="numeric" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="3" spacebelow="3" linebreak="space" pagebreak-before="false" initial="-1" bulletsuffix=""/>
<Layout name="Annotation Title" alignment="centred" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="12" spacebelow="12" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Bullet Item" alignment="left" bullet="dot" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="3" spacebelow="3" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Author" alignment="centred" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="8" spacebelow="8" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Dash Item" alignment="left" bullet="dash" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="3" spacebelow="3" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Heading 3" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="0" spacebelow="0" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Diagnostic" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="0" spacebelow="0" linebreak="any" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Ordered List 4" alignment="left" bullet="ALPHABETIC" firstindent="0" leftmargin="108" rightmargin="0" linespacing="0.0" spaceabove="3" spacebelow="3" linebreak="space" pagebreak-before="false" initial="-1" bulletsuffix=""/>
<Layout name="Maple Output" alignment="centred" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.3" spaceabove="0" spacebelow="0" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Line Printed Output" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="0" spacebelow="0" linebreak="any" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="List Item" alignment="left" bullet="indent" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="3" spacebelow="3" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Heading 2" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="8" spacebelow="2" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Ordered List 3" alignment="left" bullet="roman" firstindent="0" leftmargin="72" rightmargin="0" linespacing="0.0" spaceabove="3" spacebelow="3" linebreak="space" pagebreak-before="false" initial="-1" bulletsuffix=""/>
<Layout name="Error" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="0" spacebelow="0" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Maple Plot" alignment="centred" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="0" spacebelow="0" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Warning" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="0" spacebelow="0" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Heading 1" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="8" spacebelow="4" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Title" alignment="centred" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="12" spacebelow="12" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Ordered List 2" alignment="left" bullet="alphabetic" firstindent="0" leftmargin="36" rightmargin="0" linespacing="0.0" spaceabove="3" spacebelow="3" linebreak="space" pagebreak-before="false" initial="-1" bulletsuffix=""/>
<Layout name="Normal" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="0" spacebelow="0" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Pencil-style name="Pencil 3" pen-color="[0,0,0]" pen-height="3.0" pen-width="3.0" pen-opacity="1.0"/>
<Pencil-style name="Pencil 1" pen-color="[0,0,0]" pen-height="1.0" pen-width="1.0" pen-opacity="1.0"/>
<Pencil-style name="Pencil 5" pen-color="[255,0,0]" pen-height="5.0" pen-width="5.0" pen-opacity="1.0"/>
<Pencil-style name="Pencil 2" pen-color="[0,0,255]" pen-height="1.0" pen-width="1.0" pen-opacity="1.0"/>
<Pencil-style name="Pencil 4" pen-color="[0,0,255]" pen-height="3.0" pen-width="3.0" pen-opacity="1.0"/>
<Highlighter-style name="Highlighter 2" pen-color="[255,204,0]" pen-height="14.0" pen-width="14.0" pen-opacity="0.8"/>
<Highlighter-style name="Highlighter 4" pen-color="[0,255,255]" pen-height="32.0" pen-width="32.0" pen-opacity="0.8"/>
<Highlighter-style name="Highlighter 3" pen-color="[51,255,0]" pen-height="24.0" pen-width="24.0" pen-opacity="0.8"/>
<Highlighter-style name="Highlighter 1" pen-color="[255,153,255]" pen-height="12.0" pen-width="8.0" pen-opacity="0.8"/>
<Highlighter-style name="Highlighter 5" pen-color="[255,255,0]" pen-height="48.0" pen-width="48.0" pen-opacity="0.8"/>
</Styles>
<Task-table>
    <Task-category name="&lt;default&gt;">
    </Task-category>
</Task-table>
<Annotation-table>
    <Annotation-category name="&lt;default&gt;">
    </Annotation-category>
</Annotation-table>
<Task>
</Task>
<Group labelreference="L1" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal" alignment="centred"><Font bold="true" size="22">Parallel Capabilities in Maple 11</Font></Text-field>
</Input>
</Group>
<Group labelreference="L2" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal">It's generally advisable to have a multiple-cpu machine (as otherwise parallelization makes processing slower).
The machine used for this demo was an Athlon X2 dual core.</Text-field>
</Input>
</Group>
<Group labelreference="L3" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">kernelopts(numcpus);</Text-field>
</Input>
<Output>
<Text-field style="2D Output" layout="Maple Output"><Equation executable="false" style="2D Output">IiIj</Equation></Text-field>
</Output>
</Group>
<Section collapsed="true" MultipleChoiceAnswerIndex="-1" MultipleChoiceRandomizeChoices="false" TrueFalseAnswerIndex="-1" EssayAnswerRows="5" EssayAnswerColumns="60"><Title>
<Text-field style="Heading 1" layout="Heading 1">Capabilities/Limitations and the Package</Text-field></Title>
<Group labelreference="L9" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal">Current parallel capabilities are limited to thread-safe Maple (library) programs, and the kernel itself, which means:
</Text-field>
<Text-field style="Bullet Item" layout="Bullet Item">External calls (calls to external compiled libraries) run sequentially, as there is no guarantee that ext. programs are re-entrant.
</Text-field>
<Text-field style="Bullet Item" layout="Bullet Item">Maple library code will only work if there is no conflicting access for 'globals' (these can be read, and changed in an atomic way, but can be changed by any thread). The definition of 'globals' excludes only procedure locals, and environment variables. It includes globals, module locals, remember tables, etc. The exception is code that uses a Mutex when accessing globals.</Text-field>
<Text-field style="Text" layout="Normal"></Text-field>
<Text-field style="Text" layout="Normal">In summary, the current capabilities are limited to thread safe Maple code that you write yourself, or library routines that do not violate the limitations described above.

There are no direct parallel capabilities built into the kernel - the design is such that multiple operations can be performed, but the kernel itself does not launch multiple threads for large operations.</Text-field>
<Text-field style="Text" layout="Normal"></Text-field>
<Text-field style="Text" layout="Normal">Much of the Maple library code uses external libraries to perform certain operations (LinearAlgebra including Modular, numeric integration and ODE solution, string operations, etc.), so none of this code will run in parallel. </Text-field>
</Input>
</Group>
<Group labelreference="L11" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal"></Text-field>
</Input>
</Group>
<Group labelreference="L16" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal">In order to use these capabilities, you need to be running the parallel kernel, which can be enabled via the options dialog
(Tools <Equation executable="false" style="2D Math" input-equation="" display="LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYkLUkjbW9HRiQ2LVEoJnNyYXJyO0YnLyUsbWF0aHZhcmlhbnRHUSdub3JtYWxGJy8lJmZlbmNlR1EmZmFsc2VGJy8lKnNlcGFyYXRvckdGNC8lKXN0cmV0Y2h5R0Y0LyUqc3ltbWV0cmljR0Y0LyUobGFyZ2VvcEdGNC8lLm1vdmFibGVsaW1pdHNHRjQvJSdhY2NlbnRHRjQvJSdsc3BhY2VHUSYwLjBlbUYnLyUncnNwYWNlR0ZDRi8=">LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYkLUkjbW9HRiQ2LVEoJnNyYXJyO0YnLyUsbWF0aHZhcmlhbnRHUSdub3JtYWxGJy8lJmZlbmNlR1EmZmFsc2VGJy8lKnNlcGFyYXRvckdGNC8lKXN0cmV0Y2h5R0Y0LyUqc3ltbWV0cmljR0Y0LyUobGFyZ2VvcEdGNC8lLm1vdmFibGVsaW1pdHNHRjQvJSdhY2NlbnRHRjQvJSdsc3BhY2VHUSYwLjBlbUYnLyUncnNwYWNlR0ZDRi8=</Equation> Options <Equation executable="false" style="2D Math" input-equation="" display="LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYkLUkjbW9HRiQ2LVEoJnNyYXJyO0YnLyUsbWF0aHZhcmlhbnRHUSdub3JtYWxGJy8lJmZlbmNlR1EmZmFsc2VGJy8lKnNlcGFyYXRvckdGNC8lKXN0cmV0Y2h5R0Y0LyUqc3ltbWV0cmljR0Y0LyUobGFyZ2VvcEdGNC8lLm1vdmFibGVsaW1pdHNHRjQvJSdhY2NlbnRHRjQvJSdsc3BhY2VHUSYwLjBlbUYnLyUncnNwYWNlR0ZDRi8=">LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYkLUkjbW9HRiQ2LVEoJnNyYXJyO0YnLyUsbWF0aHZhcmlhbnRHUSdub3JtYWxGJy8lJmZlbmNlR1EmZmFsc2VGJy8lKnNlcGFyYXRvckdGNC8lKXN0cmV0Y2h5R0Y0LyUqc3ltbWV0cmljR0Y0LyUobGFyZ2VvcEdGNC8lLm1vdmFibGVsaW1pdHNHRjQvJSdhY2NlbnRHRjQvJSdsc3BhY2VHUSYwLjBlbUYnLyUncnNwYWNlR0ZDRi8=</Equation> Enable SMP Support, then restart), or by the -M option for TTY (there is no classic support at this time).</Text-field>
</Input>
</Group>
<Group labelreference="L15" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal"></Text-field>
</Input>
</Group>
<Group labelreference="L10" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal">The functionality is provided by the <Font italic="true">Threads</Font> package, which has 2 subpackages to deal with <Font italic="true">Mutex</Font> operations (mutual exclusion access to global data), and <Font italic="true">ConditionVariable</Font> (for thread synchronization).</Text-field>
</Input>
</Group>
<Group labelreference="L12" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">with(Threads);</Text-field>
</Input>
<Output>
<Text-field style="2D Output" layout="Maple Output"><Equation executable="false" style="2D Output">NypJJEFkZEc2IkkyQ29uZGl0aW9uVmFyaWFibGVHRiRJJ0NyZWF0ZUdGJEkkTXVsR0YkSSZNdXRleEdGJEklU2VsZkdGJEkkU2VxR0YkSSVXYWl0R0Yk</Equation></Text-field>
</Output>
</Group>
<Group labelreference="L13" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal">Note that three of the common sequence-type operations (Add, Mul, and Seq) have parallel implementations in this package.</Text-field>
</Input>
</Group>
<Group labelreference="L43" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal"></Text-field>
</Input>
</Group>
<Group labelreference="L42" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal">One final note: the threads implementation in the Windows API is missing significant functionality when considered with respect to the standard threading API. These operations are emulated on Windows, so performance gains will be much smaller there.</Text-field>
</Input>
</Group>
<Group labelreference="L17" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal"></Text-field>
</Input>
</Group>
</Section>
<Section collapsed="true" MultipleChoiceAnswerIndex="-1" MultipleChoiceRandomizeChoices="false" TrueFalseAnswerIndex="-1" EssayAnswerRows="5" EssayAnswerColumns="60"><Title>
<Text-field style="Heading 1" layout="Heading 1">Simple Examples</Text-field></Title>
<Group labelreference="L18" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal">Let's see how much of a timing improvement we can get with a large 'add' operation.</Text-field>
</Input>
</Group>
<Group labelreference="L19" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">s1 := [seq(rand(),i=1..10000)]:
s1 := map(op,[s1$1000]):
nops(s1);</Text-field>
</Input>
<Output>
<Text-field style="2D Output" layout="Maple Output"><Equation executable="false" style="2D Output">IikrKys1</Equation></Text-field>
</Output>
</Group>
<Group labelreference="L20" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">tt := time():
add(i,i=s1);
t1 := time()-tt;</Text-field>
</Input>
<Output>
<Text-field style="2D Output" layout="Maple Output"><Equation executable="false" style="2D Output">IjQrZ3RFJ1xaIVswJg==</Equation></Text-field>
</Output>
<Output>
<Text-field style="2D Output" layout="Maple Output"><Equation executable="false" style="2D Output" display="PkkjdDFHNiIkIiVfYCEiJA==">JCIlX2AhIiQ=</Equation></Text-field>
</Output>
</Group>
<Group labelreference="L21" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">tt := time():
Add(i,i=s1);
t2 := time()-tt;</Text-field>
</Input>
<Output>
<Text-field style="2D Output" layout="Maple Output"><Equation executable="false" style="2D Output">IjQrZ3RFJ1xaIVswJg==</Equation></Text-field>
</Output>
<Output>
<Text-field style="2D Output" layout="Maple Output"><Equation executable="false" style="2D Output" display="PkkjdDJHNiIkIiUheSMhIiQ=">JCIlIXkjISIk</Equation></Text-field>
</Output>
</Group>
<Group labelreference="L22" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">t1/t2;</Text-field>
</Input>
<Output>
<Text-field style="2D Output" layout="Maple Output"><Equation executable="false" style="2D Output">JCIrYyl6XiM+ISIq</Equation></Text-field>
</Output>
</Group>
<Group labelreference="L23" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal">So fairly close to a factor of 2.

Timings are far less impressive for smaller problems:</Text-field>
</Input>
</Group>
<Group labelreference="L24" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">s1 := [seq(rand(),i=1..1000)]:
s1 := map(op,[s1$1000]):
nops(s1);</Text-field>
</Input>
<Output>
<Text-field style="2D Output" layout="Maple Output"><Equation executable="false" style="2D Output">IigrKysi</Equation></Text-field>
</Output>
</Group>
<Group labelreference="L25" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">tt := time():
add(i,i=s1);
t1 := time()-tt;</Text-field>
</Input>
<Output>
<Text-field style="2D Output" layout="Maple Output"><Equation executable="false" style="2D Output">IjMrZyhIUyRlMzpd</Equation></Text-field>
</Output>
<Output>
<Text-field style="2D Output" layout="Maple Output"><Equation executable="false" style="2D Output" display="PkkjdDFHNiIkIiRXJCEiJA==">JCIkVyQhIiQ=</Equation></Text-field>
</Output>
</Group>
<Group labelreference="L26" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">tt := time():
Add(i,i=s1);
t2 := time()-tt;</Text-field>
</Input>
<Output>
<Text-field style="2D Output" layout="Maple Output"><Equation executable="false" style="2D Output">IjMrZyhIUyRlMzpd</Equation></Text-field>
</Output>
<Output>
<Text-field style="2D Output" layout="Maple Output"><Equation executable="false" style="2D Output" display="PkkjdDJHNiIkIiRLJCEiJA==">JCIkSyQhIiQ=</Equation></Text-field>
</Output>
</Group>
<Group labelreference="L27" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">t1/t2;</Text-field>
</Input>
<Output>
<Text-field style="2D Output" layout="Maple Output"><Equation executable="false" style="2D Output">JCIreVg5TzUhIio=</Equation></Text-field>
</Output>
</Group>
<Group labelreference="L28" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal"></Text-field>
</Input>
</Group>
</Section>
<Section collapsed="true" MultipleChoiceAnswerIndex="-1" MultipleChoiceRandomizeChoices="false" TrueFalseAnswerIndex="-1" EssayAnswerRows="5" EssayAnswerColumns="60"><Title>
<Text-field style="Heading 1" layout="Heading 1">Example of Thread Programming</Text-field></Title>
<Group labelreference="L29" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal">For this example, consider that we are attempting to factor an integer by the trial division method.

The plan is that we want split the task into multiple processes, sending each a batch of primes to use.

Note that this is a somewhat dumb implementation. A proper implementation would have facilities for launching a new batch when another is finished instead of having to wait for a whole batch.  </Text-field>
</Input>
</Group>
<Group labelreference="L30" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">TrialDivisionFactor := module()
local ModuleApply,Trial, primes,batch,n,res;

# Primes up to 1000000
primes := [seq(ithprime(i),i=1..78498)]:

Trial := proc(low,thread) local i;
   for i from low to min(nops(primes),low+batch-1) do
      if irem(n,primes[i])=0 then
         res[thread] := primes[i]; return;
      end if;
   end do;
   res[thread] := 0;
end proc:

ModuleApply := proc(num,{numthreads::posint:=1},{batchsize::posint:=1000})
uses Threads;
local ids,i,j;

   # Init
   n := num; batch := batchsize;
   res := Vector(numthreads);
   for i from 1 by numthreads*batchsize to nops(primes) do
      ids := seq(Create(Trial(i+(j-1)*batchsize,j)), j=1..numthreads);
      Wait(ids);
      if {seq(res[j],j=1..numthreads)}&lt;&gt;{0} then
         return ({seq(res[j],j=1..numthreads)} minus {0})[1];
      end if;
   end do;
   FAIL;
end proc:
      
end module:</Text-field>
</Input>
</Group>
<Group labelreference="L31" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal">Check timing for a single thread - one controller and one batch of 100 at a time:</Text-field>
</Input>
</Group>
<Group labelreference="L32" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">tt := time():
TrialDivisionFactor(nextprime(1000000),numthreads=1);
time()-tt;</Text-field>
</Input>
<Output>
<Text-field style="2D Output" layout="Maple Output"><Equation executable="false" style="2D Output">SSVGQUlMRyUqcHJvdGVjdGVkRw==</Equation></Text-field>
</Output>
<Output>
<Text-field style="2D Output" layout="Maple Output"><Equation executable="false" style="2D Output">JCIkOyQhIiQ=</Equation></Text-field>
</Output>
</Group>
<Group labelreference="L33" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">tt := time():
TrialDivisionFactor(nextprime(1000000),numthreads=2);
time()-tt;</Text-field>
</Input>
<Output>
<Text-field style="2D Output" layout="Maple Output"><Equation executable="false" style="2D Output">SSVGQUlMRyUqcHJvdGVjdGVkRw==</Equation></Text-field>
</Output>
<Output>
<Text-field style="2D Output" layout="Maple Output"><Equation executable="false" style="2D Output">JCIkYyMhIiQ=</Equation></Text-field>
</Output>
</Group>
<Group labelreference="L34" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">tt := time():
TrialDivisionFactor(nextprime(1000000),numthreads=3);
time()-tt;</Text-field>
</Input>
<Output>
<Text-field style="2D Output" layout="Maple Output"><Equation executable="false" style="2D Output">SSVGQUlMRyUqcHJvdGVjdGVkRw==</Equation></Text-field>
</Output>
<Output>
<Text-field style="2D Output" layout="Maple Output"><Equation executable="false" style="2D Output">JCIkcyIhIiQ=</Equation></Text-field>
</Output>
</Group>
<Group labelreference="L35" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">tt := time():
TrialDivisionFactor(nextprime(1000000),numthreads=4);
time()-tt;</Text-field>
</Input>
<Output>
<Text-field style="2D Output" layout="Maple Output"><Equation executable="false" style="2D Output">SSVGQUlMRyUqcHJvdGVjdGVkRw==</Equation></Text-field>
</Output>
<Output>
<Text-field style="2D Output" layout="Maple Output"><Equation executable="false" style="2D Output">JCIkIUchIiQ=</Equation></Text-field>
</Output>
</Group>
<Group labelreference="L36" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal"></Text-field>
</Input>
</Group>
</Section>
<Section collapsed="true" MultipleChoiceAnswerIndex="-1" MultipleChoiceRandomizeChoices="false" TrueFalseAnswerIndex="-1" EssayAnswerRows="5" EssayAnswerColumns="60"><Title>
<Text-field style="Heading 1" layout="Heading 1">What is and isn't parallel?</Text-field></Title>
<Group labelreference="L37" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal">We will use a simple program to test 2 simultaneous threads in an attempt to determine if the basic underlying operations can be implemented in parallel. </Text-field>
</Input>
</Group>
<Group labelreference="L39" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">RunTest := proc(func::procedure, arg::list)
uses Threads;
local t1,t2:
   lprint(ssystem(&quot;date&quot;));
   t1 := time( [func(op(arg)),func(op(arg))] ):
   lprint(ssystem(&quot;date&quot;));
   t2 := time( Wait(Create(func(op(arg))),
                    Create(func(op(arg)))) ):
   lprint(ssystem(&quot;date&quot;));
   printf(&quot;seq=%6.3f, para=%<Font encoding="UTF-8">6.3f, ratio=%5.3f\134n&quot;,</Font>
          t1,t2,t1/t2);
   NULL;
end proc:</Text-field>
</Input>
</Group>
<Group labelreference="L40" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal">Large integer multiplication (gmp):</Text-field>
</Input>
</Group>
<Group labelreference="L41" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">rr := rand(2^128):
nm := [seq(rr(),i=1..2000)]:</Text-field>
</Input>
</Group>
<Group labelreference="L52" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">testmul := proc(nm) local i,j;
   for i in nm do for j in nm do i*j end do end do:
end proc:</Text-field>
</Input>
</Group>
<Group labelreference="L44" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">RunTest(testmul,[nm]);</Text-field>
</Input>
<Output>
<Text-field style="Line Printed Output" layout="Line Printed Output">[0, &quot;Wed Mar 21 09:22:24 PDT 2007&quot;]</Text-field>
<Text-field style="Line Printed Output" layout="Line Printed Output">[0, &quot;Wed Mar 21 09:22:36 PDT 2007&quot;]</Text-field>
<Text-field style="Line Printed Output" layout="Line Printed Output">[0, &quot;Wed Mar 21 09:22:53 PDT 2007&quot;]</Text-field>
<Text-field style="Line Printed Output" layout="Line Printed Output">seq=12.568, para=19.961, ratio=0.630</Text-field>
</Output>
</Group>
<Group labelreference="L45" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal">Similar using kernel add</Text-field>
</Input>
</Group>
<Group labelreference="L46" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">testmul2 := proc() local i,j;
   add(add(i*j,j=nm),i=nm);
end proc:</Text-field>
</Input>
</Group>
<Group labelreference="L47" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">RunTest(testmul2,[]);</Text-field>
</Input>
<Output>
<Text-field style="Line Printed Output" layout="Line Printed Output">[0, &quot;Wed Mar 21 09:22:56 PDT 2007&quot;]</Text-field>
<Text-field style="Line Printed Output" layout="Line Printed Output">[0, &quot;Wed Mar 21 09:23:06 PDT 2007&quot;]</Text-field>
<Text-field style="Line Printed Output" layout="Line Printed Output">[0, &quot;Wed Mar 21 09:23:17 PDT 2007&quot;]
seq= 9.240, para=13.712, ratio=0.674</Text-field>
</Output>
</Group>
<Group labelreference="L48" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal">Polynomial multiplication</Text-field>
</Input>
</Group>
<Group labelreference="L49" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">nm := [seq(randpoly(x,degree=9,dense),i=1..2000)]:</Text-field>
</Input>
</Group>
<Group labelreference="L50" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">RunTest(testmul,[nm]);</Text-field>
</Input>
<Output>
<Text-field style="Line Printed Output" layout="Line Printed Output">[0, &quot;Wed Mar 21 09:23:21 PDT 2007&quot;]</Text-field>
<Text-field style="Line Printed Output" layout="Line Printed Output">[0, &quot;Wed Mar 21 09:23:35 PDT 2007&quot;]</Text-field>
<Text-field style="Line Printed Output" layout="Line Printed Output">[0, &quot;Wed Mar 21 09:23:54 PDT 2007&quot;]
seq=13.924, para=22.793, ratio=0.611</Text-field>
</Output>
</Group>
<Group labelreference="L51" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal">modp1 polynomial multiplication</Text-field>
</Input>
</Group>
<Group labelreference="L53" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">p := 23:
nm := [seq(modp1(ConvertIn(randpoly(x,degree=9,dense),x),p),i=1..2000)]:</Text-field>
</Input>
</Group>
<Group labelreference="L54" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">testmul3 := proc(nm,p) local i,j;
   for i in nm do for j in nm do
      modp1(Multiply(i,j),p);
   end do end do:
end proc:</Text-field>
</Input>
</Group>
<Group labelreference="L55" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">RunTest(testmul3,[nm,p]);</Text-field>
</Input>
<Output>
<Text-field style="Line Printed Output" layout="Line Printed Output">[0, &quot;Wed Mar 21 09:23:58 PDT 2007&quot;]</Text-field>
<Text-field style="Line Printed Output" layout="Line Printed Output">[0, &quot;Wed Mar 21 09:24:52 PDT 2007&quot;]</Text-field>
<Text-field style="Line Printed Output" layout="Line Printed Output">[0, &quot;Wed Mar 21 09:26:04 PDT 2007&quot;]</Text-field>
<Text-field style="Line Printed Output" layout="Line Printed Output">seq=53.299, para=83.617, ratio=0.637</Text-field>
</Output>
</Group>
<Group labelreference="L56" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal"></Text-field>
</Input>
</Group>
</Section>
<Section collapsed="true" MultipleChoiceAnswerIndex="-1" MultipleChoiceRandomizeChoices="false" TrueFalseAnswerIndex="-1" EssayAnswerRows="5" EssayAnswerColumns="60"><Title>
<Text-field style="Heading 1" layout="Heading 1">Other parallelizm in Maple</Text-field></Title>
<Group labelreference="L57" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal">At this time, the ATLAS BLAS in use by Maple have multiprocessing for 2 processors built in.</Text-field>
<Text-field style="Text" layout="Normal">Consider:</Text-field>
</Input>
</Group>
<Group labelreference="L58" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">M := LinearAlgebra:-RandomMatrix(8000,outputoptions=[datatype=float[8]]):</Text-field>
</Input>
</Group>
<Group labelreference="L59" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">ssystem(date);
tt := time():
M.M:
time()-tt;
ssystem(date);</Text-field>
</Input>
<Output>
<Text-field style="2D Output" layout="Maple Output"><Equation executable="false" style="2D Output">NyQiIiFRPVN1bn5NYXJ+MTh+MTI6NTM6MjJ+UERUfjIwMDc2Ig==</Equation></Text-field>
</Output>
<Output>
<Text-field style="2D Output" layout="Maple Output"><Equation executable="false" style="2D Output">JCIneHdFISIk</Equation></Text-field>
</Output>
<Output>
<Text-field style="2D Output" layout="Maple Output"><Equation executable="false" style="2D Output">NyQiIiFRPVN1bn5NYXJ+MTh+MTI6NTU6NDB+UERUfjIwMDc2Ig==</Equation></Text-field>
</Output>
</Group>
<Group labelreference="L60" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal">This entire operation runs in parallel, using 100% of 2 CPU the whole time. Note that the running duration is actually 2:18 = 138 sec - 1/2 the CPU time.

The total run-time for the non-parallel version is 265.04 sec 2.6 sec shorter, but the duration is the same.</Text-field>
</Input>
</Group>
<Group labelreference="L61" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal"></Text-field>
</Input>
</Group>
</Section>
</Worksheet>
