Implementing a new Primop, stage1 panic

(Reposting since this got cross-posted sort of oddly and I wasn't subscribed yet) I'm having an odd problem as I try to define my own primop, it seems that some docs may be out of date with respect to all of the touch points for a simple primop addition. I've followed what the various wiki pages have to offer (primarily http://hackage.haskell.org/trac/ghc/wiki/AddingNewPrimitiveOperations and http://hackage.haskell.org/trac/ghc/wiki/Commentary/PrimOps) without success. I even unraveled my PrimOp to be, basically, an exact copy of another PrimOp without luck. The primop I'm attempting to add is now very, very simple and copies FloatAddOp exactly so there must be an additional file I have to modify before the primop is "completely" added. Here are my simple modifications: ./compiler/prelude/primops.txt.pp primop FloatVAddOp "plusFloatVec#" Dyadic Float# -> Float# -> Float# with commutable = True ./compiler/codeGen/CgPrimOp.hs translateOp FloatVAddOp = Just (MO_F_Add W32) The compiler error is below. I have the feeling that an interface is not being built somewhere … this must be a simple one but I can't find any references to this error anywhere … has anyone seen this one before????? "inplace/bin/ghc-stage1" -H64m -O0 -fasm -package-name ghc-7.3.20111007 -hide-all-packages -i -icompiler/basicTypes -icompiler/cmm -icompiler/codeGen -icompiler/coreSyn -icompiler/deSugar -icompiler/ghci -icompiler/hsSyn -icompiler/iface -icompiler/llvmGen -icompiler/main -icompiler/nativeGen -icompiler/parser -icompiler/prelude -icompiler/profiling -icompiler/rename -icompiler/simplCore -icompiler/simplStg -icompiler/specialise -icompiler/stgSyn -icompiler/stranal -icompiler/typecheck -icompiler/types -icompiler/utils -icompiler/vectorise -icompiler/stage2/build -icompiler/stage2/build/autogen -Icompiler/stage2/build -Icompiler/stage2/build/autogen -Icompiler/../libffi/build/include -Icompiler/stage2 -Icompiler/../libraries/base/cbits -Icompiler/../libraries/base/include -Icompiler/. -Icompiler/parser -Icompiler/utils -optP-DGHCI -optP-include -optPcompiler/stage2/build/autogen/cabal_macros.h -package Cabal-1.11.2 -package array-0.3.0.3 -package base-4.4.0.0 -package bin-package-db-0.0.0.0 -package bytestring-0.9.2.0 -package containers-0.4.2.0 -package directory-1.1.0.1 -package filepath-1.2.0.1 -package hoopl-3.8.7.2 -package hpc-0.5.1.0 -package old-time-1.0.0.7 -package process-1.1.0.0 -package template-haskell-2.6.0.0 -package unix-2.5.0.0 -Wall -fno-warn-name-shadowing -fno-warn-orphans -XHaskell98 -XNondecreasingIndentation -XCPP -XMagicHash -XUnboxedTuples -XPatternGuards -XForeignFunctionInterface -XEmptyDataDecls -XTypeSynonymInstances -XMultiParamTypeClasses -XFlexibleInstances -XRank2Types -XScopedTypeVariables -XDeriveDataTypeable -DGHCI_TABLES_NEXT_TO_CODE -DSTAGE=2 -O0 -fasm -no-user-package-conf -rtsopts -odir compiler/stage2/build -hidir compiler/stage2/build -stubdir compiler/stage2/build -hisuf hi -osuf o -hcsuf hc -c compiler/iface/BinIface.hs -o compiler/stage2/build/BinIface.o ghc-stage1: panic! (the 'impossible' happened) (GHC version 7.3.20111007 for x86_64-unknown-linux): applyTypeToArgs ghc-prim:GHC.Prim.sizeofMutableArray#{(w) v 91V} [gid[PrimOp]] @ e{tv i4L2} [tv] ds{v i4Lc} [lid] i#{v i4Lg} [lid] forall a{tv 12} [tv]. ghc-prim:GHC.Prim.MutableArray#{(w) tc 31m} e{tv i4L2} [tv] a{tv 12} [tv] -> ghc-prim:GHC.Prim.Int#{(w) tc 3G} Paul Monday Parallel Scientific, LLC. paul.monday@parsci.com

Paul Always switch on -dcore-lint; it's a self-checker for types, and usually nails an error much closer to the source. Simon From: glasgow-haskell-users-bounces@haskell.org [mailto:glasgow-haskell-users-bounces@haskell.org] On Behalf Of Paul Monday Sent: 16 October 2011 16:54 To: glasgow-haskell-users@haskell.org Subject: Implementing a new Primop, stage1 panic (Reposting since this got cross-posted sort of oddly and I wasn't subscribed yet) I'm having an odd problem as I try to define my own primop, it seems that some docs may be out of date with respect to all of the touch points for a simple primop addition. I've followed what the various wiki pages have to offer (primarily http://hackage.haskell.org/trac/ghc/wiki/AddingNewPrimitiveOperations and http://hackage.haskell.org/trac/ghc/wiki/Commentary/PrimOps) without success. I even unraveled my PrimOp to be, basically, an exact copy of another PrimOp without luck. The primop I'm attempting to add is now very, very simple and copies FloatAddOp exactly so there must be an additional file I have to modify before the primop is "completely" added. Here are my simple modifications: ./compiler/prelude/primops.txt.pp primop FloatVAddOp "plusFloatVec#" Dyadic Float# -> Float# -> Float# with commutable = True ./compiler/codeGen/CgPrimOp.hs translateOp FloatVAddOp = Just (MO_F_Add W32) The compiler error is below. I have the feeling that an interface is not being built somewhere ... this must be a simple one but I can't find any references to this error anywhere ... has anyone seen this one before????? "inplace/bin/ghc-stage1" -H64m -O0 -fasm -package-name ghc-7.3.20111007 -hide-all-packages -i -icompiler/basicTypes -icompiler/cmm -icompiler/codeGen -icompiler/coreSyn -icompiler/deSugar -icompiler/ghci -icompiler/hsSyn -icompiler/iface -icompiler/llvmGen -icompiler/main -icompiler/nativeGen -icompiler/parser -icompiler/prelude -icompiler/profiling -icompiler/rename -icompiler/simplCore -icompiler/simplStg -icompiler/specialise -icompiler/stgSyn -icompiler/stranal -icompiler/typecheck -icompiler/types -icompiler/utils -icompiler/vectorise -icompiler/stage2/build -icompiler/stage2/build/autogen -Icompiler/stage2/build -Icompiler/stage2/build/autogen -Icompiler/../libffi/build/include -Icompiler/stage2 -Icompiler/../libraries/base/cbits -Icompiler/../libraries/base/include -Icompiler/. -Icompiler/parser -Icompiler/utils -optP-DGHCI -optP-include -optPcompiler/stage2/build/autogen/cabal_macros.h -package Cabal-1.11.2 -package array-0.3.0.3 -package base-4.4.0.0 -package bin-package-db-0.0.0.0 -package bytestring-0.9.2.0 -package containers-0.4.2.0 -package directory-1.1.0.1 -package filepath-1.2.0.1 -package hoopl-3.8.7.2 -package hpc-0.5.1.0 -package old-time-1.0.0.7 -package process-1.1.0.0 -package template-haskell-2.6.0.0 -package unix-2.5.0.0 -Wall -fno-warn-name-shadowing -fno-warn-orphans -XHaskell98 -XNondecreasingIndentation -XCPP -XMagicHash -XUnboxedTuples -XPatternGuards -XForeignFunctionInterface -XEmptyDataDecls -XTypeSynonymInstances -XMultiParamTypeClasses -XFlexibleInstances -XRank2Types -XScopedTypeVariables -XDeriveDataTypeable -DGHCI_TABLES_NEXT_TO_CODE -DSTAGE=2 -O0 -fasm -no-user-package-conf -rtsopts -odir compiler/stage2/build -hidir compiler/stage2/build -stubdir compiler/stage2/build -hisuf hi -osuf o -hcsuf hc -c compiler/iface/BinIface.hs -o compiler/stage2/build/BinIface.o ghc-stage1: panic! (the 'impossible' happened) (GHC version 7.3.20111007 for x86_64-unknown-linux): applyTypeToArgs ghc-prim:GHC.Prim.sizeofMutableArray#{(w) v 91V} [gid[PrimOp]] @ e{tv i4L2} [tv] ds{v i4Lc} [lid] i#{v i4Lg} [lid] forall a{tv 12} [tv]. ghc-prim:GHC.Prim.MutableArray#{(w) tc 31m} e{tv i4L2} [tv] a{tv 12} [tv] -> ghc-prim:GHC.Prim.Int#{(w) tc 3G} Paul Monday Parallel Scientific, LLC. paul.monday@parsci.commailto:paul.monday@parsci.com

Fascinating! I added the switch, figured I needed to clean everything to see the whole stack and whammo, everything worked. I wonder if the build is missing a dependency check along the way, I'll have to keep a close eye as I modify files now. Thanks for the tip! Paul Monday Parallel Scientific, LLC. paul.monday@parsci.com On Oct 17, 2011, at 8:00 AM, Simon Peyton-Jones wrote:
Paul
Always switch on -dcore-lint; it’s a self-checker for types, and usually nails an error much closer to the source.
Simon
From: glasgow-haskell-users-bounces@haskell.org [mailto:glasgow-haskell-users-bounces@haskell.org] On Behalf Of Paul Monday Sent: 16 October 2011 16:54 To: glasgow-haskell-users@haskell.org Subject: Implementing a new Primop, stage1 panic
(Reposting since this got cross-posted sort of oddly and I wasn't subscribed yet)
I'm having an odd problem as I try to define my own primop, it seems that some docs may be out of date with respect to all of the touch points for a simple primop addition. I've followed what the various wiki pages have to offer (primarily http://hackage.haskell.org/trac/ghc/wiki/AddingNewPrimitiveOperations and http://hackage.haskell.org/trac/ghc/wiki/Commentary/PrimOps) without success. I even unraveled my PrimOp to be, basically, an exact copy of another PrimOp without luck.
The primop I'm attempting to add is now very, very simple and copies FloatAddOp exactly so there must be an additional file I have to modify before the primop is "completely" added.
Here are my simple modifications:
./compiler/prelude/primops.txt.pp primop FloatVAddOp "plusFloatVec#" Dyadic Float# -> Float# -> Float# with commutable = True
./compiler/codeGen/CgPrimOp.hs translateOp FloatVAddOp = Just (MO_F_Add W32)
The compiler error is below. I have the feeling that an interface is not being built somewhere … this must be a simple one but I can't find any references to this error anywhere … has anyone seen this one before?????
"inplace/bin/ghc-stage1" -H64m -O0 -fasm -package-name ghc-7.3.20111007 -hide-all-packages -i -icompiler/basicTypes -icompiler/cmm -icompiler/codeGen -icompiler/coreSyn -icompiler/deSugar -icompiler/ghci -icompiler/hsSyn -icompiler/iface -icompiler/llvmGen -icompiler/main -icompiler/nativeGen -icompiler/parser -icompiler/prelude -icompiler/profiling -icompiler/rename -icompiler/simplCore -icompiler/simplStg -icompiler/specialise -icompiler/stgSyn -icompiler/stranal -icompiler/typecheck -icompiler/types -icompiler/utils -icompiler/vectorise -icompiler/stage2/build -icompiler/stage2/build/autogen -Icompiler/stage2/build -Icompiler/stage2/build/autogen -Icompiler/../libffi/build/include -Icompiler/stage2 -Icompiler/../libraries/base/cbits -Icompiler/../libraries/base/include -Icompiler/. -Icompiler/parser -Icompiler/utils -optP-DGHCI -optP-include -optPcompiler/stage2/build/autogen/cabal_macros.h -package Cabal-1.11.2 -package array-0.3.0.3 -package base-4.4.0.0 -package bin-package-db-0.0.0.0 -package bytestring-0.9.2.0 -package containers-0.4.2.0 -package directory-1.1.0.1 -package filepath-1.2.0.1 -package hoopl-3.8.7.2 -package hpc-0.5.1.0 -package old-time-1.0.0.7 -package process-1.1.0.0 -package template-haskell-2.6.0.0 -package unix-2.5.0.0 -Wall -fno-warn-name-shadowing -fno-warn-orphans -XHaskell98 -XNondecreasingIndentation -XCPP -XMagicHash -XUnboxedTuples -XPatternGuards -XForeignFunctionInterface -XEmptyDataDecls -XTypeSynonymInstances -XMultiParamTypeClasses -XFlexibleInstances -XRank2Types -XScopedTypeVariables -XDeriveDataTypeable -DGHCI_TABLES_NEXT_TO_CODE -DSTAGE=2 -O0 -fasm -no-user-package-conf -rtsopts -odir compiler/stage2/build -hidir compiler/stage2/build -stubdir compiler/stage2/build -hisuf hi -osuf o -hcsuf hc -c compiler/iface/BinIface.hs -o compiler/stage2/build/BinIface.o ghc-stage1: panic! (the 'impossible' happened) (GHC version 7.3.20111007 for x86_64-unknown-linux): applyTypeToArgs ghc-prim:GHC.Prim.sizeofMutableArray#{(w) v 91V} [gid[PrimOp]] @ e{tv i4L2} [tv] ds{v i4Lc} [lid] i#{v i4Lg} [lid] forall a{tv 12} [tv]. ghc-prim:GHC.Prim.MutableArray#{(w) tc 31m} e{tv i4L2} [tv] a{tv 12} [tv] -> ghc-prim:GHC.Prim.Int#{(w) tc 3G}
Paul Monday Parallel Scientific, LLC. paul.monday@parsci.com

On 17/10/2011 20:11, Paul Monday wrote:
Fascinating! I added the switch, figured I needed to clean everything to see the whole stack and whammo, everything worked.
I wonder if the build is missing a dependency check along the way, I'll have to keep a close eye as I modify files now.
Thanks for the tip!
I think adding a primop is something that does need a 'make clean', at least in the libraries and stage2. The reason is that you changed the interface to GHC.Prim, which is a magic internal module in GHC, and GHC doesn't track changes to that module. In principle GHC itself should generate a hash of the contents of GHC.Prim so that it could recompile correctly when the contents of GHC.Prim changes, but currently I think it just uses zero for the hash. I've just added this to the end of http://hackage.haskell.org/trac/ghc/wiki/AddingNewPrimitiveOperations Cheers, Simon
Paul Monday Parallel Scientific, LLC. paul.monday@parsci.com mailto:paul.monday@parsci.com
On Oct 17, 2011, at 8:00 AM, Simon Peyton-Jones wrote:
Paul Always switch on -dcore-lint; it’s a self-checker for types, and usually nails an error much closer to the source. Simon *From:*glasgow-haskell-users-bounces@haskell.org mailto:glasgow-haskell-users-bounces@haskell.org [mailto:glasgow-haskell-users-bounces@haskell.org]*On Behalf Of*Paul Monday *Sent:*16 October 2011 16:54 *To:*glasgow-haskell-users@haskell.org mailto:glasgow-haskell-users@haskell.org *Subject:*Implementing a new Primop, stage1 panic (Reposting since this got cross-posted sort of oddly and I wasn't subscribed yet) I'm having an odd problem as I try to define my own primop, it seems that some docs may be out of date with respect to all of the touch points for a simple primop addition. I've followed what the various wiki pages have to offer (primarily http://hackage.haskell.org/trac/ghc/wiki/AddingNewPrimitiveOperations and http://hackage.haskell.org/trac/ghc/wiki/Commentary/PrimOps)without success. I even unraveled my PrimOp to be, basically, an exact copy of another PrimOp without luck. The primop I'm attempting to add is now very, very simple and copies FloatAddOp exactly so there must be an additional file I have to modify before the primop is "completely" added. Here are my simple modifications: ./compiler/prelude/primops.txt.pp primop FloatVAddOp "plusFloatVec#" Dyadic Float# -> Float# -> Float# with commutable = True ./compiler/codeGen/CgPrimOp.hs translateOp FloatVAddOp= Just (MO_F_Add W32) The compiler error is below. I have the feeling that an interface is not being built somewhere … this must be a simple one but I can't find any references to this error anywhere … has anyone seen this one before????? "inplace/bin/ghc-stage1" -H64m -O0 -fasm -package-name ghc-7.3.20111007 -hide-all-packages -i -icompiler/basicTypes -icompiler/cmm -icompiler/codeGen -icompiler/coreSyn -icompiler/deSugar -icompiler/ghci -icompiler/hsSyn -icompiler/iface -icompiler/llvmGen -icompiler/main -icompiler/nativeGen -icompiler/parser -icompiler/prelude -icompiler/profiling -icompiler/rename -icompiler/simplCore -icompiler/simplStg -icompiler/specialise -icompiler/stgSyn -icompiler/stranal -icompiler/typecheck -icompiler/types -icompiler/utils -icompiler/vectorise -icompiler/stage2/build -icompiler/stage2/build/autogen -Icompiler/stage2/build -Icompiler/stage2/build/autogen -Icompiler/../libffi/build/include -Icompiler/stage2 -Icompiler/../libraries/base/cbits -Icompiler/../libraries/base/include -Icompiler/. -Icompiler/parser -Icompiler/utils -optP-DGHCI -optP-include -optPcompiler/stage2/build/autogen/cabal_macros.h -package Cabal-1.11.2 -package array-0.3.0.3 -package base-4.4.0.0 -package bin-package-db-0.0.0.0 -package bytestring-0.9.2.0 -package containers-0.4.2.0 -package directory-1.1.0.1 -package filepath-1.2.0.1 -package hoopl-3.8.7.2 -package hpc-0.5.1.0 -package old-time-1.0.0.7 -package process-1.1.0.0 -package template-haskell-2.6.0.0 -package unix-2.5.0.0 -Wall -fno-warn-name-shadowing -fno-warn-orphans -XHaskell98 -XNondecreasingIndentation -XCPP -XMagicHash -XUnboxedTuples -XPatternGuards -XForeignFunctionInterface -XEmptyDataDecls -XTypeSynonymInstances -XMultiParamTypeClasses -XFlexibleInstances -XRank2Types -XScopedTypeVariables -XDeriveDataTypeable-DGHCI_TABLES_NEXT_TO_CODE -DSTAGE=2 -O0 -fasm -no-user-package-conf -rtsopts -odir compiler/stage2/build -hidir compiler/stage2/build -stubdir compiler/stage2/build -hisuf hi -osuf o -hcsuf hc -c compiler/iface/BinIface.hs -o compiler/stage2/build/BinIface.o ghc-stage1: panic! (the 'impossible' happened) (GHC version 7.3.20111007 for x86_64-unknown-linux): applyTypeToArgs ghc-prim:GHC.Prim.sizeofMutableArray#{(w) v 91V} [gid[PrimOp]] @ e{tv i4L2} [tv] ds{v i4Lc} [lid] i#{v i4Lg} [lid] forall a{tv 12} [tv]. ghc-prim:GHC.Prim.MutableArray#{(w) tc 31m} e{tv i4L2} [tv] a{tv 12} [tv] -> ghc-prim:GHC.Prim.Int#{(w) tc 3G} Paul Monday Parallel Scientific, LLC. paul.monday@parsci.com mailto:paul.monday@parsci.com
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
participants (3)
-
Paul Monday
-
Simon Marlow
-
Simon Peyton-Jones