<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hi,<br>
<br>
You can also test your primop with a foreign primop.<br>
<br>
See here for an example of assembly code (calling cpuid):<br>
<a class="moz-txt-link-freetext" href="https://github.com/hsyl20/ViperVM/blob/master/src/lib/ViperVM/Arch/X86_64/cpuid.c">https://github.com/hsyl20/ViperVM/blob/master/src/lib/ViperVM/Arch/X86_64/cpuid.c</a><br>
<br>
And here for the Haskell part with the foreign primop that calls the
assembly code:<br>
<a class="moz-txt-link-freetext" href="https://github.com/hsyl20/ViperVM/blob/master/src/lib/ViperVM/Arch/X86_64/Cpuid.hs#L56">https://github.com/hsyl20/ViperVM/blob/master/src/lib/ViperVM/Arch/X86_64/Cpuid.hs#L56</a><br>
<br>
Cheers,<br>
Sylvain<br>
<br>
<div class="moz-cite-prefix">On 23/03/2016 02:07,
<a class="moz-txt-link-abbreviated" href="mailto:rahulmutt@gmail.com">rahulmutt@gmail.com</a> wrote:<br>
</div>
<blockquote cite="mid:20160323010713.5902417.30655.15037@gmail.com"
type="cite">
<div style="width: 100%; font-size: initial; font-family: Calibri,
'Slate Pro', sans-serif, sans-serif; color: rgb(31, 73, 125);
text-align: initial; background-color: rgb(255, 255, 255);">Hi
John,</div>
<div style="width: 100%; font-size: initial; font-family: Calibri,
'Slate Pro', sans-serif, sans-serif; color: rgb(31, 73, 125);
text-align: initial; background-color: rgb(255, 255, 255);"><br>
</div>
<div style="width: 100%; font-size: initial; font-family: Calibri,
'Slate Pro', sans-serif, sans-serif; color: rgb(31, 73, 125);
text-align: initial; background-color: rgb(255, 255, 255);">ghc-prim
is just a stub package generated for the purpose of
documentation. All primops are defined in a low level language
called Cmm in GHC. If you want to make it even faster, you'll
need to learn Cmm and update the definition in GHC. If you want
to a specialized implementation for x86 systems, you may need to
modify the NCG (Native Code Generator) which requires a
knowledge of assembly language.</div>
<div style="width: 100%; font-size: initial; font-family: Calibri,
'Slate Pro', sans-serif, sans-serif; color: rgb(31, 73, 125);
text-align: initial; background-color: rgb(255, 255, 255);"><br>
</div>
<div style="width: 100%; font-size: initial; font-family: Calibri,
'Slate Pro', sans-serif, sans-serif; color: rgb(31, 73, 125);
text-align: initial; background-color: rgb(255, 255, 255);">Hope
that helps!</div>
<div style="width: 100%; font-size: initial; font-family: Calibri,
'Slate Pro', sans-serif, sans-serif; color: rgb(31, 73, 125);
text-align: initial; background-color: rgb(255, 255, 255);">Rahul
Muttineni</div>
<div style="width: 100%; font-size: initial; font-family: Calibri,
'Slate Pro', sans-serif, sans-serif; color: rgb(31, 73, 125);
text-align: initial; background-color: rgb(255, 255, 255);"><br
style="display:initial">
</div>
<div style="font-size: initial; font-family: Calibri, 'Slate Pro',
sans-serif, sans-serif; color: rgb(31, 73, 125); text-align:
initial; background-color: rgb(255, 255, 255);">Sent from my BlackBerry 10 smartphone.</div>
<table style="background-color:white;border-spacing:0px;"
width="100%">
<tbody>
<tr>
<td colspan="2" style="font-size: initial; text-align:
initial; background-color: rgb(255, 255, 255);">
<div style="border-style: solid none none;
border-top-color: rgb(181, 196, 223); border-top-width:
1pt; padding: 3pt 0in 0in; font-family: Tahoma, 'BB
Alpha Sans', 'Slate Pro'; font-size: 10pt;">
<div><b>From: </b>John Ky</div>
<div><b>Sent: </b>Wednesday 23 March 2016 4:40 AM</div>
<div><b>To: </b>The Haskell-Beginners Mailing List -
Discussion of primarily beginner-level topics related
to Haskell</div>
<div><b>Reply To: </b>The Haskell-Beginners Mailing
List - Discussion of primarily beginner-level topics
related to Haskell</div>
<div><b>Subject: </b>[Haskell-beginners] let x = x in x
(GHC.Prim)</div>
</div>
</td>
</tr>
</tbody>
</table>
<br>
<div id="_originalContent" style="">
<div dir="ltr">Hello Haskellers,
<div><br>
</div>
<div>I'm trying to write a faster popCount function for x86
systems.<br>
</div>
<div><br>
</div>
<div>I tried cloning the ghc-prim package and repurposing it
for my own needs, but it isn't working as hoped.</div>
<div><br>
</div>
<div>In particular, popCnt64# was implemented in GHC.Prim as:</div>
<div><br>
</div>
<div>popCnt64# = let x = x in x<br>
</div>
<div><br>
</div>
<div>Which shouldn't terminate. Yet when I call it, it
magically finds the C implementation in hs_popcnt64 and
returns the correct value.</div>
<div><br>
</div>
<div>My cloned project doesn't behave that way. Instead it
doesn't terminate as I would expect.</div>
<div><br>
</div>
<div>Anyone know what's happening here, if there is a way to
make this work or tell me if I'm going about this completely
the wrong way?</div>
<div><br>
</div>
<div>Cheers,</div>
<div><br>
</div>
<div>-John</div>
<div><br>
</div>
</div>
<br>
<!--end of _originalContent --></div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Beginners mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Beginners@haskell.org">Beginners@haskell.org</a>
<a class="moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a>
</pre>
</blockquote>
<br>
</body>
</html>