###############
## SVN version check
##
-if(IS_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.svn)
- find_file(SVN ".svn" ${CMAKE_HOME_DIRECTORY})
- exec_program("svnversion ${CMAKE_HOME_DIRECTORY}" OUTPUT_VARIABLE "SVN_VERSION")
- message(STATUS "svn version ${SVN_VERSION}")
-else(IS_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.svn)
- exec_program("git config --get svn-remote.svn.url"
- OUTPUT_VARIABLE url
- RETURN_VALUE ret)
-endif(IS_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.svn)
+exec_program("git remote" OUTPUT_VARIABLE remote RETURN_VALUE ret)
+exec_program("git config --get remote.${remote}.url" OUTPUT_VARIABLE url RETURN_VALUE ret)
if(url)
exec_program("git --git-dir=${CMAKE_HOME_DIRECTORY}/.git log --oneline -1" OUTPUT_VARIABLE "GIT_VERSION")
+ message(STATUS "Git version: ${GIT_VERSION}")
exec_program("git --git-dir=${CMAKE_HOME_DIRECTORY}/.git log -n 1 --format=%ai ." OUTPUT_VARIABLE "GIT_DATE")
-
+ message(STATUS "Git date: ${GIT_DATE}")
string(REGEX REPLACE " .*" "" GIT_VERSION "${GIT_VERSION}")
STRING(REPLACE " +0000" "" GIT_DATE ${GIT_DATE})
STRING(REPLACE " " "~" GIT_DATE ${GIT_DATE})
STRING(REPLACE ":" "-" GIT_DATE ${GIT_DATE})
-
- exec_program("git svn info" ${CMAKE_HOME_DIRECTORY}
- OUTPUT_VARIABLE "GIT_SVN_VERSION")
- string(REPLACE "\n" ";" GIT_SVN_VERSION ${GIT_SVN_VERSION})
- foreach(line ${GIT_SVN_VERSION})
- string(REGEX MATCH "^Revision:.*" line_good ${line})
- if(line_good)
- string(REPLACE "Revision: " ""
- line_good ${line_good})
- set(SVN_VERSION ${line_good})
- endif(line_good)
- endforeach(line ${GIT_SVN_VERSION})
endif(url)
# If you really need to change stuff, please also bump
# GRAS_PROTOCOL_VERSION in src/gras/Msg/msg_interface.h
+SET(GRAS_THISARCH "none")
if(val_big MATCHES "l_C:1/1:_I:2/1:4/1:4/1:8/1:_P:4/1:4/1:_D:4/1:8/1:")
#gras_arch=0; gras_size=32; gras_arch_name=little32_1;
SET(GRAS_THISARCH 10)
endif(val_big MATCHES "B_C:1/1:_I:2/2:4/4:8/8:8/8:_P:8/8:8/8:_D:4/4:8/4:")
+if(GRAS_THISARCH MATCHES "none")
+ message(STATUS "architecture: ${val_big}")
+ message(FATAL_ERROR "GRAS_THISARCH is empty: '${GRAS_THISARCH}'")
+endif(GRAS_THISARCH MATCHES "none")
# Check architecture signature end
try_run(RUN_GRAS_VAR COMPILE_GRAS_VAR
message("")
endif(enable_print_message)
-message("\nConfiguration of package `simgrid' (revision ${SVN_VERSION}) on arch (=${GRAS_THISARCH}):")
+message("\nConfiguration of package `simgrid' on arch (=${GRAS_THISARCH}):")
message(" BUILDNAME : ${BUILDNAME}")
message(" SITE : ${SITE}")
-message(" Release : simgrid-${release_version}~rev${SVN_VERSION}")
+message(" Release : simgrid-${release_version}")
message("")
message(" Compiler: c++ : ${CMAKE_CXX_COMPILER}")
message(" version: ${COMPILER_CXX_VERSION}")
#cmakedefine PROCESSOR_i686 @PROCESSOR_i686@
#cmakedefine PROCESSOR_x86_64 @PROCESSOR_x86_64@
#cmakedefine CMAKE_SYSTEM_PROCESSOR @CMAKE_SYSTEM_PROCESSOR@
+#cmakedefine HAVE_RAWCTX @HAVE_RAWCTX@
/* Defined if arrays in struct can straddle struct alignment boundaries. This
is like than the structure compaction above, but this time, the argument to
-# define installer name\r
-outFile "SimGrid@SIMGRID_VERSION_MAJOR@.@SIMGRID_VERSION_MINOR@.@SIMGRID_VERSION_PATCH@_win@WIN_ARCH@@BIN_EXE@"\r
+!include "MUI2.nsh"\r
\r
-# set the default installation directory\r
-InstallDir $PROGRAMFILES\SimGrid\r
+;--------------------------------\r
+;Interface Configuration\r
\r
-# The text to prompt the user to enter a directory\r
-DirText "This will install Simgrid on your computer. Choose a directory"\r
+ !define MUI_HEADERIMAGE\r
+ !define MUI_HEADERIMAGE_BITMAP "@CMAKE_HOME_DIRECTORY@\doc\webcruft\simgrid_logo_win.bmp" ; optional\r
+ !define MUI_ABORTWARNING\r
\r
-# default section start\r
-section\r
+;--------------------------------\r
+;Pages\r
+\r
+ !insertmacro MUI_PAGE_LICENSE "@CMAKE_HOME_DIRECTORY@\LICENSE-LGPL-2.1"\r
+ !insertmacro MUI_PAGE_COMPONENTS\r
+ !insertmacro MUI_PAGE_DIRECTORY\r
+ !insertmacro MUI_PAGE_INSTFILES\r
+ !insertmacro MUI_PAGE_FINISH\r
+ \r
+ !insertmacro MUI_UNPAGE_CONFIRM\r
+ !insertmacro MUI_UNPAGE_INSTFILES\r
+ !insertmacro MUI_UNPAGE_FINISH\r
+\r
+;--------------------------------\r
+;Languages\r
+ !insertmacro MUI_LANGUAGE "English"\r
+ !insertmacro MUI_LANGUAGE "French"\r
+;--------------------------------\r
+\r
+Name "Simgrid"\r
+outFile "SimGrid@SIMGRID_VERSION_MAJOR@.@SIMGRID_VERSION_MINOR@.@SIMGRID_VERSION_PATCH@_@CMAKE_SYSTEM_PROCESSOR@@BIN_EXE@"\r
+Icon "@CMAKE_HOME_DIRECTORY@\doc\webcruft\SimGrid.ico"\r
+\r
+# set the default installation directory\r
+InstallDir c:\SimGrid@SIMGRID_VERSION_MAJOR@.@SIMGRID_VERSION_MINOR@.@SIMGRID_VERSION_PATCH@\r
+\r
+Section "Libraries and Headers" LibSection\r
\r
# install lib\r
CreateDirectory $INSTDIR\lib\r
file @CMAKE_HOME_DIRECTORY@\include\simix\datatypes.h\r
file @CMAKE_HOME_DIRECTORY@\include\simix\context.h\r
\r
+SectionEnd\r
+Section "Binaries" BinSection \r
+ \r
# insatll bin\r
CreateDirectory $INSTDIR\bin\r
setOutPath $INSTDIR\bin\r
file bin\smpirun\r
file bin\tesh\r
\r
- #install doc\r
+SectionEnd\r
+Section "Documentation" DocSection \r
+ \r
+ # install doc\r
CreateDirectory $INSTDIR\doc\r
setOutPath $INSTDIR\doc\r
file /nonfatal /r @CMAKE_HOME_DIRECTORY@\doc\html\r
+ # create a shortcut in the start menu programs directory\r
+ CreateDirectory "$SMPROGRAMS\SimGrid"\r
+ createShortCut "$SMPROGRAMS\SimGrid\Documentation.lnk" "$INSTDIR\doc\html\index.html"\r
+ \r
+SectionEnd\r
+Section "Examples" ExamplesSection \r
+ \r
+ # install examples\r
+ CreateDirectory $INSTDIR\examples\r
+ setOutPath $INSTDIR\examples\r
+ file /r @CMAKE_HOME_DIRECTORY@\examples\platforms\r
+ file /r @CMAKE_HOME_DIRECTORY@\doc\HelloWorld\r
+ # create a shortcut in the start menu programs directory\r
+ createShortCut "$SMPROGRAMS\SimGrid\HelloWorld project.lnk" "$INSTDIR\examples\HelloWorld" \r
+ \r
+SectionEnd\r
\r
+# default section start\r
+section \r
# define uninstaller name\r
writeUninstaller $INSTDIR\uninstaller@BIN_EXE@\r
\r
# create a shortcut in the start menu programs directory\r
CreateDirectory "$SMPROGRAMS\SimGrid"\r
createShortCut "$SMPROGRAMS\SimGrid\Uninstall simgrid.lnk" "$INSTDIR\uninstaller@BIN_EXE@"\r
- createShortCut "$SMPROGRAMS\SimGrid\Documentation.lnk" "$INSTDIR\doc\index.html"\r
+\r
+ # Include for some of the windows message defines\r
+ !include "winmessages.nsh"\r
+ # HKLM (all users) vs HKCU (current user) defines\r
+ !define env_hklm 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'\r
+ !define env_hkcu 'HKCU "Environment"'\r
+ # Set Variables\r
+ WriteRegExpandStr ${env_hklm} SIMGRID_ROOT $INSTDIR\r
+ WriteRegExpandStr ${env_hklm} SIMGRID_VERSION @SIMGRID_VERSION_MAJOR@.@SIMGRID_VERSION_MINOR@.@SIMGRID_VERSION_PATCH@\r
+\r
+ WriteRegStr HKCU "SOFTWARE\SimGrid" "Version" "@SIMGRID_VERSION_MAJOR@.@SIMGRID_VERSION_MINOR@.@SIMGRID_VERSION_PATCH@"\r
+ WriteRegStr HKCU "SOFTWARE\SimGrid" "InstallPath" "$INSTDIR"\r
\r
- MessageBox MB_OK "Installation was successful."\r
+ SetRebootFlag true\r
\r
# default section end\r
sectionEnd\r
\r
+LangString DESC_LibSection ${LANG_ENGLISH} "Install Simgrid and gras libraries with associated headers."\r
+LangString DESC_BinSection ${LANG_ENGLISH} "Install some useful tools for Simgrid."\r
+LangString DESC_DocSection ${LANG_ENGLISH} "Generated (doxygen) documentation."\r
+LangString DESC_ExamplesSection ${LANG_ENGLISH} "Simgrid's HelloWorld example and some classical platforms."\r
+\r
+LangString DESC_LibSection ${LANG_FRENCH} "Installer les librairies Simgrid et Gras et leurs EntĂȘtes."\r
+LangString DESC_BinSection ${LANG_FRENCH} "Installer les outils optionnels."\r
+LangString DESC_DocSection ${LANG_FRENCH} "Installer la documentation."\r
+LangString DESC_ExamplesSection ${LANG_FRENCH} "Installer un exemple 'HelloWorld' et des fichiers de plate-formes types."\r
+\r
+!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN\r
+ !insertmacro MUI_DESCRIPTION_TEXT ${LibSection} $(DESC_LibSection)\r
+ !insertmacro MUI_DESCRIPTION_TEXT ${BinSection} $(DESC_BinSection)\r
+ !insertmacro MUI_DESCRIPTION_TEXT ${DocSection} $(DESC_DocSection)\r
+ !insertmacro MUI_DESCRIPTION_TEXT ${ExamplesSection} $(DESC_ExamplesSection)\r
+!insertmacro MUI_FUNCTION_DESCRIPTION_END\r
+\r
# create a section to define what the uninstaller does.\r
# the section will always be named "Uninstall"\r
section "Uninstall"\r
# delete link\r
delete "$SMPROGRAMS\SimGrid\Uninstall simgrid.lnk"\r
delete "$SMPROGRAMS\SimGrid\Documentation.lnk"\r
+ delete "$SMPROGRAMS\SimGrid\HelloWorld project.lnk"\r
\r
# now delete directories\r
RMDir "$INSTDIR\bin"\r
RMDir "$INSTDIR\include\xbt"\r
RMDir "$INSTDIR\include"\r
RMDir /r "$INSTDIR\doc"\r
+ RMDir /r "$INSTDIR\examples"\r
RMDir "$SMPROGRAMS\SimGrid"\r
- RMDir "$PROGRAMFILES\SimGrid"\r
-\r
+ \r
+ # Delete variable\r
+ DeleteRegValue ${env_hklm} SIMGRID_ROOT\r
+ DeleteRegValue ${env_hklm} SIMGRID_VERSION\r
+ DeleteRegKey HKCU "SOFTWARE\SimGrid"\r
+ \r
# uninstall section end\r
sectionEnd
\ No newline at end of file
$OS = "WIN";
}
+print "OS: ".$OS."\n";
+
# make sure we received a tesh file
scalar @ARGV > 0 || die "Usage:\n tesh [*options*] *tesh_file*\n";
# cleanup the command line
if($OS eq "WIN"){
$cmd{'cmd'} =~ s/\${EXEEXT:=}/.exe/g;
+ $cmd{'cmd'} =~ s/\${EXEEXT}/.exe/g;
+ $cmd{'cmd'} =~ s/\$EXEEXT/.exe/g;
}
else{
$cmd{'cmd'} =~ s/\${EXEEXT:=}//g;
PREDEFINED = DOXYGEN \
DOXYGEN_SKIP_IT \
- XBT_PUBLIC=
+ XBT_PUBLIC= \
+ XBT_INLINE=
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
# this tag can be used to specify a list of macro names that should be expanded.
\li cmake 2.8 <a href="http://www.cmake.org/cmake/resources/software.html">(download page)</a>
\li perl strawberry <a href="http://www.strawberryperl.com/download/5.12.2.0/strawberry-perl-5.12.2.0.msi">(download page)</a>
\li pcre-7.0 <a href="http://sourceforge.net/projects/gnuwin32/files/pcre/7.0/pcre-7.0.exe/download">(download page)</a>
-
+ \li git <a href="http://msysgit.googlecode.com/files/Git-1.7.4-preview20110204.exe">(download page)</a>
+
\subsubsection faq_cmakeoption1 Liste of options
\verbatim
On Windows
+Open the "Git Bash" window.
\verbatim
cmake -G"Unix Makefiles" -D[name]=[value] ... ./
gmake
--- /dev/null
+### This is a template for building targets with simgrid
+cmake_minimum_required(VERSION 2.8)
+
+### Need to set rc ccompiler before enable language
+if(WIN32)
+ SET(CMAKE_RC_COMPILER "windres")
+endif(WIN32)
+
+project(HelloWorld C)
+set(CMAKE_C_FLAGS "" CACHE TYPE INTERNAL FORCE)
+set(CMAKE_EXE_LINKER_FLAGS "" CACHE TYPE INTERNAL FORCE)
+
+###############################
+# Test the build dependencies #
+###############################
+include(FindPCRE.cmake)
+message(STATUS "Looking for lib Simgrid")
+if("$ENV{SIMGRID_ROOT}" STREQUAL "")
+ message(STATUS "Looking for lib Simgrid - Not found")
+ message(FATAL_ERROR "Simgrid not found, reinstall it or set SIMGRID_ROOT")
+else("$ENV{SIMGRID_ROOT}" STREQUAL "")
+ link_directories($ENV{SIMGRID_ROOT}/lib)
+ include_directories($ENV{SIMGRID_ROOT}/include)
+ include_directories($ENV{SIMGRID_ROOT}/src)
+ include_directories($ENV{SIMGRID_ROOT}/src/include)
+ add_library(libsimgrid STATIC IMPORTED)
+ message(STATUS "Looking for lib Simgrid - found")
+endif("$ENV{SIMGRID_ROOT}" STREQUAL "")
+
+###########
+# TARGETS #
+###########
+
+#########################
+# add_executable #
+# args1 target name #
+# args2 sources #
+#########################
+add_executable(HelloWorld HelloWorld.c)
+# Any targets need to be linked with simgrid and pcre
+target_link_libraries(HelloWorld simgrid pcre)
--- /dev/null
+### SET THE LIBRARY EXTENSION AND GCC VERSION
+if(APPLE) #MAC
+ set(LIB_EXE "dylib")
+else(APPLE)
+ if(WIN32) #WINDOWS
+ set(LIB_EXE "a")
+ set(BIN_EXE ".exe")
+ else(WIN32) #UNIX
+ set(LIB_EXE "so")
+ endif(WIN32)
+endif(APPLE)
+
+find_library(PATH_PCRE_LIB
+ NAMES pcre
+ HINTS
+ $ENV{LD_LIBRARY_PATH}
+ $ENV{PCRE_LIBRARY_PATH}
+ PATH_SUFFIXES lib/ GnuWin32/lib
+ PATHS
+ /opt
+ /opt/local
+ /opt/csw
+ /sw
+ /usr)
+
+find_path(PATH_PCRE_H "pcre.h"
+ HINTS
+ $ENV{LD_LIBRARY_PATH}
+ $ENV{PCRE_LIBRARY_PATH}
+ PATH_SUFFIXES include/ GnuWin32/include
+ PATHS
+ /opt
+ /opt/local
+ /opt/csw
+ /sw
+ /usr)
+
+set(HAVE_PCRE_LIB 0)
+
+message(STATUS "Looking for pcre.h")
+if(PATH_PCRE_H)
+message(STATUS "Looking for pcre.h - found")
+else(PATH_PCRE_H)
+message(STATUS "Looking for pcre.h - not found")
+endif(PATH_PCRE_H)
+
+message(STATUS "Looking for lib pcre")
+if(PATH_PCRE_LIB)
+message(STATUS "Looking for lib pcre - found")
+else(PATH_PCRE_LIB)
+message(STATUS "Looking for lib pcre - not found")
+endif(PATH_PCRE_LIB)
+
+if(PATH_PCRE_LIB AND PATH_PCRE_H)
+ string(REGEX REPLACE "/libpcre.*[.]${LIB_EXE}$" "" PATHLIBPCRE "${PATH_PCRE_LIB}")
+ string(REGEX REPLACE "/pcre.h" "" PATH_PCRE_H "${PATH_PCRE_H}")
+ string(REGEX MATCH "-L${PATHLIBPCRE} " operation "${CMAKE_C_FLAGS}")
+ if(NOT operation)
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-L${PATHLIBPCRE} ")
+ endif(NOT operation)
+ string(REGEX MATCH "-I${PATH_PCRE_H} " operation "${CMAKE_C_FLAGS}")
+ if(NOT operation)
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-I${PATH_PCRE_H} ")
+ endif(NOT operation)
+ set(HAVE_PCRE_LIB 1)
+else(PATH_PCRE_LIB)
+ message(FATAL_ERROR "Please install the libpcre3-dev package or equivalent before using it.")
+endif(PATH_PCRE_LIB AND PATH_PCRE_H)
+
+mark_as_advanced(PATH_PCRE_H)
+mark_as_advanced(PATH_PCRE_LIB)
\ No newline at end of file
--- /dev/null
+#include "xbt/log.h"
+XBT_LOG_NEW_DEFAULT_CATEGORY(HelloWorld,
+ "Messages specific for this Hello World example");
+void main()
+{
+ XBT_INFO("Hello World !!!");
+}
--- /dev/null
+This is a very simple example to explain how to compile with simgrid.
+
+1) How to compile an example: (HelloWorld)
+
+- Run "Git bash" (installed with git).
+- Open HelloWorld Directory ('cd' command line).
+- Create a build directory and change directory. (optional)
+- Type 'cmake -G"Unix Makefiles" <path_to_HelloWorld_project>'
+- Run gmake
+- You should obtain a runnable example ("HelloWorld.exe").
+
+2) Content of this directory
+
+- HelloWorld.c
+ The example source file.
+- CMakeLists.txt
+ It allows to configure the project.
+- FindPCRE.cmake
+ Simgrid needs pcre regular expression.
+ This finds and links to the pcre library.
+- README
+ This explaination.
+
+3) How to add and compile a new example
+
+- Put your source file into the helloWord directory.
+- Edit CMakeLists.txt :
+ * In the Targets section add those two lines:
+ add_executable(TARGET_NAME SOURCES)
+ target_link_libraries(TARGET_NAME simgrid pcre)
+ * It creates a target called 'TARGET_NAME.exe' with the sources 'SOURCES'.
+- To initialize your project, you'll need to run 'cmake -G"Unix Makefiles" <path_to_HelloWorld_project>.'
+- To build you project, run "cmake ."
+- Run "gmake"
+- You should obtain "TARGET_NAME.exe".
\ No newline at end of file
XBT_INLINE XBT_PUBLIC(void) xbt_dynar_free(xbt_dynar_t * dynar);
XBT_PUBLIC(void) xbt_dynar_free_voidp(void *dynar);
XBT_PUBLIC(void) xbt_dynar_free_container(xbt_dynar_t * dynar);
-
-XBT_INLINE XBT_PUBLIC(unsigned long) xbt_dynar_length(const xbt_dynar_t
- dynar);
-XBT_INLINE XBT_PUBLIC(int) xbt_dynar_is_empty(const xbt_dynar_t dynar);
-XBT_PUBLIC(void) xbt_dynar_reset(xbt_dynar_t const dynar);
XBT_PUBLIC(void) xbt_dynar_shrink(xbt_dynar_t dynar, int empty_slots);
-
XBT_PUBLIC(void) xbt_dynar_dump(xbt_dynar_t dynar);
/** @} */
int(*compar)(const void *, const void *));
XBT_INLINE XBT_PUBLIC(void *) xbt_dynar_to_array (xbt_dynar_t dynar);
+/** @} */
+/** @defgroup XBT_dynar_misc Dynar miscellaneous functions
+ * @ingroup XBT_dynar
+ *
+ * @{
+ */
+
+XBT_INLINE XBT_PUBLIC(unsigned long) xbt_dynar_length(const xbt_dynar_t
+ dynar);
+XBT_INLINE XBT_PUBLIC(int) xbt_dynar_is_empty(const xbt_dynar_t dynar);
+XBT_PUBLIC(void) xbt_dynar_reset(xbt_dynar_t const dynar);
+
+
/** @} */
/** @defgroup XBT_dynar_perl Perl-like use of dynars
* @ingroup XBT_dynar
#ifdef HAVE_TRACING
+/* Need to define function drand48 for Windows */
+#ifdef _WIN32
+# define drand48() (rand()/(RAND_MAX + 1.0))
+#endif
+
#define INSTR_DEFAULT_STR_SIZE 500
#include "instr/instr.h"
}
else { /* use the factory specified by --cfg=contexts/factory:value */
- if (smx_context_factory_name == NULL) {
+ if (smx_context_factory_name == NULL) {
/* use the default factory */
-#ifdef CONTEXT_UCONTEXT
- SIMIX_ctx_sysv_factory_init(&simix_global->context_factory);
-#else
- SIMIX_ctx_thread_factory_init(&simix_global->context_factory);
-#endif
- }
- else if (!strcmp(smx_context_factory_name, "ucontext")) {
+ #ifdef HAVE_RAWCTX
+ SIMIX_ctx_raw_factory_init(&simix_global->context_factory);
+ #elif CONTEXT_UCONTEXT
+ SIMIX_ctx_sysv_factory_init(&simix_global->context_factory);
+ #else
+ SIMIX_ctx_thread_factory_init(&simix_global->context_factory);
+ #endif
+ }
+ else if (!strcmp(smx_context_factory_name, "ucontext")) {
/* use ucontext */
#ifdef CONTEXT_UCONTEXT
SIMIX_ctx_sysv_factory_init(&simix_global->context_factory);
#ifdef PROCESSOR_i686
__asm__ (
-#ifdef APPLE
+#if defined(APPLE) || defined(_WIN32)
".text\n"
".globl _raw_makecontext\n"
"_raw_makecontext:\n"
);
__asm__ (
-#ifdef APPLE
+#if defined(APPLE) || defined(_WIN32)
".text\n"
".globl _raw_swapcontext\n"
"_raw_swapcontext:\n"
);
#elif PROCESSOR_x86_64
__asm__ (
-#ifdef APPLE
+#if defined(APPLE) || defined(_WIN32)
".text\n"
".globl _raw_makecontext\n"
"_raw_makecontext:\n"
);
__asm__ (
-#ifdef APPLE
+#if defined(APPLE) || defined(_WIN32)
".text\n"
".globl _raw_swapcontext\n"
"_raw_swapcontext:\n"
{
void *object;
- if (m->current_size > 0) {
- /* there is at least an available object */
- /* XBT_DEBUG("Reuse an old object for mallocator %p (size:%d/%d)", m,
- m->current_size, m->max_size); */
- object = m->objects[--m->current_size];
- } else {
- /* otherwise we must allocate a new object */
+ if (m->current_size <= 0) {
+ /* No object is ready yet. Create a bunch of them to try to group the mallocs
+ * on the same memory pages (to help the cache lines) */
+
/* XBT_DEBUG("Create a new object for mallocator %p (size:%d/%d)", m,
m->current_size, m->max_size); */
- object = (*(m->new_f)) ();
+ int i;
+ int amount=MIN( (m->max_size) /2,1000);
+ for (i=0;i<amount;i++)
+ m->objects[i] = (*(m->new_f)) ();
+ m->current_size=amount;
}
+
+ /* there is at least an available object, now */
+ /* XBT_DEBUG("Reuse an old object for mallocator %p (size:%d/%d)", m,
+ m->current_size, m->max_size); */
+ if (MC_IS_ENABLED) /* no mallocator with MC */
+ object = (*(m->new_f)) ();
+ else
+ object = m->objects[--m->current_size];
+
(*(m->reset_f)) (object);
return object;
}