Do we need to maintain PrimRep.VecRep?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Do we need to maintain PrimRep.VecRep?

Ömer Sinan Ağacan
I have some code that does things depending on PrimReps of terms and so I have
to handle VecRep there. To understand what VecRep exactly is and how to use it I
looked at its uses, and all I can find was that we have a wired-in DataCon
`vecRepDataCon` which has a type that I thought should have VecRep PrimRep, but
when I test in GHCi I see that its PrimRep is PtrRep:

    λ> map typePrimRep (map dataConRepType (tyConDataCons runtimeRepTyCon))
    [PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep]

(This DataCon is not exported and only used in runtimeRepTyCon)

So I think VecRep may not be in use at the moment. Do we still need to maintain
it? What's the use case? Can anyone show me a Core term that has a type whose
PrimRep is VecRep?

Thanks..
_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Reply | Threaded
Open this post in threaded view
|

Re: Do we need to maintain PrimRep.VecRep?

Geoffrey Mainland
VecRep is used for vector operations. If you aren't using LLVM, you
won't see them.

VecRep's are generated by utils/genprimopcode/Main.hs.

Check out compiler/stage1/build/primop-vector-tys.hs-incl in your build
tree---should be plenty of generated VecRep's there :)

Cheers,
Geoff

On 06/07/2016 05:00 AM, Ömer Sinan Ağacan wrote:

> I have some code that does things depending on PrimReps of terms and so I have
> to handle VecRep there. To understand what VecRep exactly is and how to use it I
> looked at its uses, and all I can find was that we have a wired-in DataCon
> `vecRepDataCon` which has a type that I thought should have VecRep PrimRep, but
> when I test in GHCi I see that its PrimRep is PtrRep:
>
>     λ> map typePrimRep (map dataConRepType (tyConDataCons runtimeRepTyCon))
>     [PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep]
>
> (This DataCon is not exported and only used in runtimeRepTyCon)
>
> So I think VecRep may not be in use at the moment. Do we still need to maintain
> it? What's the use case? Can anyone show me a Core term that has a type whose
> PrimRep is VecRep?
>
> Thanks..
> _______________________________________________
> ghc-devs mailing list
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Reply | Threaded
Open this post in threaded view
|

Re: Do we need to maintain PrimRep.VecRep?

Ömer Sinan Ağacan
Thanks, I can see the TyCons with VecReps there.. but I still can't see how the
terms are constructed? Can you show me some example programs, or functions in
the compiler, that generate vector terms? (e.g. terms with types with VecReps)

2016-06-07 10:48 GMT-04:00 Geoffrey Mainland <[hidden email]>:

> VecRep is used for vector operations. If you aren't using LLVM, you
> won't see them.
>
> VecRep's are generated by utils/genprimopcode/Main.hs.
>
> Check out compiler/stage1/build/primop-vector-tys.hs-incl in your build
> tree---should be plenty of generated VecRep's there :)
>
> Cheers,
> Geoff
>
> On 06/07/2016 05:00 AM, Ömer Sinan Ağacan wrote:
>> I have some code that does things depending on PrimReps of terms and so I have
>> to handle VecRep there. To understand what VecRep exactly is and how to use it I
>> looked at its uses, and all I can find was that we have a wired-in DataCon
>> `vecRepDataCon` which has a type that I thought should have VecRep PrimRep, but
>> when I test in GHCi I see that its PrimRep is PtrRep:
>>
>>     λ> map typePrimRep (map dataConRepType (tyConDataCons runtimeRepTyCon))
>>     [PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep]
>>
>> (This DataCon is not exported and only used in runtimeRepTyCon)
>>
>> So I think VecRep may not be in use at the moment. Do we still need to maintain
>> it? What's the use case? Can anyone show me a Core term that has a type whose
>> PrimRep is VecRep?
>>
>> Thanks..
>> _______________________________________________
>> ghc-devs mailing list
>> [hidden email]
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
>
_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Reply | Threaded
Open this post in threaded view
|

Re: Do we need to maintain PrimRep.VecRep?

Geoffrey Mainland
Only programs that use vector primops will generate VecRep's. GHC is not
such a program.

The branch of vector that I modified to use vector primops will generate
VecRep's. You can find it here:

https://github.com/mainland/vector/tree/simd

It uses a modified version of primitive. See here, for example:

https://github.com/mainland/primitive/blob/simd/Data/Primitive/Multi.hs

The reason this is not available more widely is lack of support in the
native code generator. Do you have any interest in working on adding
such support? :)

Cheers,
Geoff

