Send Beginners mailing list submissions to
        beginners@haskell.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  let x = x in x (GHC.Prim) (Sylvain Henry)
   2.  the flag -N2 requires the program to be built    with -threaded
      (Jung Kim)
   3. Re:  the flag -N2 requires the program to be built with
      -threaded (Sumit Sahrawat, Maths & Computing, IIT (BHU))


----------------------------------------------------------------------

Message: 1
Date: Wed, 23 Mar 2016 02:10:21 +0100
From: Sylvain Henry <sylv...@haskus.fr>
To: beginners@haskell.org
Subject: Re: [Haskell-beginners] let x = x in x (GHC.Prim)
Message-ID: <56f1ecfd.50...@haskus.fr>
Content-Type: text/plain; charset="windows-1252"; Format="flowed"

Hi,

You can also test your primop with a foreign primop.

See here for an example of assembly code (calling cpuid):
https://github.com/hsyl20/ViperVM/blob/master/src/lib/ViperVM/Arch/X86_64/cpuid.c

And here for the Haskell part with the foreign primop that calls the 
assembly code:
https://github.com/hsyl20/ViperVM/blob/master/src/lib/ViperVM/Arch/X86_64/Cpuid.hs#L56

Cheers,
Sylvain

On 23/03/2016 02:07, rahulm...@gmail.com wrote:
> Hi John,
>
> 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.
>
> Hope that helps!
> Rahul Muttineni
>
> Sent from my BlackBerry 10 smartphone.
> *From: *John Ky
> *Sent: *Wednesday 23 March 2016 4:40 AM
> *To: *The Haskell-Beginners Mailing List - Discussion of primarily 
> beginner-level topics related to Haskell
> *Reply To: *The Haskell-Beginners Mailing List - Discussion of 
> primarily beginner-level topics related to Haskell
> *Subject: *[Haskell-beginners] let x = x in x (GHC.Prim)
>
>
> Hello Haskellers,
>
> I'm trying to write a faster popCount function for x86 systems.
>
> I tried cloning the ghc-prim package and repurposing it for my own 
> needs, but it isn't working as hoped.
>
> In particular, popCnt64# was implemented in GHC.Prim as:
>
> popCnt64# = let x = x in x
>
> Which shouldn't terminate.  Yet when I call it, it magically finds the 
> C implementation in hs_popcnt64 and returns the correct value.
>
> My cloned project doesn't behave that way.  Instead it doesn't 
> terminate as I would expect.
>
> 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?
>
> Cheers,
>
> -John
>
>
>
>
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20160323/da52b572/attachment-0001.html>

------------------------------

Message: 2
Date: Wed, 23 Mar 2016 13:19:23 +0800
From: Jung Kim <jung...@gmail.com>
To: beginners@haskell.org
Subject: [Haskell-beginners] the flag -N2 requires the program to be
        built   with -threaded
Message-ID:
        <cabmbna3cnf+4+7kpxyzxydhffzafiof4yqcmhijs651dep0...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

I am currently reading an article[1] where the author uses Haskell to
explain her idea. The problem is I don't understand Haskell and am not
familiar with Haskell concept like MVar, IVar, etc. (I can get the
code compile, and have several years programming experiences.)

When testing the code, it throws the error messages "the flag -N2
requires the program to be built with -threaded"; however I can't find
thread related flag with ghc command by `ghc --help`. How can I fix
this problem?

Environment I use: Debian stretch/sid, kernel 4.0.0-2-rt-686-pae, GHC
version 7.10.3.

The code is exactly the same as described in the section
'Nondeterminism with MVars' of article; and the makefile content is

all:
        ghc -O mvar.hs
        ghc -o mvar mvar.o
run:
        ./execute # while true; do ./mvar +RTS -N2; done
clean:
        rm mvar

Thanks

[1]. 
http://composition.al/blog/2013/09/22/some-example-mvar-ivar-and-lvar-programs-in-haskell/


------------------------------

Message: 3
Date: Wed, 23 Mar 2016 11:55:25 +0530
From: "Sumit Sahrawat, Maths & Computing, IIT (BHU)"
        <sumit.sahrawat.ap...@iitbhu.ac.in>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] the flag -N2 requires the program to
        be built with -threaded
Message-ID:
        <CAJbEW8M-CO3Bn4F0HiYZDhzb3=yqhynskbkrt3ewsvzfnqm...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

As there are a lot of options, ghc has a `--show-options` flag which shows
them all. The `-threaded` flag is to be passed to ghc.
I think the second command in the `all` block is redundant, as `ghc -O
mvar.hs` should produce a binary named mvar.

This should work:

all:
    ghc -O -threaded mvar.hs

Regards,
  Sumit

On 23 March 2016 at 10:49, Jung Kim <jung...@gmail.com> wrote:

> I am currently reading an article[1] where the author uses Haskell to
> explain her idea. The problem is I don't understand Haskell and am not
> familiar with Haskell concept like MVar, IVar, etc. (I can get the
> code compile, and have several years programming experiences.)
>
> When testing the code, it throws the error messages "the flag -N2
> requires the program to be built with -threaded"; however I can't find
> thread related flag with ghc command by `ghc --help`. How can I fix
> this problem?
>
> Environment I use: Debian stretch/sid, kernel 4.0.0-2-rt-686-pae, GHC
> version 7.10.3.
>
> The code is exactly the same as described in the section
> 'Nondeterminism with MVars' of article; and the makefile content is
>
> all:
>         ghc -O mvar.hs
>         ghc -o mvar mvar.o
> run:
>         ./execute # while true; do ./mvar +RTS -N2; done
> clean:
>         rm mvar
>
> Thanks
>
> [1].
> http://composition.al/blog/2013/09/22/some-example-mvar-ivar-and-lvar-programs-in-haskell/
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20160323/5fd9c111/attachment-0001.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 93, Issue 20
*****************************************

Reply via email to