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: the flag -N2 requires the program to be built with -threaded (Jung Kim) 2. Re: let x = x in x (GHC.Prim) (Takenobu Tani) 3. Re: let x = x in x (GHC.Prim) (John Ky) ---------------------------------------------------------------------- Message: 1 Date: Wed, 23 Mar 2016 20:34:41 +0800 From: Jung Kim <jung...@gmail.com> To: sumit.sahrawat.ap...@iitbhu.ac.in, 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: <cabmbna2fatagpo6cfzrfg9wqvtfudym0r+ptd78jajcvm7u...@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 I changed to the suggested solution and that fixes the problem. Thank you very much! On 23 March 2016 at 14:25, Sumit Sahrawat, Maths & Computing, IIT (BHU) <sumit.sahrawat.ap...@iitbhu.ac.in> wrote: > 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 > > > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > ------------------------------ Message: 2 Date: Wed, 23 Mar 2016 23:20:09 +0900 From: Takenobu Tani <takenobu...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] let x = x in x (GHC.Prim) Message-ID: <CAPB_Nvy+bh71Z_nGvdWGtEwZLwZpwPQzdpy2w8iMe_G=ftt...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Hi John, > popCnt64# = let x = x in x It represents "bottom, or undefined, or infinite loop" [1]. (Almost primitives can't be represented with Haskell language.) In your case, It's good to use FFI call [2] like as Sylvain's nice code. If you dig GHC compiler's primitives, followings [3][4] may be useful. [1] https://www.fpcomplete.com/blog/2015/02/primitive-haskell [2] https://downloads.haskell.org/~ghc/master/users-guide/ffi-chap.html#primitive-imports [3] https://ghc.haskell.org/trac/ghc/wiki/Commentary/PrimOps [4] http://www.well-typed.com/blog/2014/06/understanding-the-realworld/ Cheers, Takenobu 2016-03-23 10:10 GMT+09:00 Sylvain Henry <sylv...@haskus.fr>: > 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 > listBeginners@haskell.orghttp://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > _______________________________________________ > 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/e5695d59/attachment-0001.html> ------------------------------ Message: 3 Date: Wed, 23 Mar 2016 21:28:23 +0000 From: John Ky <newho...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] let x = x in x (GHC.Prim) Message-ID: <camb4o-d4bpz881yx02aqvtou0ourdofpe47vltzvhtyvw_w...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Hi Rahul, I see mention of the popcount instruction in nativeGen/X86/CodeGen.hs. In particular it looks like it only activates if sse4_2 is activated? Maybe all I need to do is activate this somehow? Cheers, -John On Wed, 23 Mar 2016 at 12: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/9a92dd03/attachment.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 21 *****************************************