Re: Question on SSE intrinsics

2017-07-29 Thread Nicholas Wilson via Digitalmars-d-learn

On Sunday, 30 July 2017 at 02:05:32 UTC, Nicholas Wilson wrote:

On Saturday, 29 July 2017 at 22:45:12 UTC, piotrekg2 wrote:

What about __builtin_ctz?


https://github.com/ldc-developers/druntime/blob/ldc/src/ldc/intrinsics.di#L325


you can also make it out of bsf or bsr (i can't remember which) 
from `core.bitop`


Re: Question on SSE intrinsics

2017-07-29 Thread Nicholas Wilson via Digitalmars-d-learn

On Saturday, 29 July 2017 at 22:45:12 UTC, piotrekg2 wrote:

On Saturday, 29 July 2017 at 18:19:47 UTC, Johan Engelen wrote:

On Saturday, 29 July 2017 at 16:01:07 UTC, piotrekg2 wrote:

Hi,
I'm trying to port some of my c++ code which uses sse2 
instructions into D. The code calls the following intrinsics:


- _mm256_loadu_si256
- _mm256_movemask_epi8

Do they have any equivalent intrinsics in D?


Yes, with LDC (probably GDC too).
But unfortunately we don't have the "_mm256" functions (yet?), 
instead we have GCC's "__builtin_ia32..." functions.


The first one you mention I think is just an unaligned load? 
That can be done with the template `loadUnaligned` from module 
ldc.simd.


The second one has a synonym, "__builtin_ia32_pmovmskb256".

-Johan


What about __builtin_ctz?


https://github.com/ldc-developers/druntime/blob/ldc/src/ldc/intrinsics.di#L325



Re: Question on SSE intrinsics

2017-07-29 Thread piotrekg2 via Digitalmars-d-learn

On Saturday, 29 July 2017 at 18:19:47 UTC, Johan Engelen wrote:

On Saturday, 29 July 2017 at 16:01:07 UTC, piotrekg2 wrote:

Hi,
I'm trying to port some of my c++ code which uses sse2 
instructions into D. The code calls the following intrinsics:


- _mm256_loadu_si256
- _mm256_movemask_epi8

Do they have any equivalent intrinsics in D?


Yes, with LDC (probably GDC too).
But unfortunately we don't have the "_mm256" functions (yet?), 
instead we have GCC's "__builtin_ia32..." functions.


The first one you mention I think is just an unaligned load? 
That can be done with the template `loadUnaligned` from module 
ldc.simd.


The second one has a synonym, "__builtin_ia32_pmovmskb256".

-Johan


What about __builtin_ctz?


Re: Question on SSE intrinsics

2017-07-29 Thread Johan Engelen via Digitalmars-d-learn

On Saturday, 29 July 2017 at 16:01:07 UTC, piotrekg2 wrote:

Hi,
I'm trying to port some of my c++ code which uses sse2 
instructions into D. The code calls the following intrinsics:


- _mm256_loadu_si256
- _mm256_movemask_epi8

Do they have any equivalent intrinsics in D?


Yes, with LDC (probably GDC too).
But unfortunately we don't have the "_mm256" functions (yet?), 
instead we have GCC's "__builtin_ia32..." functions.


The first one you mention I think is just an unaligned load? That 
can be done with the template `loadUnaligned` from module 
ldc.simd.


The second one has a synonym, "__builtin_ia32_pmovmskb256".

-Johan



Re: Question on SSE intrinsics

2017-07-29 Thread Eugene Wissner via Digitalmars-d-learn

On Saturday, 29 July 2017 at 16:01:07 UTC, piotrekg2 wrote:

Hi,
I'm trying to port some of my c++ code which uses sse2 
instructions into D. The code calls the following intrinsics:


- _mm256_loadu_si256
- _mm256_movemask_epi8

Do they have any equivalent intrinsics in D?

I'm compiling my c++ code using gcc.

Thanks,
Piotr


https://stackoverflow.com/questions/14002946/explicit-simd-code-in-d

I don't think something has changed since then.


Question on SSE intrinsics

2017-07-29 Thread piotrekg2 via Digitalmars-d-learn

Hi,
I'm trying to port some of my c++ code which uses sse2 
instructions into D. The code calls the following intrinsics:


- _mm256_loadu_si256
- _mm256_movemask_epi8

Do they have any equivalent intrinsics in D?

I'm compiling my c++ code using gcc.

Thanks,
Piotr



Re: SSE intrinsics?

2009-01-22 Thread Jarrett Billingsley
On Thu, Jan 22, 2009 at 10:43 AM, Trass3r  wrote:
> Jarrett Billingsley schrieb:
>>
>> Why do that when you could use some template madness to make an SSE
>> assembler?  ;)
>
> ^^ Would that make sense?
> How do those intrinsics get evaluated? I mean in which step of compilation,
> in the frontend or backend, etc.

It was kind of a joke, but it's entirely possible.  You could write a
compile-time x86 assembler that would take a string and turn it into a
series of bytes.  Or simpler, just convert those instructions which
DMD doesn't know about into bytes, and leave the other instructions
alone.  You can then mix that into an assembly statement.

It's probably incredibly impractical for all but the simplest cases
but keep in mind that the compiler _is_ Turing-complete.


Re: SSE intrinsics?

2009-01-22 Thread Trass3r

Jarrett Billingsley schrieb:

Why do that when you could use some template madness to make an SSE
assembler?  ;)


^^ Would that make sense?
How do those intrinsics get evaluated? I mean in which step of 
compilation, in the frontend or backend, etc.


Re: SSE intrinsics?

2008-11-19 Thread Jarrett Billingsley
On Wed, Nov 19, 2008 at 1:32 PM, bearophile <[EMAIL PROTECTED]> wrote:
> Hoenir:
>> Does DMD provide/support something like the SSE intrinsics available in C++?
>
> Currently not. You can use SSE instructions inlining assembly code (it's not 
> too much difficult, there are documents online that show you how to use the 
> SSE instructions, but it may require some time to write the code).
>
> Bye,
> bearophile
>

Why do that when you could use some template madness to make an SSE
assembler?  ;)


Re: SSE intrinsics?

2008-11-19 Thread Hoenir

bearophile schrieb:

Hoenir:

Does DMD provide/support something like the SSE intrinsics available in C++?


Currently not. You can use SSE instructions inlining assembly code (it's not 
too much difficult, there are documents online that show you how to use the SSE 
instructions, but it may require some time to write the code).

Yeah, I know that option, but of course it's a little bit more 
time-consuming and harder to maintain/change ;)


Re: SSE intrinsics?

2008-11-19 Thread bearophile
Hoenir:
> Does DMD provide/support something like the SSE intrinsics available in C++?

Currently not. You can use SSE instructions inlining assembly code (it's not 
too much difficult, there are documents online that show you how to use the SSE 
instructions, but it may require some time to write the code).

Bye,
bearophile


SSE intrinsics?

2008-11-19 Thread Hoenir

Does DMD provide/support something like the SSE intrinsics available in C++?
Or is it only available in GDC? I'm not sure if this sort of thing 
belongs to front- or backend.