Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DataConverter] If SSE2 is not available, mul_const is incorrect #10

Open
btgoodwin opened this issue Jul 11, 2019 · 2 comments
Open

[DataConverter] If SSE2 is not available, mul_const is incorrect #10

btgoodwin opened this issue Jul 11, 2019 · 2 comments

Comments

@btgoodwin
Copy link

In mathOptimizations.c, the ifdef __SSE2__ is within the if statement but its corresponding #endif is outside the closing brace of that if statement. If __SSE2__ is not defined, this will result in the following error:

| mathOptimizations.c: In function 'mul_const':
| mathOptimizations.c:2421:1: error: expected declaration or statement at end of input
|  }
|  ^
@btgoodwin
Copy link
Author

btgoodwin commented Jul 11, 2019

Judging by the surrounding logic, this method may actually have a performance bug as well. There is a loop after the endif that seems to re-multiply and re-store the samples. It's likely the code should be:

  void mul_const(float* c, const float *a, const float b, int n){
#ifdef HAVE_IPP
    //(void)ippsRealToCplx_32f((const Ipp32f*) r,(const Ipp32f*) c, (Ipp32fc*)rc, elements);
#else
    int k=0;
    __m128 b1 = _mm_load1_ps(&b);
#ifdef __SSE2__
    if ( ALIGNED2(c,a) && stack_simd_aligned() ) {
        for( ; k+3<n;k+=4){
            __m128 a1 = _mm_load_ps((const float*)(a+k));
              a1 = _mm_mul_ps(a1,b1);
            _mm_store_ps((float*)(c+k),a1);
        }
    }
#else
    if (k<(n-1)){
        for(;k+1<n;k+=2){
            c[k] = a[k] * b;
        }
    }
#endif
#endif
}

Note the movement of the #ifdef __SSE2__ to ahead of the alignment check (which would be required for SSE), and the change of the corresponding #endif to #else followed by another #endif to close out the __SSE2__ check.

@RedhawkDeployer
Copy link
Collaborator

We have confirmed the issue and have put the issue on our backlog for scheduling.

@shmahon shmahon transferred this issue from RedhawkSDR/redhawk Apr 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants