~ubuntu-branches/ubuntu/vivid/atlas/vivid

« back to all changes in this revision

Viewing changes to CONFIG/probe_3DNow1.c

  • Committer: Bazaar Package Importer
  • Author(s): Sylvestre Ledru
  • Date: 2009-09-17 23:31:54 UTC
  • mto: (2.2.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: james.westby@ubuntu.com-20090917233154-9esw88ub02twbuab
Tags: upstream-3.8.3
ImportĀ upstreamĀ versionĀ 3.8.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
/*
3
 
 *             Automatically Tuned Linear Algebra Software v3.6.0
4
 
 *                   (C) Copyright 2000 Peter Soendergaard
5
 
 *
6
 
 * Redistribution and use in source and binary forms, with or without
7
 
 * modification, are permitted provided that the following conditions
8
 
 * are met:
9
 
 *   1. Redistributions of source code must retain the above copyright
10
 
 *      notice, this list of conditions and the following disclaimer.
11
 
 *   2. Redistributions in binary form must reproduce the above copyright
12
 
 *      notice, this list of conditions, and the following disclaimer in the
13
 
 *      documentation and/or other materials provided with the distribution.
14
 
 *   3. The name of the ATLAS group or the names of its contributers may
15
 
 *      not be used to endorse or promote products derived from this
16
 
 *      software without specific written permission.
17
 
 *
18
 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
 
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20
 
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21
 
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ATLAS GROUP OR ITS CONTRIBUTORS
22
 
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23
 
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
 
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
 
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
 
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
 
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
 
 * POSSIBILITY OF SUCH DAMAGE.
29
 
 *
30
 
 */
31
 
#include <stdio.h>
32
 
 
33
 
#define VECLEN 2
34
 
 
35
 
#define gen_vec_rr(op,reg1,reg2) \
36
 
        __asm__ __volatile__ (#op " %%" #reg1 ", %%" #reg2 \
37
 
                              :  /* nothing */ \
38
 
                              : /* nothing */)
39
 
 
40
 
 
41
 
#define gen_vec_mr(op,mem,reg) \
42
 
        __asm__ __volatile__ (#op " %0, %%" #reg \
43
 
                              :  /* nothing */ \
44
 
                              : "m" (((mem)[0])), "m" (((mem)[1])))
45
 
 
46
 
#define gen_vec_rm(op,reg,mem) \
47
 
        __asm__ __volatile__ (#op " %%" #reg ", %0" \
48
 
                              : "=m" (((mem)[0])), "=m" (((mem)[1])) \
49
 
                              :  /* nothing */ )
50
 
 
51
 
 
52
 
#define vec_mov_mr(mem,reg)     gen_vec_mr(movq,mem,reg)
53
 
#define vec_mov_rm(reg,mem)     gen_vec_rm(movq,reg,mem)
54
 
#define vec_add_rr(reg1,reg2)   gen_vec_rr(pfadd,reg1,reg2)
55
 
 
56
 
#define reg0 mm0
57
 
#define reg1 mm1
58
 
 
59
 
main()
60
 
{
61
 
 
62
 
  int i;
63
 
  float testv1[VECLEN],testv2[VECLEN],testv3[VECLEN];
64
 
 
65
 
  for (i=0;i<VECLEN;i++)
66
 
    {
67
 
      testv1[i]=i;
68
 
      testv2[i]=i+2;
69
 
      testv3[i]=0;
70
 
    }
71
 
 
72
 
  __asm__ __volatile__ ("femms");
73
 
 
74
 
  vec_mov_mr(testv1,reg0);
75
 
  vec_mov_mr(testv2,reg1);
76
 
  vec_add_rr(reg1,reg0);
77
 
  vec_mov_rm(reg0,testv3);
78
 
 
79
 
  __asm__ __volatile__ ("femms");
80
 
 
81
 
  for (i=0;i<VECLEN;i++)
82
 
    {
83
 
      if (testv3[i]!=(2*i+2))
84
 
        {
85
 
          printf("FAILURE\n");
86
 
          exit(1);
87
 
        }
88
 
    }
89
 
 
90
 
  printf("SUCCESS\n");
91
 
  exit(0);
92
 
 
93
 
}