Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fastest way to find max element in vector




On Nov 21, 2005, at 11:15 AM, Rustam Muginov wrote:

Please excuse me for confusion. I need to find the largest element across the vector register (vFloat), not across arbitrary array of floats.

-

Hi Rustam,

  You could try something like this:

[gohara:~/misc] gohara% cat max.c
#include <stdio.h>
#include <stdlib.h>

int main(){

        vector float mVec = (vector float)(0.,7.,2.3,7.1);
        vector float temp;

        printf("%vf\n",mVec);

        mVec = vec_max(mVec,vec_sld(mVec,mVec,8));
        mVec = vec_max(mVec,vec_sld(mVec,mVec,4));

        printf("%vf\n",mVec);

        return 0;
}

[gohara:~/misc] gohara% gcc max.c -faltivec
[gohara:~/misc] gohara% ./a.out
0.000000 7.000000 2.300000 7.100000
7.100000 7.100000 7.100000 7.100000

It's similar to adding across a vector of floats (see: http:// developer.apple.com/hardware/ve/algorithms.html#across).

Although there may be a faster (better) way. Note that you can modify this to do it non-destructively as well.

  Dave
_______________________________________________
Do not post admin requests to the list. They will be ignored.
PerfOptimization-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/perfoptimization-dev/email@hidden

This email sent to email@hidden
References: 
 >Fastest way to find max element in vector (From: Rustam Muginov <email@hidden>)
 >Re: Fastest way to find max element in vector (From: Rustam Muginov <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.