On 06/07/2016 11:08 AM, Ömer Sinan Ağacan wrote:

> Thanks, I can see the TyCons with VecReps there.. but I still can't see how the
> terms are constructed? Can you show me some example programs, or functions in
> the compiler, that generate vector terms? (e.g. terms with types with VecReps)
>
> 2016-06-07 10:48 GMT-04:00 Geoffrey Mainland <[hidden email]>:
>> VecRep is used for vector operations. If you aren't using LLVM, you
>> won't see them.
>>
>> VecRep's are generated by utils/genprimopcode/Main.hs.
>>
>> Check out compiler/stage1/build/primop-vector-tys.hs-incl in your build
>> tree---should be plenty of generated VecRep's there :)
>>
>> Cheers,
>> Geoff
>>
>> On 06/07/2016 05:00 AM, Ömer Sinan Ağacan wrote:
>>> I have some code that does things depending on PrimReps of terms and so I have
>>> to handle VecRep there. To understand what VecRep exactly is and how to use it I
>>> looked at its uses, and all I can find was that we have a wired-in DataCon
>>> `vecRepDataCon` which has a type that I thought should have VecRep PrimRep, but
>>> when I test in GHCi I see that its PrimRep is PtrRep:
>>>
>>>     λ> map typePrimRep (map dataConRepType (tyConDataCons runtimeRepTyCon))
>>>     [PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep]
>>>
>>> (This DataCon is not exported and only used in runtimeRepTyCon)
>>>
>>> So I think VecRep may not be in use at the moment. Do we still need to maintain
>>> it? What's the use case? Can anyone show me a Core term that has a type whose
>>> PrimRep is VecRep?
>>>
>>> Thanks..
>>> _______________________________________________
>>> ghc-devs mailing list
>>> [hidden email]
>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Reply | Threaded
Open this post in threaded view
|

Re: Do we need to maintain PrimRep.VecRep?

Ömer Sinan Ağacan
Ahh, I see... I finally found the primops, machops, and code generator for x86:

      MO_V_Insert {}   -> needLlvm
      MO_V_Extract {}  -> needLlvm
      MO_V_Add {}      -> needLlvm
      MO_V_Sub {}      -> needLlvm
      ...

> The reason this is not available more widely is lack of support in the native
> code generator. Do you have any interest in working on adding such support?
> :)

I'm afraid I'm short on free time at the moment but I'll let you know if I have
a chance to work on that.

Thanks,
Omer

2016-06-07 11:22 GMT-04:00 Geoffrey Mainland <[hidden email]>:

> Only programs that use vector primops will generate VecRep's. GHC is not
> such a program.
>
> The branch of vector that I modified to use vector primops will generate
> VecRep's. You can find it here:
>
> https://github.com/mainland/vector/tree/simd
>
> It uses a modified version of primitive. See here, for example:
>
> https://github.com/mainland/primitive/blob/simd/Data/Primitive/Multi.hs
>
> The reason this is not available more widely is lack of support in the
> native code generator. Do you have any interest in working on adding
> such support? :)
>
> Cheers,
> Geoff
>
> On 06/07/2016 11:08 AM, Ömer Sinan Ağacan wrote:
>> Thanks, I can see the TyCons with VecReps there.. but I still can't see how the
>> terms are constructed? Can you show me some example programs, or functions in
>> the compiler, that generate vector terms? (e.g. terms with types with VecReps)
>>
>> 2016-06-07 10:48 GMT-04:00 Geoffrey Mainland <[hidden email]>:
>>> VecRep is used for vector operations. If you aren't using LLVM, you
>>> won't see them.
>>>
>>> VecRep's are generated by utils/genprimopcode/Main.hs.
>>>
>>> Check out compiler/stage1/build/primop-vector-tys.hs-incl in your build
>>> tree---should be plenty of generated VecRep's there :)
>>>
>>> Cheers,
>>> Geoff
>>>
>>> On 06/07/2016 05:00 AM, Ömer Sinan Ağacan wrote:
>>>> I have some code that does things depending on PrimReps of terms and so I have
>>>> to handle VecRep there. To understand what VecRep exactly is and how to use it I
>>>> looked at its uses, and all I can find was that we have a wired-in DataCon
>>>> `vecRepDataCon` which has a type that I thought should have VecRep PrimRep, but
>>>> when I test in GHCi I see that its PrimRep is PtrRep:
>>>>
>>>>     λ> map typePrimRep (map dataConRepType (tyConDataCons runtimeRepTyCon))
>>>>     [PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep]
>>>>
>>>> (This DataCon is not exported and only used in runtimeRepTyCon)
>>>>
>>>> So I think VecRep may not be in use at the moment. Do we still need to maintain
>>>> it? What's the use case? Can anyone show me a Core term that has a type whose
>>>> PrimRep is VecRep?
>>>>
>>>> Thanks..
>>>> _______________________________________________
>>>> ghc-devs mailing list
>>>> [hidden email]
>>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
>
_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Reply | Threaded
Open this post in threaded view
|

Re: Do we need to maintain PrimRep.VecRep?

Carter Schonwald
There's also the question of whether or not the high level simd ops that llvm exposes are the ones that can be easily supported by the native code Gen without duplicating llvm specific logic around lowering on various architectures.  Though for the basic horizontal operations that are currently exposed that should be straight forward.  But might be more tricky for shuffle and dot product kinds of things. 

On Tuesday, June 7, 2016, Ömer Sinan Ağacan <[hidden email]> wrote:
Ahh, I see... I finally found the primops, machops, and code generator for x86:

      MO_V_Insert {}   -> needLlvm
      MO_V_Extract {}  -> needLlvm
      MO_V_Add {}      -> needLlvm
      MO_V_Sub {}      -> needLlvm
      ...

> The reason this is not available more widely is lack of support in the native
> code generator. Do you have any interest in working on adding such support?
> :)

I'm afraid I'm short on free time at the moment but I'll let you know if I have
a chance to work on that.

Thanks,
Omer

2016-06-07 11:22 GMT-04:00 Geoffrey Mainland <<a href="javascript:;" onclick="_e(event, &#39;cvml&#39;, &#39;mainland@apeiron.net&#39;)">mainland@...>:
> Only programs that use vector primops will generate VecRep's. GHC is not
> such a program.
>
> The branch of vector that I modified to use vector primops will generate
> VecRep's. You can find it here:
>
> https://github.com/mainland/vector/tree/simd
>
> It uses a modified version of primitive. See here, for example:
>
> https://github.com/mainland/primitive/blob/simd/Data/Primitive/Multi.hs
>
> The reason this is not available more widely is lack of support in the
> native code generator. Do you have any interest in working on adding
> such support? :)
>
> Cheers,
> Geoff
>
> On 06/07/2016 11:08 AM, Ömer Sinan Ağacan wrote:
>> Thanks, I can see the TyCons with VecReps there.. but I still can't see how the
>> terms are constructed? Can you show me some example programs, or functions in
>> the compiler, that generate vector terms? (e.g. terms with types with VecReps)
>>
>> 2016-06-07 10:48 GMT-04:00 Geoffrey Mainland <<a href="javascript:;" onclick="_e(event, &#39;cvml&#39;, &#39;mainland@apeiron.net&#39;)">mainland@...>:
>>> VecRep is used for vector operations. If you aren't using LLVM, you
>>> won't see them.
>>>
>>> VecRep's are generated by utils/genprimopcode/Main.hs.
>>>
>>> Check out compiler/stage1/build/primop-vector-tys.hs-incl in your build
>>> tree---should be plenty of generated VecRep's there :)
>>>
>>> Cheers,
>>> Geoff
>>>
>>> On 06/07/2016 05:00 AM, Ömer Sinan Ağacan wrote:
>>>> I have some code that does things depending on PrimReps of terms and so I have
>>>> to handle VecRep there. To understand what VecRep exactly is and how to use it I
>>>> looked at its uses, and all I can find was that we have a wired-in DataCon
>>>> `vecRepDataCon` which has a type that I thought should have VecRep PrimRep, but
>>>> when I test in GHCi I see that its PrimRep is PtrRep:
>>>>
>>>>     λ> map typePrimRep (map dataConRepType (tyConDataCons runtimeRepTyCon))
>>>>     [PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep,PtrRep]
>>>>
>>>> (This DataCon is not exported and only used in runtimeRepTyCon)
>>>>
>>>> So I think VecRep may not be in use at the moment. Do we still need to maintain
>>>> it? What's the use case? Can anyone show me a Core term that has a type whose
>>>> PrimRep is VecRep?
>>>>
>>>> Thanks..
>>>> _______________________________________________
>>>> ghc-devs mailing list
>>>> <a href="javascript:;" onclick="_e(event, &#39;cvml&#39;, &#39;ghc-devs@haskell.org&#39;)">ghc-devs@...
>>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
>
_______________________________________________
ghc-devs mailing list
<a href="javascript:;" onclick="_e(event, &#39;cvml&#39;, &#39;ghc-devs@haskell.org&#39;)">ghc-devs@...
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs