Changeset 54ca3523 in mainline


Ignore:
Timestamp:
2005-05-20T17:04:55Z (20 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0cb0a72
Parents:
c01bd280
Message:

FPU work.
FPU code cleanup, add/fix copyright notices where needed.
Fix PI calculation to use double n instead of int n.
Make FPU test #1 even more stressing.

Re-enable O3 again.
Revert Makefile.config not to compile in any tests.

Files:
11 edited

Legend:

Unmodified
Added
Removed
  • arch/ia32/Makefile.inc

    rc01bd280 r54ca3523  
    1414
    1515CPPFLAGS=$(DEFS) -nostdinc -I../include
    16 CFLAGS=$(CPPFLAGS) -nostdlib -fno-builtin -fomit-frame-pointer -Wmissing-prototypes -Werror -O0
     16CFLAGS=$(CPPFLAGS) -nostdlib -fno-builtin -fomit-frame-pointer -Wmissing-prototypes -Werror -O3
    1717LFLAGS=-M -no-check-sections -T ../arch/ia32/_link.ld
    1818
  • arch/ia32/include/fpu_context.h

    rc01bd280 r54ca3523  
    11/*
    2  * Copyright (C) 2001-2004 Jakub Jermar
     2 * Copyright (C) 2005 Jakub Vana
    33 * All rights reserved.
    44 *
  • arch/ia32/src/fpu_context.c

    rc01bd280 r54ca3523  
    11/*
    2 #
    3 # Copyright (C) 2005 Jakub Vana
    4 # All rights reserved.
    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 #
    10 # - Redistributions of source code must retain the above copyright
    11 #   notice, this list of conditions and the following disclaimer.
    12 # - Redistributions in binary form must reproduce the above copyright
    13 #   notice, this list of conditions and the following disclaimer in the
    14 #   documentation and/or other materials provided with the distribution.
    15 # - The name of the author may not be used to endorse or promote products
    16 #   derived from this software without specific prior written permission.
    17 #
    18 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
    19 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    20 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    21 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
    22 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
    23 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    27 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    28 #
    29 */
     2 *
     3 * Copyright (C) 2005 Jakub Vana
     4 * All rights reserved.
     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 *
     10 * - Redistributions of source code must retain the above copyright
     11 *   notice, this list of conditions and the following disclaimer.
     12 * - Redistributions in binary form must reproduce the above copyright
     13 *   notice, this list of conditions and the following disclaimer in the
     14 *   documentation and/or other materials provided with the distribution.
     15 * - The name of the author may not be used to endorse or promote products
     16 *   derived from this software without specific prior written permission.
     17 *
     18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28 *
     29 */
    3030
    3131#include <fpu_context.h>
    3232#include <arch.h>
    3333#include <cpu.h>
    34 
    3534
    3635void fpu_context_save(fpu_context_t *fctx)
     
    8079void fpu_init(void)
    8180{
    82     asm(
    83         "fninit;"
    84     );
     81        asm(
     82                "fninit;"
     83        );
    8584}
    86 
  • arch/ia32/src/interrupt.c

    rc01bd280 r54ca3523  
    9797void nm_fault(__u8 n, __u32 stack[])
    9898{
    99 
    100 //      printf("-1\n");       
    10199        reset_TS_flag();
    102100        if ((CPU->fpu_owner)!=NULL)
    103101        { 
    104 //              printf("tid:%d \n", THREAD->tid);
    105 //              printf("owner:%d\n", (CPU->fpu_owner)->tid);
    106102                fpu_lazy_context_save(&((CPU->fpu_owner)->saved_fpu_context));
    107 
    108 //              printf("owner 2\n");
    109                 (CPU->fpu_owner)->fpu_context_engaged=0; /* Enables migration */
    110 //              printf("owner 3\n");       
    111 
     103                (CPU->fpu_owner)->fpu_context_engaged=0; /* don't prevent migration */
    112104        }
    113 //      printf("0\n");
    114105        if(THREAD->fpu_context_exists) fpu_lazy_context_restore(&(THREAD->saved_fpu_context));
    115106        else {fpu_init();THREAD->fpu_context_exists=1;}
    116 //      printf("1\n");
    117107        CPU->fpu_owner=THREAD;
    118 //      printf("2\n");
    119        
    120 //      printf("3\n"); 
    121 //      panic("#NM fault\n");
    122108}
    123109
  • arch/ia64/include/fpu_context.h

    rc01bd280 r54ca3523  
    11/*
    2  * Copyright (C) 2005 Jakub Jermar
     2 * Copyright (C) 2005 Jakub Vana
    33 * All rights reserved.
    44 *
  • arch/ia64/src/fpu_context.c

    rc01bd280 r54ca3523  
    11/*
    2 #
    3 # Copyright (C) 2005 Jakub Vana
    4 # All rights reserved.
    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 #
    10 # - Redistributions of source code must retain the above copyright
    11 #   notice, this list of conditions and the following disclaimer.
    12 # - Redistributions in binary form must reproduce the above copyright
    13 #   notice, this list of conditions and the following disclaimer in the
    14 #   documentation and/or other materials provided with the distribution.
    15 # - The name of the author may not be used to endorse or promote products
    16 #   derived from this software without specific prior written permission.
    17 #
    18 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
    19 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    20 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    21 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
    22 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
    23 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    27 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    28 #
    29 */
     2 *
     3 * Copyright (C) 2005 Jakub Vana
     4 * All rights reserved.
     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 *
     10 * - Redistributions of source code must retain the above copyright
     11 *   notice, this list of conditions and the following disclaimer.
     12 * - Redistributions in binary form must reproduce the above copyright
     13 *   notice, this list of conditions and the following disclaimer in the
     14 *   documentation and/or other materials provided with the distribution.
     15 * - The name of the author may not be used to endorse or promote products
     16 *   derived from this software without specific prior written permission.
     17 *
     18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28 *
     29 */
    3030
    3131#include <fpu_context.h>
  • arch/mips/include/fpu_context.h

    rc01bd280 r54ca3523  
    11/*
    2  * Copyright (C) 2001-2004 Jakub Jermar
     2 * Copyright (C) 2005 Jakub Vana
    33 * All rights reserved.
    44 *
  • arch/mips/src/fpu_context.c

    rc01bd280 r54ca3523  
    11/*
    2 #
    3 # Copyright (C) 2005 Jakub Vana
    4 # All rights reserved.
    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 #
    10 # - Redistributions of source code must retain the above copyright
    11 #   notice, this list of conditions and the following disclaimer.
    12 # - Redistributions in binary form must reproduce the above copyright
    13 #   notice, this list of conditions and the following disclaimer in the
    14 #   documentation and/or other materials provided with the distribution.
    15 # - The name of the author may not be used to endorse or promote products
    16 #   derived from this software without specific prior written permission.
    17 #
    18 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
    19 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    20 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    21 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
    22 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
    23 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    27 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    28 #
    29 */
     2 *
     3 * Copyright (C) 2005 Jakub Vana
     4 * All rights reserved.
     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 *
     10 * - Redistributions of source code must retain the above copyright
     11 *   notice, this list of conditions and the following disclaimer.
     12 * - Redistributions in binary form must reproduce the above copyright
     13 *   notice, this list of conditions and the following disclaimer in the
     14 *   documentation and/or other materials provided with the distribution.
     15 * - The name of the author may not be used to endorse or promote products
     16 *   derived from this software without specific prior written permission.
     17 *
     18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28 *
     29 */
    3030
    3131#include <fpu_context.h>
  • include/fpu_context.h

    rc01bd280 r54ca3523  
     1/*
     2 * Copyright (C) 2005 Jakubi Vana
     3 * All rights reserved.
     4 *
     5 * Redistribution and use in source and binary forms, with or without
     6 * modification, are permitted provided that the following conditions
     7 * are met:
     8 *
     9 * - Redistributions of source code must retain the above copyright
     10 *   notice, this list of conditions and the following disclaimer.
     11 * - 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 * - The name of the author may not be used to endorse or promote products
     15 *   derived from this software without specific prior written permission.
     16 *
     17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 */
    128
    229#ifndef fpu_context_h
     
    1542
    1643#endif /*fpu_context_h*/
     44
  • src/Makefile.config

    rc01bd280 r54ca3523  
    66
    77# Support for symetric multiprocessors
    8 SMP=__SMP__
     8#SMP=__SMP__
    99
    1010# Improved support for hyperthreading
     
    1818
    1919# Uncomment if you want to run in the test mode
    20 TEST=__TEST__
     20#TEST=__TEST__
    2121
    2222TEST_FILE=test.c
  • test/fpu/fpu1/test.c

    rc01bd280 r54ca3523  
    4444
    4545#define THREADS         150*2
     46#define ATTEMPTS        10
    4647
    4748#define E_10e8  271828182
     
    5556static void e(void *data)
    5657{
     58        int i;
    5759        double e,d,le,f;
    58         le=-1;
    59         e=0;
    60         f=1;
    6160
    6261        waitq_sleep(&can_start);
    6362
    64         for(d=1;e!=le;d*=f,f+=1) {
    65                 le=e;
    66                 e=e+1/d;
     63        for (i = 0; i<ATTEMPTS; i++) {
     64                le=-1;
     65                e=0;
     66                f=1;
     67
     68                for(d=1;e!=le;d*=f,f+=1) {
     69                        le=e;
     70                        e=e+1/d;
     71                }
     72
     73                if((int)(100000000*e)!=E_10e8)
     74                        panic("tid%d: e*10e8=%d\n", THREAD->tid, (int) 100000000*e);
    6775        }
    6876
    69         if((int)(100000000*e)==E_10e8) {
    70                 atomic_inc((int *) &threads_ok);
    71         }
    72         else
    73                 printf("tid%d: e*10e8=%d)\n", THREAD->tid, (int) 100000000*e);
     77        atomic_inc((int *) &threads_ok);
    7478}
    7579
    7680static void pi(void *data)
    7781{
    78         double lpi = -1, pi = 0;
    79         double ab, ad;
    80         int n;
     82        int i;
     83        double lpi, pi;
     84        double n, ab, ad;
    8185
    8286        waitq_sleep(&can_start);
    8387
    84         for (n=2, ab = sqrt(2); lpi != pi; n *= 2, ab = ad) {
    85                 double sc, cd;
    8688
    87                 sc = sqrt(1 - (ab*ab/4));
    88                 cd = 1 - sc;
    89                 ad = sqrt(ab*ab/4 + cd*cd);
    90                 lpi = pi;
    91                 pi = 2 * n * ad;
    92         }
     89        for (i = 0; i<ATTEMPTS; i++) {
     90                lpi = -1;
     91                pi = 0;
    9392
    94         if((int)(100000000*pi)==PI_10e8) {
    95                 atomic_inc((int *) &threads_ok);
     93                for (n=2, ab = sqrt(2); lpi != pi; n *= 2, ab = ad) {
     94                        double sc, cd;
     95
     96                        sc = sqrt(1 - (ab*ab/4));
     97                        cd = 1 - sc;
     98                        ad = sqrt(ab*ab/4 + cd*cd);
     99                        lpi = pi;
     100                        pi = 2 * n * ad;
     101                }
     102
     103                if((int)(100000000*pi)!=PI_10e8)
     104                        panic("tid%d: pi*10e8=%d\n", THREAD->tid, (int) 100000000*pi);
    96105        }
    97         else
    98                 printf("tid%d: pi*10e8=%d)\n", THREAD->tid, (int) 100000000*pi);
     106
     107        atomic_inc((int *) &threads_ok);
    99108}
    100109
Note: See TracChangeset for help on using the changeset viewer.