Changeset 41


Ignore:
Timestamp:
Aug 24, 2009, 1:11:00 PM (15 years ago)
Author:
buchmann
Message:

Add:

  • openmp support:
    • add flags to test_regression makefile
    • configure.ac now checks for openmp
    • Makefile.am add openmp flags
    • a new testbench to check benefits due to openmp
Location:
sources
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • sources/INSTALL

    r27 r41  
    22*************************
    33
    4 Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free
    5 Software Foundation, Inc.
     4Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
     52006, 2007 Free Software Foundation, Inc.
    66
    77This file is free documentation; the Free Software Foundation gives
     
    1111==================
    1212
    13 These are generic installation instructions.
     13Briefly, the shell commands `./configure; make; make install' should
     14configure, build, and install this package.  The following
     15more-detailed instructions are generic; see the `README' file for
     16instructions specific to this package.
    1417
    1518   The `configure' shell script attempts to guess correct values for
     
    2427   It can also use an optional file (typically called `config.cache'
    2528and enabled with `--cache-file=config.cache' or simply `-C') that saves
    26 the results of its tests to speed up reconfiguring.  (Caching is
     29the results of its tests to speed up reconfiguring.  Caching is
    2730disabled by default to prevent problems with accidental use of stale
    28 cache files.)
     31cache files.
    2932
    3033   If you need to do unusual things to compile the package, please try
     
    3639
    3740   The file `configure.ac' (or `configure.in') is used to create
    38 `configure' by a program called `autoconf'.  You only need
    39 `configure.ac' if you want to change it or regenerate `configure' using
    40 a newer version of `autoconf'.
     41`configure' by a program called `autoconf'.  You need `configure.ac' if
     42you want to change it or regenerate `configure' using a newer version
     43of `autoconf'.
    4144
    4245The simplest way to compile this package is:
    4346
    4447  1. `cd' to the directory containing the package's source code and type
    45      `./configure' to configure the package for your system.  If you're
    46      using `csh' on an old version of System V, you might need to type
    47      `sh ./configure' instead to prevent `csh' from trying to execute
    48      `configure' itself.
    49 
    50      Running `configure' takes awhile.  While running, it prints some
    51      messages telling which features it is checking for.
     48     `./configure' to configure the package for your system.
     49
     50     Running `configure' might take a while.  While running, it prints
     51     some messages telling which features it is checking for.
    5252
    5353  2. Type `make' to compile the package.
     
    6868     with the distribution.
    6969
     70  6. Often, you can also type `make uninstall' to remove the installed
     71     files again.
     72
    7073Compilers and Options
    7174=====================
     
    7982is an example:
    8083
    81      ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
     84     ./configure CC=c99 CFLAGS=-g LIBS=-lposix
    8285
    8386   *Note Defining Variables::, for more details.
     
    8891You can compile the package for more than one kind of computer at the
    8992same time, by placing the object files for each architecture in their
    90 own directory.  To do this, you must use a version of `make' that
    91 supports the `VPATH' variable, such as GNU `make'.  `cd' to the
     93own directory.  To do this, you can use GNU `make'.  `cd' to the
    9294directory where you want the object files and executables to go and run
    9395the `configure' script.  `configure' automatically checks for the
    9496source code in the directory that `configure' is in and in `..'.
    9597
    96    If you have to use a `make' that does not support the `VPATH'
    97 variable, you have to compile the package for one architecture at a
    98 time in the source code directory.  After you have installed the
    99 package for one architecture, use `make distclean' before reconfiguring
    100 for another architecture.
     98   With a non-GNU `make', it is safer to compile the package for one
     99architecture at a time in the source code directory.  After you have
     100installed the package for one architecture, use `make distclean' before
     101reconfiguring for another architecture.
    101102
    102103Installation Names
     
    191192
    192193causes the specified `gcc' to be used as the C compiler (unless it is
    193 overridden in the site shell script).  Here is a another example:
    194 
    195      /bin/bash ./configure CONFIG_SHELL=/bin/bash
    196 
    197 Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent
    198 configuration-related scripts to be executed by `/bin/bash'.
     194overridden in the site shell script).
     195
     196Unfortunately, this technique does not work for `CONFIG_SHELL' due to
     197an Autoconf bug.  Until the bug is fixed you can use this workaround:
     198
     199     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
    199200
    200201`configure' Invocation
  • sources/configure.ac

    r39 r41  
    22# Process this file with autoconf to produce a configure script.
    33
    4 AC_PREREQ(2.60)
    5 AC_INIT(SystemCASS, 1.0.0)
     4AC_PREREQ(2.63)
     5AC_INIT([SystemCASS],[1.0.0])
    66AC_CANONICAL_TARGET
    77
     
    1818AC_PROG_MAKE_SET
    1919AC_PROG_LIBTOOL
     20
     21AC_CHECK_PROG(has_latex, latex, yes)
     22AC_CHECK_PROG(has_bibtex, bibtex, yes)
     23AC_CHECK_PROG(has_fig2dev, fig2dev, yes)
     24AC_CHECK_PROG(has_ps2pdf, ps2pdf, yes)
     25AC_CHECK_PROG(has_dvips, dvips, yes)
     26
    2027
    2128# User choices
     
    3946# Also set -DNDEBUG when not debugging, this disables assert()s
    4047AS_IF([test "x$do_debug"  = "xyes"], [CXXFLAGS="-g"         ],
    41       [test "x$do_debug" != "xyes"], [CXXFLAGS="-O2 -NDEBUG"])
     48      [test "x$do_debug" != "xyes"], [CXXFLAGS="-O2 -DNDEBUG"])
    4249
    4350case $target_os in
     
    6370# Checks for libraries.
    6471AS_IF([test "x$with_pat" != "xno"],
    65           saved_CFLAGS="$CFLAGS"
    66           saved_LIBS="$LIBS"
    67           LIBS="$LIBS -L$with_pat/lib"
    68           CFLAGS="$CFLAGS -I$with_pat/include"
     72          ALLIANCE_CFLAGS="-I$with_pat/include"
    6973          [AC_CHECK_HEADER([pat.h],,
    7074                   [AC_MSG_ERROR([You asked for PAT trace format but no pat.h dnl
     
    7579can be found. Try --with-pat=/search/dir/]),
    7680                   [-lMut -lPpt -lPgn])]
    77           ALLIANCE_CFLAGS="$CFLAGS"
    78           CFLAGS="$saved_CFLAGS"
    79           LIBS="$saved_LIBS"
    8081          AC_SUBST(ALLIANCE_PATH, $withval)
    8182          AC_SUBST(ALLIANCE_CFLAGS)
     
    9192AM_CONDITIONAL(HAS_SOCLIB, test x$with_soclib != xno)
    9293
    93 AC_CHECK_PROG(has_latex, latex, yes)
    94 AC_CHECK_PROG(has_bibtex, bibtex, yes)
    95 AC_CHECK_PROG(has_fig2dev, fig2dev, yes)
    96 AC_CHECK_PROG(has_ps2pdf, ps2pdf, yes)
    97 AC_CHECK_PROG(has_dvips, dvips, yes)
     94# OpenMP
     95AC_OPENMP([C])
    9896
    9997AM_CONDITIONAL(BUILD_DOCS,
  • sources/src/Makefile.am

    r34 r41  
    3838
    3939libsystemc_la_LIBADD = libgen_code.la $(ALLIANCE_LIBS)
    40 libsystemc_la_CXXFLAGS = @ALLIANCE_CFLAGS@ $(CXXFLAGS)
     40libsystemc_la_CXXFLAGS = @ALLIANCE_CFLAGS@ @OPENMP_CFLAGS@ $(CXXFLAGS)
    4141
    4242noinst_LTLIBRARIES =  libgen_code.la
    4343libgen_code_la_SOURCES = gen_code.cc
    44 libgen_code_la_CXXFLAGS=-DGENERATED_MODULE_CFLAGS='"$(CXXFLAGS) -I$(prefix)/include"'
     44libgen_code_la_CXXFLAGS=-DGENERATED_MODULE_CFLAGS='"$(CXXFLAGS) -I$(prefix)/include"' @OPENMP_CFLAGS@
    4545
    4646include_HEADERS = alias.h casc.h data_field.h fsm_rules.h global_functions.h internal_ext.h module_hierarchy_ext.h port_dependency_ext.h sc_bigint.h sc_biguint.h sc_bit.h sc_bv.h sc_clock_ext.h sc_event.h sc_fwd.h sc_int.h sc_interface.h sc_localvar.h sc_logic.h sc_lv.h sc_module_ext.h sc_module_name.h sc_nbdefs.h sc_numrep.h sc_object.h sc_pat_trace.h sc_port_ext.h sc_sensitive.h sc_signal.h sc_signed.h sc_string.h sc_time.h sc_trace_ext.h sc_uint.h sc_unit.h sc_unsigned.h sc_vcd_trace.h sc_ver_ext.h serialization_ext.h systemc systemc.h systemcass_version_ext.h
  • sources/src/gen_code.cc

    r38 r41  
    5454#endif
    5555
     56#ifdef _OPENMP
     57#include <omp.h>
     58#endif
     59
    5660#ifdef CONFIG_CHECK_FSM_RULES
    5761#include "fsm_rules.h"
     
    107111                   const method_process_t &m)
    108112{
    109   SC_ENTRY_FUNC func    = m.func;
     113  SC_ENTRY_FUNC func  = m.func;
    110114  if (print_schedule)
    111115    o << "    fprintf(stderr,\"evaluation de "
    112                 << m.module->name() << "->" << m.name << "()\\n\");\n";
     116      << m.module->name() << "->" << m.name << "()\\n\");\n";
    113117  o << " p.integer = " << func << ";\n";
    114118#ifdef CPP_CALL
    115119  o << " (((sc_module*)(" << m.module << "))->*(p.pmf)) (); /* "
    116                 << m.module->name () << "->" << m.name << "() */\n";
     120    << m.module->name () << "->" << m.name << "() */\n";
    117121#else
    118122  o << " p.pf((void *)"
    119           << m.module << "); /* "
    120                 << m.module->name () << "->" << m.name << "() */\n";
     123    << m.module << "); /* "
     124    << m.module->name () << "->" << m.name << "() */\n";
    121125#endif
    122126}
     
    145149void
    146150open_temp          (ofstream &o,
    147                                 char     *temp)
     151                    char     *temp)
    148152{
    149153/*
    150         srand (time (NULL));
    151                 int r = rand () % 1000;
     154  srand (time (NULL));
     155    int r = rand () % 1000;
    152156*/
    153157  pid_t pid = getpid();
    154158  int r = -1;
    155         do {
    156                 sprintf (temp, "%s/scheduling-%d-%x.cc", temporary_dir, pid, ++r);
     159  do {
     160    sprintf (temp, "%s/scheduling-%d-%x.cc", temporary_dir, pid, ++r);
    157161  } while (is_exist (temp));
    158162
    159163  o.open (temp,ios::out);
    160         if (o.is_open () == false)
     164  if (o.is_open () == false)
    161165  {
    162                 cerr << "Error : Unable to open a file to write scheduling code.\n";
     166    cerr << "Error : Unable to open a file to write scheduling code.\n";
    163167    exit (30032005);
    164168  }
     
    176180                method_process_list_t &transition_func_list)
    177181{
    178         // transitions
     182  // transitions
    179183  o << "\ninline void transition(void)\n{\n";
    180184  if (transition_func_list.empty () == false) {
    181185    o << " /* fonctions de transition */\n"
    182                         << " register fct p;\n";
    183         method_process_list_t::iterator mm;
     186      << " register fct p;\n";
     187    method_process_list_t::iterator mm;
    184188    for( mm = transition_func_list.begin(); mm != transition_func_list.end(); ++mm)
    185189    {
    186190      PrintCall (o, **mm);
    187191    }
    188         }
     192  }
    189193  o << "}\n";
    190194}
     
    195199           method_process_list_t &moore_func_list)
    196200{
    197         // Moore generations (sequential functions)
     201  // Moore generations (sequential functions)
    198202  o << "\ninline void moore_generation (void)\n{\n";
    199         if (moore_func_list.empty () == false) {
    200                 o << "  /* fonctions de generation de Moore */\n"
    201                   << " register fct p;\n";
    202         method_process_list_t::reverse_iterator mm;
     203  if (moore_func_list.empty () == false) {
     204    o << "  /* fonctions de generation de Moore */\n"
     205      << " register fct p;\n";
     206    method_process_list_t::reverse_iterator mm;
    203207    for( mm = moore_func_list.rbegin(); mm != moore_func_list.rend(); ++mm)
    204208    {
     
    214218           strong_component_list_t &strongcomponents)
    215219{
    216         // Mealy generations (combinational functions only)
     220  // Mealy generations (combinational functions only)
    217221  o << "\nextern void mealy_generation (void)\n{\n";
    218         if (strongcomponents.empty ())
     222  if (strongcomponents.empty ())
    219223    return NULL;
    220         o << "  register fct p;\n"
    221           << "\n\n  /* fonctions de mealy */\n";
     224   o << "  register fct p;\n"
     225    << "\n\n  /* fonctions de mealy */\n";
    222226#ifdef NO_STATIC_SCHEDULE
    223227  o << "\n  do {\n    unstable = 0;\n";
     
    227231    if ( (*ss)->size() == 1) {
    228232      /* un seul element dans le strong component */
    229                         method_process_t *m = (method_process_t*)(*((*ss)->begin ()));
     233      method_process_t *m = (method_process_t*)(*((*ss)->begin ()));
    230234      PrintCall (o, *m);
    231235      continue;
     
    237241      component_list_t::reverse_iterator rev_mm;
    238242      for( rev_mm = (*ss)->rbegin(); rev_mm != (*ss)->rend(); ++rev_mm) {
    239                                 method_process_t *m = (method_process_t*) *rev_mm;
     243        method_process_t *m = (method_process_t*) *rev_mm;
    240244        PrintCall (o, *m);
    241245      }
     
    257261           ProcessDependencyList   &mealy_func_list)
    258262{
    259         // Mealy generations (combinational functions only)
     263  // Mealy generations (combinational functions only)
    260264  o << "\nextern void mealy_generation (void)\n{\n";
    261265  o << "  register fct p;\n"
     
    301305    << pmf_type
    302306    << " integer; SC_ENTRY_FUNC pmf; CASC_ENTRY_FUNC pf; } fct;\n";
    303        
    304   gen_transition (o, transition_func_list);     
    305   gen_moore      (o, moore_func_list); 
     307 
     308  gen_transition (o, transition_func_list); 
     309  gen_moore      (o, moore_func_list); 
    306310  gen_mealy      (o, strongcomponents);
    307311
     
    310314 
    311315  o.flush ();
    312         o.close ();
    313 
    314         // add "cc" extension
     316  o.close ();
     317
     318  // add "cc" extension
    315319  char file_name[PATH_MAX];
    316320  strncpy(file_name, base_name, PATH_MAX);
     
    337341    cerr << "Generating C code for scheduling...\n";
    338342
    339         // open temporary file
    340         ofstream o;
     343  // open temporary file
     344  ofstream o;
    341345  char base_name[PATH_MAX];
    342         open_temp (o, base_name);
     346  open_temp (o, base_name);
    343347 
    344         if (! o.good ()) {
     348  if (! o.good ()) {
    345349    perror("scheduling: open file\n");
    346350    exit(-1);
     
    348352
    349353  o << "// generated by " << sc_version () << endl
    350                 << "#include <casc.h>\n\n"
    351                 << "#include <cstdio>\n\n"
    352 //              << "#include <iostream>\n\n"
    353                 << "namespace sc_core {\n"
     354    << "#include <casc.h>\n\n"
     355    << "#include <cstdio>\n\n"
     356//    << "#include <iostream>\n\n"
     357    << "namespace sc_core {\n"
    354358    << " typedef void (sc_module::*SC_ENTRY_FUNC)();\n"
    355                 << " typedef void (*CASC_ENTRY_FUNC)(void *);\n"
     359    << " typedef void (*CASC_ENTRY_FUNC)(void *);\n"
    356360    << " typedef union { unsigned long long int integer; SC_ENTRY_FUNC pmf; CASC_ENTRY_FUNC pf; } fct;\n";
    357        
    358   gen_transition (o, transition_func_list);     
    359   gen_moore      (o, moore_func_list); 
     361 
     362  gen_transition (o, transition_func_list); 
     363  gen_moore      (o, moore_func_list); 
    360364  gen_mealy      (o, mealy_func_list);
    361365
     
    364368 
    365369  o.flush ();
    366         o.close ();
    367  
    368         // add "cc" extension
     370  o.close ();
     371 
     372  // add "cc" extension
    369373  char file_name[PATH_MAX];
    370374  strncpy(file_name, base_name, PATH_MAX);
     
    395399  const char *systemc_dir = getenv ("SYSTEMCASS");
    396400//  const char *target_arch = getenv ("TARGET_ARCH");
    397         const char *default_compiler =
     401  const char *default_compiler =
    398402#ifdef CPP_CALL
    399                 "g++";
     403    "g++";
    400404#else
    401                 "gcc";
     405    "gcc";
    402406#endif
    403407
    404408  compiler = (compiler == NULL)?default_compiler:compiler;
    405         if (systemc_dir == NULL) {
     409  if (systemc_dir == NULL) {
    406410    systemc_dir = getenv ("SYSTEMC");
    407411    if (systemc_dir == NULL) {
    408                 cerr << "Error : set SYSTEMCASS or SYSTEMC environnement variable "
     412      cerr << "Error : set SYSTEMCASS or SYSTEMC environnement variable "
    409413              "to the SYSTEMCASS directory.\n";
    410                 exit (-1);
     414      exit (-1);
    411415    }
    412         }
     416  }
    413417  //target_arch = (target_arch == NULL)?"":target_arch;
    414418 
     
    439443  const char *commandline_template =
    440444#if defined(CONFIG_OS_DARWIN)
    441           "(cd %s ;"                     " %s %s -DSCHEDULING_BY_CASC -I%s/include -fno-common -dynamic -o %s -c %s)"
     445    "(cd %s ;"                     " %s %s -DSCHEDULING_BY_CASC -I%s/include -fno-common -dynamic -o %s -c %s)"
    442446#elif defined(CONFIG_OS_LINUX)
    443           "(cd %s ; libtool --mode=compile %s %s -DSCHEDULING_BY_CASC -I%s/include -shared -o %s -c %s)"
     447    "(cd %s ; libtool --mode=compile %s %s -DSCHEDULING_BY_CASC -I%s/include -shared -o %s -c %s)"
    444448#else
    445           "(cd %s ;"                     " %s %s -DSCHEDULING_BY_CASC -I%s/include -dynamiclib -o %s -c %s)"
    446 #endif
    447           ;
     449    "(cd %s ;"                     " %s %s -DSCHEDULING_BY_CASC -I%s/include -dynamiclib -o %s -c %s)"
     450#endif
     451    ;
    448452
    449453  string cflags = casc_cflags;
     
    452456
    453457  sprintf(compil_str,
    454                   commandline_template,
    455                   temporary_dir,
    456                   compiler,
    457                   cflags.c_str(),
    458                   systemc_dir,
    459                   target_name,
    460                   source_name);
     458      commandline_template,
     459      temporary_dir,
     460      compiler,
     461      cflags.c_str(),
     462      systemc_dir,
     463      target_name,
     464      source_name);
    461465
    462466  if (dump_stage)
     
    476480  sprintf (source_name, "%s.lo", base_name);
    477481  sprintf(compil_str, "(cd %s ; pwd ; libtool --mode=link %s %s -module -shared -o %s %s -rpath /tmp)", /* -L. -L%s/lib-%s */
    478            temporary_dir, compiler, casc_cflags, /*systemc_dir, target_arch,*/
     482     temporary_dir, compiler, casc_cflags, /*systemc_dir, target_arch,*/
    479483     target_name, source_name);
    480484#else
    481485  sprintf (source_name, "%s.o", base_name);
    482486  sprintf(compil_str, "(cd %s ; pwd ; libtool -dynamic -o %s %s)",
    483            temporary_dir, target_name, source_name);
     487     temporary_dir, target_name, source_name);
    484488#endif
    485489
     
    538542  pf.function = (fct*)   malloc (sizeof (fct)   * pf.func_number);
    539543  pf.instance = (void**) malloc (sizeof (void*) * pf.func_number);
    540         ProcessDependencyList::iterator it;
     544  ProcessDependencyList::iterator it;
    541545  int i;
    542         for (i = 0, it = func_list.begin(); it != func_list.end(); ++it, ++i)
    543         {
    544                 const method_process_t *mp = *it;
     546  for (i = 0, it = func_list.begin(); it != func_list.end(); ++it, ++i)
     547  {
     548    const method_process_t *mp = *it;
    545549    pf.function[i].pmf = (mp->func);
    546550    pf.instance[i] = (void*)(mp->module);
     
    580584}
    581585
     586void
     587call_functions_in_parallel (function_call &fc)
     588{
     589  int n = fc.func_number;
     590  int i;
     591  #pragma omp parallel for
     592  for (i = 0; i < n; ++i)
     593  {
     594#if 0 //defined(CONFIG_DEBUG)
     595    sc_module *m = (sc_module*)(fc.instance[i]);
     596    cerr << m->name () << endl;
     597    cerr << "thread #" << omp_get_thread_num () << endl;
     598#endif
     599    fc.function[i].pf (fc.instance[i]);
     600  }
     601}
     602
    582603void static_mealy_generation ()
    583604{
     
    595616  casc_fsm_step = GEN_MOORE;
    596617#endif
    597   call_functions (pf[1]); // moore generation
     618  call_functions_in_parallel (pf[1]); // moore generation
    598619#ifdef CONFIG_CHECK_FSM_RULES
    599620  casc_fsm_step = GEN_MEALY;
     
    621642  (mod->*func) ();
    622643}
     644
    623645void quasistatic_mealy_generation ()
    624646{
     
    627649    if ( (*ss)->size() == 1) {
    628650      /* un seul element dans le strong component */
    629                         method_process_t *m = (method_process_t*)(*((*ss)->begin ()));
     651      method_process_t *m = (method_process_t*)(*((*ss)->begin ()));
    630652      Call (*m);
    631653      continue;
     
    636658        component_list_t::reverse_iterator rev_mm;
    637659        for( rev_mm = (*ss)->rbegin(); rev_mm != (*ss)->rend(); ++rev_mm) {
    638                                 method_process_t *m = (method_process_t*) *rev_mm;
     660          method_process_t *m = (method_process_t*) *rev_mm;
    639661          Call (*m);
    640662        }
  • sources/test_regression/env.mk

    r27 r41  
    3333CFLAGS      = $(PROF) $(DEBUG) $(OPT) \
    3434              -Wall \
     35              -fopenmp \
    3536              -UENABLE_TRACE -UENABLE_PAT -I. \
    3637              ${ENDIANESS_FLAG}
    3738
    38 LFLAGS      = $(PROF) $(BFD_LIBERTY) -ldl
     39LFLAGS      = $(PROF) $(BFD_LIBERTY) -ldl -fopenmp
    3940
    4041CFLAGS_SYSTEMC    = $(CFLAGS) \
Note: See TracChangeset for help on using the changeset viewer.