From: Matt Birkholz Date: Sat, 25 Jul 2015 21:30:40 +0000 (-0700) Subject: Add configure option --enable-smp and new machine options. X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=7f911cdd6fc31b95c3c15f7ba3283a1f00dd2a71;p=mit-scheme.git Add configure option --enable-smp and new machine options. Machine options: "--processors" and "--processor-heap" with corresponding environment variables "MITSCHEME_PROCESSORS" and "MITSCHEME_PROCESSOR_HEAP_SIZE". --- diff --git a/src/microcode/boot.c b/src/microcode/boot.c index c48f95da7..e76caa920 100644 --- a/src/microcode/boot.c +++ b/src/microcode/boot.c @@ -119,6 +119,9 @@ main_name (int argc, const char ** argv) setup_memory ((BLOCKS_TO_BYTES (option_heap_size)), (BLOCKS_TO_BYTES (option_stack_size)), (BLOCKS_TO_BYTES (option_constant_size))); +#ifdef ENABLE_SMP + setup_processors (option_processor_count); +#endif initialize_primitives (); compiler_initialize (option_fasl_file != 0); diff --git a/src/microcode/configure.ac b/src/microcode/configure.ac index 2a384555a..c79634292 100644 --- a/src/microcode/configure.ac +++ b/src/microcode/configure.ac @@ -130,6 +130,11 @@ AC_ARG_ENABLE([native-code], [Support native compiled code if available [[yes]]])) : ${enable_native_code='yes'} +AC_ARG_ENABLE([smp], + AS_HELP_STRING([--enable-smp], + [Support multi-processing if available [[no]]])) +: ${enable_smp='no'} + AC_ARG_WITH([openssl], AS_HELP_STRING([--with-openssl], [Use OpenSSL crypto library if available [[yes]]])) @@ -1045,6 +1050,19 @@ if test ${enable_valgrind_mode} != no; then M4_FLAGS="${M4_FLAGS} -P VALGRIND_MODE,1" fi +dnl Check for pthreads. +if test "${enable_smp}" != no; then + AC_CHECK_HEADER([pthread.h], + [ + AC_DEFINE([ENABLE_SMP], [1], + [Define to 1 for Symmetric Multiple Processor support.]) + CFLAGS="-pthread ${CFLAGS}" + LDFLAGS="-pthread ${LDFLAGS}" + M4_FLAGS="${M4_FLAGS} -P ENABLE_SMP,1" + ], + AC_MSG_ERROR([SMP support requires ])) +fi + OPTIONAL_BASES="${OPTIONAL_BASES} cmpint cmpintmd comutl" case ${mit_scheme_native_code} in diff --git a/src/microcode/confshared.h b/src/microcode/confshared.h index b44d715f8..c81466bb9 100644 --- a/src/microcode/confshared.h +++ b/src/microcode/confshared.h @@ -693,4 +693,8 @@ extern void win32_stack_reset (void); # define HEAP_FREE(address) #endif +#ifndef ENABLE_SMP +#define __thread +#endif + #endif /* SCM_CONFSHARED_H */ diff --git a/src/microcode/debug.c b/src/microcode/debug.c index 35b4e0bbe..5464bcc66 100644 --- a/src/microcode/debug.c +++ b/src/microcode/debug.c @@ -1014,9 +1014,15 @@ Returns #T if the scan was successful and #F if there were any complaints.") #define D_TRACE_ON_ERROR 12 #define D_PER_FILE 13 #define D_BIGNUM 14 - -#ifndef LAST_SWITCH -#define LAST_SWITCH D_BIGNUM +#ifdef ENABLE_SMP +# define D_SMP 15 +# ifndef LAST_SWITCH +# define LAST_SWITCH D_SMP +# endif +#else +# ifndef LAST_SWITCH +# define LAST_SWITCH D_BIGNUM +# endif #endif static bool * @@ -1039,6 +1045,9 @@ find_flag (int flag_number) case D_TRACE_ON_ERROR: return (&Trace_On_Error); case D_PER_FILE: return (&Per_File); case D_BIGNUM: return (&Bignum_Debug); +#ifdef ENABLE_SMP + case D_SMP: return (&smp_trace_p); +#endif MORE_DEBUG_FLAG_CASES (); default: return (0); } @@ -1064,6 +1073,9 @@ flag_name (int flag_number) case D_TRACE_ON_ERROR: return ("Trace_On_Error"); case D_PER_FILE: return ("Per_File"); case D_BIGNUM: return ("Bignum_Debug"); +#ifdef ENABLE_SMP + case D_SMP: return ("smp_trace_p"); +#endif MORE_DEBUG_FLAG_NAMES (); default: return ("Unknown Debug Flag"); } diff --git a/src/microcode/makegen/files-os-prim.scm b/src/microcode/makegen/files-os-prim.scm index adf2552ea..2611e5bfb 100644 --- a/src/microcode/makegen/files-os-prim.scm +++ b/src/microcode/makegen/files-os-prim.scm @@ -35,3 +35,4 @@ USA. "prosterm" "prostty" "pruxsock" ;Misnamed, should be "prossock". +"prossmp" diff --git a/src/microcode/option.c b/src/microcode/option.c index 9a5639c8b..8bcfbe3f8 100644 --- a/src/microcode/option.c +++ b/src/microcode/option.c @@ -91,6 +91,8 @@ static const char * option_raw_band; static const char * option_raw_heap; static const char * option_raw_constant; static const char * option_raw_stack; +static const char * option_raw_processor_count; +static const char * option_raw_processor_heap; /* Command-line arguments */ int option_saved_argc; @@ -118,6 +120,8 @@ const char * option_fasl_file = 0; unsigned long option_heap_size; unsigned long option_constant_size; unsigned long option_stack_size; +int option_processor_count; +unsigned long option_processor_heap_size; void print_help (void) @@ -254,6 +258,14 @@ Additional options may be supported by the band (and described below).\n\ #ifndef STACK_SIZE_VARIABLE # define STACK_SIZE_VARIABLE "MITSCHEME_STACK_SIZE" #endif + +#ifndef PROCESSORS_VARIABLE +# define PROCESSORS_VARIABLE "MITSCHEME_PROCESSORS" +#endif + +#ifndef PROCESSOR_HEAP_SIZE_VARIABLE +# define PROCESSOR_HEAP_SIZE_VARIABLE "MITSCHEME_PROCESSOR_HEAP_SIZE" +#endif static int string_compare_ci (const char * string1, const char * string2) @@ -502,6 +514,8 @@ parse_standard_options (int argc, const char ** argv) option_argument ("silent", false, (&option_batch_mode)); option_argument ("stack", true, (&option_raw_stack)); option_argument ("version", false, (&option_show_version)); + option_argument ("processors", true, (&option_raw_processor_count)); + option_argument ("processor-heap", true, (&option_raw_processor_heap)); /* These are deprecated: */ option_argument ("compiler", false, 0); @@ -860,6 +874,12 @@ describe_size_option (const char * name, unsigned int value) outf_fatal (" %s size: %d\n", name, value); } +static void +describe_number_option (const char * name, unsigned int value) +{ + outf_fatal (" number of %s: %d\n", name, value); +} + static void describe_path_option (const char * name, const char ** value) { @@ -893,6 +913,8 @@ describe_options (void) describe_boolean_option ("force interactive", option_force_interactive); describe_boolean_option ("disable core dump", option_disable_core_dump); describe_boolean_option ("suppress noise", option_batch_mode); + describe_number_option ("processors", option_processor_count); + describe_size_option ("processor heap", option_processor_heap_size); if (option_unused_argc == 0) outf_fatal (" no unused arguments\n"); else @@ -1004,6 +1026,16 @@ read_command_line_options (int argc, const char ** argv) option_raw_stack, STACK_SIZE_VARIABLE, DEFAULT_STACK_SIZE)); + option_processor_count + = (standard_numeric_option ("processors", + option_raw_processor_count, + PROCESSORS_VARIABLE, + 1)); + option_processor_heap_size + = (standard_numeric_option ("processor-heap", + option_raw_processor_heap, + PROCESSOR_HEAP_SIZE_VARIABLE, + 0)); if (option_show_version) { outf_console ("%s\n", PACKAGE_STRING); diff --git a/src/microcode/option.h b/src/microcode/option.h index 3d126db29..052639a6c 100644 --- a/src/microcode/option.h +++ b/src/microcode/option.h @@ -54,6 +54,8 @@ extern const char * option_fasl_file; extern unsigned long option_heap_size; extern unsigned long option_constant_size; extern unsigned long option_stack_size; +extern int option_processor_count; +extern unsigned long option_processor_heap_size; extern void read_command_line_options (int argc, const char ** argv); diff --git a/src/microcode/ossmp.h b/src/microcode/ossmp.h new file mode 100644 index 000000000..133409535 --- /dev/null +++ b/src/microcode/ossmp.h @@ -0,0 +1,42 @@ +/* -*-C-*- + +Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, + 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Massachusetts + Institute of Technology + +This file is part of MIT/GNU Scheme. + +MIT/GNU Scheme is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at +your option) any later version. + +MIT/GNU Scheme is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with MIT/GNU Scheme; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, +USA. + +*/ + +#ifndef SCM_OSSMP_H +#define SCM_OSSMP_H + +#ifdef ENABLE_SMP + +#include + +extern void setup_processors (int count); + +#ifdef ENABLE_DEBUGGING_TOOLS +extern bool smp_trace_p; +#endif + +#endif /* ENABLE_SMP */ + +#endif /* SCM_OSSMP_H */ diff --git a/src/microcode/prossmp.c b/src/microcode/prossmp.c new file mode 100644 index 000000000..c3293e0bd --- /dev/null +++ b/src/microcode/prossmp.c @@ -0,0 +1,63 @@ +/* -*-C-*- + +Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, + 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Massachusetts + Institute of Technology + +This file is part of MIT/GNU Scheme. + +MIT/GNU Scheme is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at +your option) any later version. + +MIT/GNU Scheme is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with MIT/GNU Scheme; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, +USA. + +*/ + +/* Primitives for "symmetric multi-processing". */ + +#include "prims.h" + +#ifdef ENABLE_SMP + +#include "option.h" + +#ifdef ENABLE_DEBUGGING_TOOLS + +bool smp_trace_p = true; + +static void +trace (const char * format, ...) +{ + va_list args; + va_start (args, format); + if (smp_trace_p == true) + voutf_error_line (format, args); + va_end (args); +} + +#else + +#define trace(...) do {} while (false) + +#endif + +void +setup_processors (int count) +{ + trace ("; processor count: %d", option_processor_count); + trace ("; local heap size: %d", option_processor_heap_size); + trace ("; stack size: %d", option_stack_size); +} + +#endif /* ENABLE_SMP */ diff --git a/src/microcode/scheme.h b/src/microcode/scheme.h index 26720db80..03dcbf1b2 100644 --- a/src/microcode/scheme.h +++ b/src/microcode/scheme.h @@ -37,6 +37,7 @@ USA. #include "const.h" /* Various named constants */ #include "object.h" /* Scheme object representation */ #include "intrpt.h" /* Interrupt processing macros */ +#include "ossmp.h" /* Symmetric Multi-Processing declarations */ #include "critsec.h" /* Critical sections */ #include "gc.h" /* Memory management related macros */ #include "memmag.h"