CMakeCache.txt
DartConfiguration.tcl
simgrid.nsi
+TAGS
Testing/
Makefile
bin/
lib/
manpages/
-build_dir/
+build_*/
build/
buildtools/Cmake/memcheck_tests.cmake
buildtools/Cmake/test_prog/prog_va_copy.c
set_tests_properties(mc-centralized-raw PROPERTIES WILL_FAIL true)
endif()
endif()
- set_tests_properties(msg-bittorrent-thread-parallel PROPERTIES ENVIRONMENT SG_TEST_EXENV=true WILL_FAIL true)
- if(CONTEXT_UCONTEXT)
- set_tests_properties(msg-bittorrent-ucontext-parallel PROPERTIES ENVIRONMENT SG_TEST_EXENV=true WILL_FAIL true)
- endif()
- if(HAVE_RAWCTX)
- set_tests_properties(msg-bittorrent-raw-parallel PROPERTIES ENVIRONMENT SG_TEST_EXENV=true WILL_FAIL true)
- endif()
endif()
endif()
if(enable_java)
find_package(Java REQUIRED COMPONENTS Runtime Development)
find_package(JNI REQUIRED)
- include(UseJava)
set(HAVE_Java 1)
endif()
if(enable_lua)
--- /dev/null
+cmake_minimum_required(VERSION 2.8.6)
+
+include(UseJava)
+
+# Rules to build libSG_java
+#
+add_library(SG_java SHARED ${JMSG_C_SRC})
+set_target_properties(SG_java PROPERTIES VERSION ${libSG_java_version})
+get_target_property(COMMON_INCLUDES SG_java INCLUDE_DIRECTORIES)
+set_target_properties(SG_java PROPERTIES
+ INCLUDE_DIRECTORIES "${COMMON_INCLUDES};${JNI_INCLUDE_DIRS}")
+add_dependencies(SG_java simgrid)
+
+if(WIN32)
+ get_target_property(SIMGRID_LIB_NAME_NAME SG_java LIBRARY_OUTPUT_NAME)
+ set_target_properties(SG_java PROPERTIES
+ LINK_FLAGS "-Wl,--subsystem,windows,--kill-at ${SIMGRID_LIB_NAME}"
+ PREFIX "")
+ find_path(PEXPORTS_PATH NAMES pexports.exe PATHS NO_DEFAULT_PATHS)
+ message(STATUS "pexports: ${PEXPORTS_PATH}")
+ if(PEXPORTS_PATH)
+ add_custom_command(TARGET SG_java POST_BUILD
+ COMMAND ${PEXPORTS_PATH}/pexports.exe ${CMAKE_BINARY_DIR}/SG_java.dll > ${CMAKE_BINARY_DIR}/SG_java.def)
+ endif(PEXPORTS_PATH)
+else()
+ target_link_libraries(SG_java simgrid)
+endif()
+
+# Rules to build simgrid.jar
+#
+
+## Files to include in simgrid.jar
+##
+set(SIMGRID_JAR "${CMAKE_BINARY_DIR}/simgrid.jar")
+set(MANIFEST_FILE "${CMAKE_HOME_DIRECTORY}/src/bindings/java/MANIFEST.MF")
+set(LIBSIMGRID_SO
+ ${CMAKE_SHARED_LIBRARY_PREFIX}simgrid${CMAKE_SHARED_LIBRARY_SUFFIX})
+set(LIBSG_JAVA_SO
+ ${CMAKE_SHARED_LIBRARY_PREFIX}SG_java${CMAKE_SHARED_LIBRARY_SUFFIX})
+
+## Name of the "NATIVE" folder in simgrid.jar
+##
+if(CMAKE_SYSTEM_PROCESSOR MATCHES ".86")
+ if(${ARCH_32_BITS})
+ set(JSG_BUNDLE "NATIVE/${CMAKE_SYSTEM_NAME}/i386/")
+ else()
+ set(JSG_BUNDLE "NATIVE/${CMAKE_SYSTEM_NAME}/amd64/")
+ endif()
+else()
+ message(WARNING "Unknown system type. Processor: ${CMAKE_SYSTEM_PROCESSOR}; System: ${CMAKE_SYSTEM_NAME}")
+ set(JSG_BUNDLE "NATIVE/${CMAKE_SYSTEM_NAME}/${CMAKE_SYSTEM_PROCESSOR/")
+endif()
+message("Native libraries bundled into: ${JSG_BUNDLE}")
+
+## Don't strip libraries if not in release mode
+##
+if(release)
+ set(STRIP_COMMAND "${CMAKE_STRIP}")
+else()
+ set(STRIP_COMMAND "true")
+endif()
+
+## Here is how to build simgrid.jar
+##
+set(CMAKE_JAVA_TARGET_OUTPUT_NAME simgrid)
+add_jar(SG_java_pre_jar ${JMSG_JAVA_SRC})
+
+add_custom_command(
+ COMMENT "Finalize simgrid.jar..."
+ OUTPUT ${SIMGRID_JAR}_finalized
+ DEPENDS simgrid SG_java SG_java_pre_jar
+ ${SIMGRID_JAR} ${MANIFEST_FILE}
+ ${CMAKE_BINARY_DIR}/lib/${LIBSIMGRID_SO}
+ ${CMAKE_BINARY_DIR}/lib/${LIBSG_JAVA_SO}
+ ${CMAKE_HOME_DIRECTORY}/COPYING
+ ${CMAKE_HOME_DIRECTORY}/ChangeLog
+ ${CMAKE_HOME_DIRECTORY}/ChangeLog.SimGrid-java
+ COMMAND ${CMAKE_COMMAND} -E remove_directory "NATIVE"
+ COMMAND ${CMAKE_COMMAND} -E make_directory "${JSG_BUNDLE}"
+ COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/lib/${LIBSIMGRID_SO}" "${JSG_BUNDLE}"
+ COMMAND ${STRIP_COMMAND} -S "${JSG_BUNDLE}/${LIBSIMGRID_SO}"
+ COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/lib/${LIBSG_JAVA_SO}" "${JSG_BUNDLE}"
+ COMMAND ${STRIP_COMMAND} -S "${JSG_BUNDLE}/${LIBSG_JAVA_SO}"
+ COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_HOME_DIRECTORY}/COPYING" "${JSG_BUNDLE}"
+ COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_HOME_DIRECTORY}/ChangeLog" "${JSG_BUNDLE}"
+ COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_HOME_DIRECTORY}/ChangeLog.SimGrid-java" "${JSG_BUNDLE}"
+ COMMAND ${JAVA_ARCHIVE} -uvmf ${MANIFEST_FILE} ${SIMGRID_JAR} "NATIVE"
+ COMMAND ${CMAKE_COMMAND} -E remove ${SIMGRID_JAR}_finalized
+ COMMAND ${CMAKE_COMMAND} -E touch ${SIMGRID_JAR}_finalized
+ )
+add_custom_target(SG_java_jar ALL DEPENDS ${SIMGRID_JAR}_finalized)
endif()
if(enable_java)
- add_library(SG_java SHARED ${JMSG_C_SRC})
- set_target_properties(SG_java PROPERTIES VERSION ${libSG_java_version})
- get_target_property(COMMON_INCLUDES SG_java INCLUDE_DIRECTORIES)
- set_target_properties(SG_java PROPERTIES
- INCLUDE_DIRECTORIES "${COMMON_INCLUDES};${JNI_INCLUDE_DIRS}")
- add_dependencies(SG_java simgrid)
-
- if(WIN32)
- get_target_property(SIMGRID_LIB_NAME_NAME SG_java LIBRARY_OUTPUT_NAME)
- set_target_properties(SG_java PROPERTIES
- LINK_FLAGS "-Wl,--subsystem,windows,--kill-at ${SIMGRID_LIB_NAME}"
- PREFIX "")
- find_path(PEXPORTS_PATH NAMES pexports.exe PATHS NO_DEFAULT_PATHS)
- message(STATUS "pexports: ${PEXPORTS_PATH}")
- if(PEXPORTS_PATH)
- add_custom_command(TARGET SG_java POST_BUILD
- COMMAND ${PEXPORTS_PATH}/pexports.exe ${CMAKE_BINARY_DIR}/SG_java.dll > ${CMAKE_BINARY_DIR}/SG_java.def)
- endif(PEXPORTS_PATH)
- else()
- target_link_libraries(SG_java simgrid)
- endif()
-
- set(CMAKE_JAVA_TARGET_OUTPUT_NAME simgrid)
- add_jar(SG_java_pre_jar ${JMSG_JAVA_SRC})
-
- set(SIMGRID_JAR "${CMAKE_BINARY_DIR}/simgrid.jar")
- set(MANIFEST_FILE "${CMAKE_HOME_DIRECTORY}/src/bindings/java/MANIFEST.MF")
-
- if(CMAKE_SYSTEM_PROCESSOR MATCHES ".86")
- if(${ARCH_32_BITS})
- set(JSG_BUNDLE "NATIVE/${CMAKE_SYSTEM_NAME}/x86/")
- else()
- set(JSG_BUNDLE "NATIVE/${CMAKE_SYSTEM_NAME}/amd64/")
- endif()
- else()
- message(WARNING "Unknown system type. Processor: ${CMAKE_SYSTEM_PROCESSOR}; System: ${CMAKE_SYSTEM_NAME}")
- set(JSG_BUNDLE "NATIVE/${CMAKE_SYSTEM_NAME}/${CMAKE_SYSTEM_PROCESSOR/")
- endif()
- message("Native libraries bundled into: ${JSG_BUNDLE}")
-
- set(LIBSIMGRID_SO
- ${CMAKE_SHARED_LIBRARY_PREFIX}simgrid${CMAKE_SHARED_LIBRARY_SUFFIX})
- set(LIBSG_JAVA_SO
- ${CMAKE_SHARED_LIBRARY_PREFIX}SG_java${CMAKE_SHARED_LIBRARY_SUFFIX})
-
- if(release)
- set(STRIP_COMMAND "${CMAKE_STRIP}")
- else()
- set(STRIP_COMMAND "true")
- endif()
-
- add_custom_command(
- COMMENT "Finalize simgrid.jar..."
- OUTPUT ${SIMGRID_JAR}_finalized
- DEPENDS simgrid SG_java SG_java_pre_jar
- ${SIMGRID_JAR} ${MANIFEST_FILE}
- ${CMAKE_BINARY_DIR}/lib/${LIBSIMGRID_SO}
- ${CMAKE_BINARY_DIR}/lib/${LIBSG_JAVA_SO}
- ${CMAKE_HOME_DIRECTORY}/COPYING
- ${CMAKE_HOME_DIRECTORY}/ChangeLog
- ${CMAKE_HOME_DIRECTORY}/ChangeLog.SimGrid-java
- COMMAND ${CMAKE_COMMAND} -E remove_directory "NATIVE"
- COMMAND ${CMAKE_COMMAND} -E make_directory "${JSG_BUNDLE}"
- COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/lib/${LIBSIMGRID_SO}" "${JSG_BUNDLE}"
- COMMAND ${STRIP_COMMAND} -S "${JSG_BUNDLE}/${LIBSIMGRID_SO}"
- COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/lib/${LIBSG_JAVA_SO}" "${JSG_BUNDLE}"
- COMMAND ${STRIP_COMMAND} -S "${JSG_BUNDLE}/${LIBSG_JAVA_SO}"
- COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_HOME_DIRECTORY}/COPYING" "${JSG_BUNDLE}"
- COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_HOME_DIRECTORY}/ChangeLog" "${JSG_BUNDLE}"
- COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_HOME_DIRECTORY}/ChangeLog.SimGrid-java" "${JSG_BUNDLE}"
- COMMAND ${JAVA_ARCHIVE} -uvmf ${MANIFEST_FILE} ${SIMGRID_JAR} "NATIVE"
- COMMAND ${CMAKE_COMMAND} -E remove ${SIMGRID_JAR}_finalized
- COMMAND ${CMAKE_COMMAND} -E touch ${SIMGRID_JAR}_finalized
- )
- add_custom_target(SG_java_jar ALL DEPENDS ${SIMGRID_JAR}_finalized)
+ include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeJava.cmake)
endif()
add_dependencies(simgrid maintainer_files)
#include "peer.h"
#include "tracker.h"
#include <msg/msg.h>
+#include <xbt/RngStream.h>
+
/**
* Bittorrent example launcher
*/
int main(int argc, char *argv[])
{
+ xbt_dynar_t host_list;
+ msg_host_t host;
+ unsigned i;
+
MSG_init(&argc, argv);
/* Check the arguments */
MSG_create_environment(platform_file);
+ host_list = MSG_hosts_as_dynar();
+ xbt_dynar_foreach(host_list, i, host) {
+ char descr[512];
+ RngStream stream;
+ snprintf(descr, sizeof descr, "RngSream<%s>", MSG_host_get_name(host));
+ stream = RngStream_CreateStream(descr);
+ MSG_host_set_data(host, stream);
+ }
+
MSG_function_register("tracker", tracker);
MSG_function_register("peer", peer);
MSG_main();
+ xbt_dynar_foreach(host_list, i, host) {
+ RngStream stream = MSG_host_get_data(host);
+ RngStream_DeleteStream(&stream);
+ }
+ xbt_dynar_free(&host_list);
+
return 0;
}
* Number of pieces the peer asks for simultaneously
*/
#define MAX_PIECES 1
+
#endif /* BITTORRENT_BITTORRENT_H_ */
> [ 0.000000] (8:peer@McGee) Hi, I'm joining the network with id 8
> [ 3000.000000] (1:tracker@Jacquelin) Tracker is leaving
> [ 5000.005340] (5:peer@Geoff) Here is my current status: 1111111111
-> [ 5000.012657] (7:peer@iRMX) Here is my current status: 1111111111
+> [ 5000.012635] (7:peer@iRMX) Here is my current status: 1111111111
> [ 5000.048881] (2:peer@Boivin) Here is my current status: 1111111111
> [ 5000.827441] (8:peer@McGee) Here is my current status: 1111111111
> [ 5000.832977] (3:peer@Jean_Yves) Here is my current status: 1111111111
peer->current_pieces = xbt_dynar_new(sizeof(int), NULL);
peer->current_piece = -1;
- peer->stream = RngStream_CreateStream("");
+ peer->stream = MSG_host_get_data(MSG_host_self());
peer->comm_received = NULL;
peer->round = 0;
xbt_free(peer->pieces_count);
xbt_free(peer->bitfield);
xbt_free(peer->bitfield_blocks);
-
- RngStream_DeleteStream(&peer->stream);
}
/**
{
int i;
- RngStream stream = RngStream_CreateStream("tracker");
+ RngStream stream = MSG_host_get_data(MSG_host_self());
//Checking arguments
xbt_assert(argc == 2, "Wrong number of arguments for the tracker.");
}
//Free the peers list
xbt_dynar_free(&peers_list);
- //Free the RngStream object.
- RngStream_DeleteStream(&stream);
XBT_INFO("Tracker is leaving");
*
* We allow to link against compiled versions that differ in the patch level.
*/
-#define MSG_init(argc,argv) { \
- int ver_major,ver_minor,ver_patch; \
- sg_version(&ver_major,&ver_minor,&ver_patch); \
- if ((ver_major != SIMGRID_VERSION_MAJOR) || \
- (ver_minor != SIMGRID_VERSION_MINOR)) { \
- fprintf(stderr,"FATAL ERROR: Your program was compiled with SimGrid version %d.%d.%d, and then linked against SimGrid %d.%d.%d. Please fix this.\n", \
- SIMGRID_VERSION_MAJOR,SIMGRID_VERSION_MINOR,SIMGRID_VERSION_PATCH,ver_major,ver_minor,ver_patch); \
- } \
- MSG_init_nocheck(argc,argv); \
- }
+#define MSG_init(argc,argv) { \
+ int ver_major,ver_minor,ver_patch; \
+ sg_version(&ver_major,&ver_minor,&ver_patch); \
+ if ((ver_major != SIMGRID_VERSION_MAJOR) || \
+ (ver_minor != SIMGRID_VERSION_MINOR)) { \
+ fprintf(stderr,"FATAL ERROR: Your program was compiled with SimGrid version %d.%d.%d, and then linked against SimGrid %d.%d.%d. Please fix this.\n", \
+ SIMGRID_VERSION_MAJOR,SIMGRID_VERSION_MINOR,SIMGRID_VERSION_PATCH,ver_major,ver_minor,ver_patch); \
+ } \
+ MSG_init_nocheck(argc,argv); \
+ }
XBT_PUBLIC(void) MSG_init_nocheck(int *argc, char **argv);
XBT_PUBLIC(msg_error_t) MSG_main(void);
XBT_PUBLIC(msg_error_t) MSG_task_receive_from_host(msg_task_t * task, const char *alias,
msg_host_t host);
+XBT_PUBLIC(msg_error_t) MSG_task_receive_from_host_bounded(msg_task_t * task, const char *alias,
+ msg_host_t host, double rate);
XBT_PUBLIC(msg_error_t) MSG_task_execute(msg_task_t task);
XBT_PUBLIC(msg_error_t) MSG_parallel_task_execute(msg_task_t task);
XBT_PUBLIC(void) MSG_task_set_compute_duration(msg_task_t task,
double compute_duration);
XBT_PUBLIC(void) MSG_task_set_data_size(msg_task_t task,
- double data_size);
+ double data_size);
XBT_PUBLIC(double) MSG_task_get_remaining_computation(msg_task_t task);
XBT_PUBLIC(double) MSG_task_get_remaining_communication(msg_task_t task);
MSG_task_receive(msg_task_t * task, const char *alias);
#define MSG_task_recv(t,a) MSG_task_receive(t,a)
+
+
+XBT_PUBLIC(msg_error_t)
+ MSG_task_receive_ext_bounded(msg_task_t * task, const char *alias, double timeout,
+ msg_host_t host, double rate);
+
+XBT_PUBLIC(msg_error_t)
+ MSG_task_receive_with_timeout_bounded(msg_task_t * task, const char *alias,
+ double timeout, double rate);
+
+XBT_PUBLIC(msg_error_t)
+ MSG_task_receive_bounded(msg_task_t * task, const char *alias,double rate);
+#define MSG_task_recv_bounded(t,a,r) MSG_task_receive_bounded(t,a,r)
+
XBT_PUBLIC(msg_comm_t) MSG_task_isend(msg_task_t task, const char *alias);
XBT_PUBLIC(msg_comm_t) MSG_task_isend_bounded(msg_task_t task, const char *alias, double maxrate);
XBT_PUBLIC(msg_comm_t) MSG_task_isend_with_matching(msg_task_t task,
XBT_PUBLIC(void) MSG_task_dsend(msg_task_t task, const char *alias, void_f_pvoid_t cleanup);
XBT_PUBLIC(void) MSG_task_dsend_bounded(msg_task_t task, const char *alias, void_f_pvoid_t cleanup, double maxrate);
XBT_PUBLIC(msg_comm_t) MSG_task_irecv(msg_task_t * task, const char *alias);
+XBT_PUBLIC(msg_comm_t) MSG_task_irecv_bounded(msg_task_t * task, const char *alias, double rate);
XBT_PUBLIC(int) MSG_comm_test(msg_comm_t comm);
XBT_PUBLIC(int) MSG_comm_testany(xbt_dynar_t comms);
XBT_PUBLIC(void) MSG_comm_destroy(msg_comm_t comm);
XBT_PUBLIC(msg_error_t)
MSG_task_send_with_timeout(msg_task_t task, const char *alias,
double timeout);
-
+
XBT_PUBLIC(msg_error_t)
MSG_task_send_with_timeout_bounded(msg_task_t task, const char *alias,
double timeout, double maxrate);
MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, msg_task_t * task,
msg_host_t host, double timeout);
+XBT_PUBLIC(msg_error_t)
+ MSG_mailbox_get_task_ext_bounded(msg_mailbox_t mailbox, msg_task_t *task,
+ msg_host_t host, double timeout, double rate);
+
XBT_PUBLIC(msg_error_t)
MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, msg_task_t task,
double timeout);
XBT_PUBLIC(void) simcall_comm_destroy(smx_action_t comm);
XBT_PUBLIC(smx_action_t) simcall_comm_iprobe(smx_rdv_t rdv, int src, int tag,
int (*match_fun)(void *, void *, smx_action_t), void *data);
+XBT_PUBLIC(double) simcall_comm_change_rate_first_action(smx_rdv_t rdv, double newrate);
XBT_PUBLIC(void) simcall_comm_cancel(smx_action_t comm);
/* FIXME: waitany is going to be a vararg function, and should take a timeout */
* \skip end_of_doxygen
* \until }
*
+ * Note that if you use dynars to store pointed data, the
+ * xbt_dynar_search(), xbt_dynar_search_or_negative() and
+ * xbt_dynar_member() won't be for you. Instead of comparing
+ * your pointed elements, they compare the pointer to them. See
+ * the documentation of xbt_dynar_search() for more info.
+ *
*/
/** @defgroup XBT_dynar_cons Dynar constructor and destructor
* @ingroup XBT_dynar
* @param _data
* @hideinitializer
*
- * \note An example of usage:
+ * Here is an example of usage:
* \code
xbt_dynar_t dyn;
unsigned int cpt;
printf("Seen %s\n",str);
}
\endcode
+ *
+ * Note that underneath, that's a simple for loop with no real black
+ * magic involved. It's perfectly safe to interrupt a foreach with a
+ * break or a return statement.
*/
#define xbt_dynar_foreach(_dynar,_cursor,_data) \
for (_xbt_dynar_cursor_first(_dynar,&(_cursor)) ; \
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "jmsg_file.h"
#include "jxbt_utilities.h"
+
void jfile_bind(JNIEnv *env, jobject jfile, msg_file_t stream) {
- (*env)->SetLongField(env, jfile, jfile_field_bind, (jlong) (long) (stream));
+ (*env)->SetLongField(env, jfile, jfile_field_bind, (intptr_t)stream);
}
msg_file_t jfile_get_native(JNIEnv *env, jobject jfile) {
- msg_file_t file = (msg_file_t)(*env)->GetLongField(env, jfile, jfile_field_bind);
+ msg_file_t file =
+ (msg_file_t)(intptr_t)(*env)->GetLongField(env, jfile, jfile_field_bind);
return file;
}
msg_process_t jprocess_to_native_process(jobject jprocess, JNIEnv * env)
{
- return (msg_process_t) (long) (*env)->GetLongField(env, jprocess, jprocess_field_Process_bind);
+ return
+ (msg_process_t)(intptr_t)(*env)->GetLongField(env, jprocess,
+ jprocess_field_Process_bind);
}
void jprocess_bind(jobject jprocess, msg_process_t process, JNIEnv * env)
{
- (*env)->SetLongField(env, jprocess, jprocess_field_Process_bind, (jlong)(process));
+ (*env)->SetLongField(env, jprocess, jprocess_field_Process_bind,
+ (intptr_t)process);
}
jlong jprocess_get_id(jobject jprocess, JNIEnv * env)
{
- return (*env)->GetLongField(env, jprocess, jprocess_field_Process_id);
+ return
+ (intptr_t)(*env)->GetLongField(env, jprocess, jprocess_field_Process_id);
}
jstring jprocess_get_name(jobject jprocess, JNIEnv * env)
/* bind/retrieve the msg host */
host = MSG_get_host_by_name(hostname);
- if (!(host)) { /* not binded */
+ if (!(host)) { /* not bound */
jxbt_throw_host_not_found(env, hostname);
return;
}
jfieldID jrngstream_bind;
RngStream jrngstream_to_native(JNIEnv *env, jobject jrngstream) {
- RngStream rngstream = (RngStream) (*env)->GetLongField(env, jrngstream, jrngstream_bind);
+ RngStream rngstream =
+ (RngStream)(intptr_t)(*env)->GetLongField(env, jrngstream, jrngstream_bind);
if (!rngstream) {
jxbt_throw_notbound(env, "rngstream", jrngstream);
return NULL;
const char *name = (*env)->GetStringUTFChars(env, jname, 0);
RngStream rngstream = RngStream_CreateStream(name);
//Bind the RngStream object
- (*env)->SetLongField(env, jrngstream, jrngstream_bind, (jlong)rngstream);
+ (*env)->SetLongField(env, jrngstream, jrngstream_bind, (intptr_t)rngstream);
(*env)->ReleaseStringUTFChars(env, jname, name);
}
Java_org_simgrid_msg_RngStream_destroy(JNIEnv *env, jobject jrngstream) {
RngStream rngstream = jrngstream_to_native(env, jrngstream);
RngStream_DeleteStream(&rngstream);
- (*env)->SetLongField(env, jrngstream, jrngstream_bind, (jlong)NULL);
+ (*env)->SetLongField(env, jrngstream, jrngstream_bind, (intptr_t)NULL);
}
JNIEXPORT jboolean JNICALL
Java_org_simgrid_msg_RngStream_setPackageSeed(JNIEnv *env, jobject jrngstream, jintArray jseed) {
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(jmsg);
void jvm_bind(JNIEnv *env, jobject jvm, msg_vm_t vm) {
- (*env)->SetLongField(env, jvm, jvm_field_bind, (jlong) (long) (vm));
+ (*env)->SetLongField(env, jvm, jvm_field_bind, (intptr_t)vm);
}
msg_vm_t jvm_get_native(JNIEnv *env, jobject jvm) {
- msg_vm_t vm = (msg_vm_t)(*env)->GetLongField(env, jvm, jvm_field_bind);
- return vm;
+ return (msg_vm_t)(intptr_t)(*env)->GetLongField(env, jvm, jvm_field_bind);
}
JNIEXPORT void JNICALL
msg_vm_t vm = jvm_get_native(env,jvm);
msg_process_t process = jprocess_to_native_process(jprocess,env);
- xbt_assert((vm != NULL), "VM object is not binded");
- xbt_assert((process != NULL), "Process object is not binded.");
+ xbt_assert((vm != NULL), "VM object is not bound");
+ xbt_assert((process != NULL), "Process object is not bound.");
MSG_vm_bind(vm,process);
}
#define JXBT_UTILITY_H
#include <jni.h>
+#include <stdint.h>
/* *********** */
/* JNI GETTERS */
* Thus it is represented as a physical resource with computing capabilities, some
* mailboxes to enable running process to communicate with remote ones, and some private
* data that can be only accessed by local process. An instance of this class is always
- * binded with the corresponding native host. All the native hosts are automatically created
+ * bound with the corresponding native host. All the native hosts are automatically created
* during the call of the method Msg.createEnvironment(). This method take as parameter a
* platform file which describes all elements of the platform (host, link, root..).
* You cannot create a host yourself.
}
/**
* The natively implemented method to create an MSG process.
- * @param hostName A valid (binded) host where create the process.
+ * @param hostName A valid (bound) host where create the process.
*/
protected native void create(String hostName) throws HostNotFoundException;
/**
*/
public native void bind(Process process);
/** Removes the given process from the given VM, and kill it
- * Will raise a ProcessNotFound exception if the process were not binded to that VM
+ * Will raise a ProcessNotFound exception if the process were not bound to that VM
*/
public native void unbind(Process process);
/** Immediately change the host on which all processes are running
else if (!java_context->bound) {
java_context->bound = 1;
smx_process_t process = SIMIX_process_self();
- (*global_env)->SetLongField(global_env, java_context->jprocess, jprocess_field_Process_bind, (jlong)process);
+ (*global_env)->SetLongField(global_env, java_context->jprocess,
+ jprocess_field_Process_bind,
+ (intptr_t)process);
}
next_coroutine = java_context->jcoroutine;
else if (!java_context->bound) {
java_context->bound = 1;
smx_process_t process = SIMIX_process_self();
- (*global_env)->SetLongField(global_env, java_context->jprocess, jprocess_field_Process_bind, (jlong)process);
+ (*global_env)->SetLongField(global_env, java_context->jprocess,
+ jprocess_field_Process_bind, (intptr_t)process);
}
(*global_env)->CallStaticVoidMethod(global_env, coclass, coroutine_yieldTo, java_context->jcoroutine);
}
typedef struct s_smx_ctx_cojava {
s_smx_ctx_base_t super; /* Fields of super implementation */
- jobject jprocess; /* the java process instance binded with the msg process structure */
+ jobject jprocess; /* the java process instance bound with the msg process structure */
JNIEnv *jenv; /* jni interface pointer associated to this thread */
jobject jcoroutine; /* java coroutine object */
int bound:1;
}
else {
smx_process_t process = SIMIX_process_self();
- (*env)->SetLongField(env, context->jprocess, jprocess_field_Process_bind, (jlong)process);
+ (*env)->SetLongField(env, context->jprocess, jprocess_field_Process_bind,
+ (intptr_t)process);
}
xbt_assert((context->jprocess != NULL), "Process not created...");
//wait for the process to be able to begin
typedef struct s_smx_ctx_java {
s_smx_ctx_base_t super; /* Fields of super implementation */
- jobject jprocess; /* the java process instance binded with the msg process structure */
+ jobject jprocess; /* the java process instance bound with the msg process structure */
JNIEnv *jenv; /* jni interface pointer associated to this thread */
xbt_os_thread_t thread;
xbt_os_sem_t begin; /* this semaphore is used to schedule/yield the process */
return MSG_task_receive_ext(task, alias, -1, host);
}
+/** msg_task_usage
+ *\brief Deprecated function that used to receive a task from a mailbox from a specific host
+ *\brief at a given rate
+ *
+ * \param task a memory location for storing a #msg_task_t.
+ * \param alias name of the mailbox to receive the task from
+ * \param host a #msg_host_t host from where the task was sent
+ * \param rate limit the reception to rate bandwidth
+ *
+ * \return Returns
+ * #MSG_OK if the task was successfully received,
+ * #MSG_HOST_FAILURE, or #MSG_TRANSFER_FAILURE otherwise.
+ */
+msg_error_t
+MSG_task_receive_from_host_bounded(msg_task_t * task, const char *alias,
+ msg_host_t host, double rate)
+{
+ return MSG_task_receive_ext_bounded(task, alias, -1, host, rate);
+}
+
/** \ingroup msg_task_usage
* \brief Receives a task from a mailbox.
*
return MSG_task_receive_with_timeout(task, alias, -1);
}
+/** \ingroup msg_task_usage
+ * \brief Receives a task from a mailbox at a given rate.
+ *
+ * \param task a memory location for storing a #msg_task_t.
+ * \param alias name of the mailbox to receive the task from
+ * \param rate limit the reception to rate bandwidth
+ *
+ * \return Returns
+ * #MSG_OK if the task was successfully received,
+ * #MSG_HOST_FAILURE, or #MSG_TRANSFER_FAILURE otherwise.
+ */
+msg_error_t MSG_task_receive_bounded(msg_task_t * task, const char *alias, double rate)
+{
+ return MSG_task_receive_with_timeout_bounded(task, alias, -1, rate);
+}
+
/** \ingroup msg_task_usage
* \brief Receives a task from a mailbox with a given timeout.
*
return MSG_task_receive_ext(task, alias, timeout, NULL);
}
+/** \ingroup msg_task_usage
+ * \brief Receives a task from a mailbox with a given timeout and at a given rate.
+ *
+ * \param task a memory location for storing a #msg_task_t.
+ * \param alias name of the mailbox to receive the task from
+ * \param timeout is the maximum wait time for completion (if -1, this call is the same as #MSG_task_receive)
+ * \param rate limit the reception to rate bandwidth
+ *
+ * \return Returns
+ * #MSG_OK if the task was successfully received,
+ * #MSG_HOST_FAILURE, or #MSG_TRANSFER_FAILURE, or #MSG_TIMEOUT otherwise.
+ */
+msg_error_t
+MSG_task_receive_with_timeout_bounded(msg_task_t * task, const char *alias,
+ double timeout,double rate)
+{
+ return MSG_task_receive_ext_bounded(task, alias, timeout, NULL,rate);
+}
+
/** \ingroup msg_task_usage
* \brief Receives a task from a mailbox from a specific host with a given timeout.
*
return ret;
}
+/** \ingroup msg_task_usage
+ * \brief Receives a task from a mailbox from a specific host with a given timeout
+ * and at a given rate.
+ *
+ * \param task a memory location for storing a #msg_task_t.
+ * \param alias name of the mailbox to receive the task from
+ * \param timeout is the maximum wait time for completion (provide -1 for no timeout)
+ * \param host a #msg_host_t host from where the task was sent
+ * \param rate limit the reception to rate bandwidth
+ *
+ * \return Returns
+ * #MSG_OK if the task was successfully received,
+* #MSG_HOST_FAILURE, or #MSG_TRANSFER_FAILURE, or #MSG_TIMEOUT otherwise.
+ */
+msg_error_t
+MSG_task_receive_ext_bounded(msg_task_t * task, const char *alias, double timeout,
+ msg_host_t host, double rate)
+{
+ XBT_DEBUG
+ ("MSG_task_receive_ext: Trying to receive a message on mailbox '%s'",
+ alias);
+ return MSG_mailbox_get_task_ext_bounded(MSG_mailbox_get_by_alias(alias), task,
+ host, timeout, rate);
+}
+
/** \ingroup msg_task_usage
* \brief Sends a task on a mailbox.
*
return comm;
}
+/** \ingroup msg_task_usage
+ * \brief Starts listening for receiving a task from an asynchronous communication
+ * at a given rate.
+ *
+ * \param task a memory location for storing a #msg_task_t. has to be valid until the end of the communication.
+ * \param name of the mailbox to receive the task on
+ * \param rate limit the bandwidth to the given rate
+ * \return the msg_comm_t communication created
+ */
+msg_comm_t MSG_task_irecv_bounded(msg_task_t *task, const char *name, double rate)
+{
+
+
+ smx_rdv_t rdv = MSG_mailbox_get_by_alias(name);
+ simcall_comm_change_rate_first_action(rdv,rate);
+ /* FIXME: these functions are not traceable */
+
+ /* Sanity check */
+ xbt_assert(task, "Null pointer for the task storage");
+
+ if (*task)
+ XBT_CRITICAL
+ ("MSG_task_irecv() was asked to write in a non empty task struct.");
+
+ /* Try to receive it by calling SIMIX network layer */
+ msg_comm_t comm = xbt_new0(s_msg_comm_t, 1);
+ comm->task_sent = NULL;
+ comm->task_received = task;
+ comm->status = MSG_OK;
+ comm->s_comm = simcall_comm_irecv(rdv, task, NULL, NULL, NULL);
+
+ return comm;
+}
+
/** \ingroup msg_task_usage
* \brief Checks whether a communication is done, and if yes, finalizes it.
* \param comm the communication to test
return simcall_rdv_comm_count_by_host(mailbox, host);
}
+double MSG_set_rate_before_read(msg_mailbox_t mailbox, double newrate) {
+ return simcall_comm_change_rate_first_action(mailbox,newrate);
+}
+
msg_mailbox_t MSG_mailbox_get_by_alias(const char *alias)
{
MSG_RETURN(ret);
}
+
+
+/** \ingroup msg_mailbox_management
+ * \brief Get a task from a mailbox on a given host at a given rate
+ *
+ * \param mailbox The mailbox where the task was sent
+ * \param task a memory location for storing a #msg_task_t.
+ * \param host a #msg_host_t host from where the task was sent
+ * \param timeout a timeout
+ * \param rate a bandwidth rate
+
+ * \return Returns
+ * #MSG_OK if the task was successfully received,
+ * #MSG_HOST_FAILURE, or #MSG_TRANSFER_FAILURE otherwise.
+ */
+msg_error_t
+MSG_mailbox_get_task_ext_bounded(msg_mailbox_t mailbox, msg_task_t * task,
+ msg_host_t host, double timeout, double rate)
+{
+ MSG_set_rate_before_read(mailbox,rate);
+ MSG_RETURN(MSG_mailbox_get_task_ext(mailbox,task,host,timeout));
+}
+
+
msg_error_t
MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, msg_task_t task,
double timeout)
*/
void MSG_mailbox_free(void *mailbox);
+/* \brief MSG_set_rate_before_read - set a rate before receiving a task
+ *
+ * \param mailbox The mailbox to release.
+ * \param rate The new rate
+ */
+double MSG_set_rate_before_read(msg_mailbox_t mailbox, double rate);
+
/* \brief MSG_mailbox_get_by_alias - get a mailbox from its alias.
*
* The function MSG_mailbox_get_by_alias returns the mailbox associated with
/** @brief Removes the given process from the given VM, and kill it
* @ingroup msg_VMs
*
- * Will raise a not_found exception if the process were not binded to that VM
+ * Will raise a not_found exception if the process were not bound to that VM
*/
void MSG_vm_unbind(msg_vm_t vm, msg_process_t process) {
int pos = xbt_dynar_search(vm->processes,process);
}
+/**
+ * \ingroup simix_comm_management
+ */
+double simcall_comm_change_rate_first_action(smx_rdv_t rdv, double newrate)
+{
+ xbt_assert(rdv, "No rendez-vous point defined for change_rate_first_action");
+
+ smx_action_t action;
+ xbt_fifo_item_t item;
+
+ item = xbt_fifo_get_first_item(rdv->comm_fifo);
+ if (item != NULL) {
+ action = (smx_action_t) xbt_fifo_get_item_content(item);
+ if (action->comm.rate > newrate) {
+ action->comm.rate = newrate;
+ return newrate;
+ } else
+ return action->comm.rate;
+ } else
+ return -1.0;
+}
+
+
/**
* \ingroup simix_comm_management
*/
}
}
- //let's get routes
- xbt_dict_cursor_t cursor1 = NULL, cursor2 = NULL;
- container_t child1, child2;
- const char *child1_name, *child2_name;
- xbt_dict_foreach(container->children, cursor1, child1_name, child1) {
- //if child1 is not a link, a smpi node, a msg process, a msg vm or a msg task
- if (child1->kind == INSTR_LINK || child1->kind == INSTR_SMPI || child1->kind == INSTR_MSG_PROCESS || child1->kind == INSTR_MSG_VM || child1->kind == INSTR_MSG_TASK) continue;
-
- xbt_dict_foreach(container->children, cursor2, child2_name, child2) {
- //if child2 is not a link, a smpi node, a msg process, a msg vm or a msg task
- if (child2->kind == INSTR_LINK || child2->kind == INSTR_SMPI || child2->kind == INSTR_MSG_PROCESS || child2->kind == INSTR_MSG_VM || child2->kind == INSTR_MSG_TASK) continue;
-
- //if child1 is not child2
- if (strcmp (child1_name, child2_name) == 0) continue;
-
- //get the route
- sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t,1);
- route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t),NULL);
- rc->get_route_and_latency(rc, child1->net_elm, child2->net_elm,
- route, NULL);
-
- //user might want to extract a graph using routes with only one link
- //see --cfg=tracing/onelink_only:1 or --help-tracing for details
- if (TRACE_onelink_only() && xbt_dynar_length (route->link_list) > 1){
- generic_free_route(route);
- continue;
- }
+ {
+ xbt_graph_t graph = xbt_graph_new_graph (0, NULL);
+ xbt_dict_t nodes = xbt_dict_new_homogeneous(NULL);
+ xbt_dict_t edges = xbt_dict_new_homogeneous(NULL);
+ xbt_edge_t edge = NULL;
- //traverse the route connecting the containers
- unsigned int cpt;
- void *link;
- container_t current, previous;
- if (route->gw_src){
- previous = PJ_container_get(route->gw_src->name);
- }else{
- previous = child1;
- }
+ xbt_dict_cursor_t cursor = NULL;
+ char *edge_name;
- xbt_dynar_foreach (route->link_list, cpt, link) {
- //FIXME (TODO): Should have a cleaner way to get the link name
- char *link_name = ((link_CM02_t)link)->lmm_resource.generic_resource.name;
- current = PJ_container_get(link_name);
- linkContainers(previous, current, filter);
- previous = current;
- }
- if (route->gw_dst){
- current = PJ_container_get(route->gw_dst->name);
- }else{
- current = child2;
- }
- linkContainers(previous, current, filter);
- generic_free_route(route);
+ rc->get_graph(graph,nodes,edges,rc);
+ xbt_dict_foreach(edges,cursor,edge_name,edge) {
+ linkContainers(PJ_container_get(edge->src->data), PJ_container_get(edge->dst->data), filter);
}
+ xbt_dict_free (&nodes);
+ xbt_dict_free (&edges);
+ xbt_graph_free_graph(graph,xbt_free, xbt_free, NULL);
}
+
}
/*
#define GRAPHICATOR_SUPPORT_FUNCTIONS
-static xbt_node_t new_xbt_graph_node (xbt_graph_t graph, const char *name, xbt_dict_t nodes)
-{
- xbt_node_t ret = xbt_dict_get_or_null (nodes, name);
- if (ret) return ret;
-
- ret = xbt_graph_new_node (graph, xbt_strdup(name));
- xbt_dict_set (nodes, name, ret, NULL);
- return ret;
-}
-
-static xbt_edge_t new_xbt_graph_edge (xbt_graph_t graph, xbt_node_t s, xbt_node_t d, xbt_dict_t edges)
-{
- xbt_edge_t ret;
-
- const char *sn = instr_node_name (s);
- const char *dn = instr_node_name (d);
- int len = strlen(sn)+strlen(dn)+1;
- char *name = (char*)xbt_malloc(len * sizeof(char));
-
-
- snprintf (name, len, "%s%s", sn, dn);
- ret = xbt_dict_get_or_null (edges, name);
- if (ret == NULL){
- snprintf (name, len, "%s%s", dn, sn);
- ret = xbt_dict_get_or_null (edges, name);
- }
-
- if (ret == NULL){
- ret = xbt_graph_new_edge(graph, s, d, NULL);
- xbt_dict_set (edges, name, ret, NULL);
- }
- free (name);
- return ret;
-}
-
static void recursiveXBTGraphExtraction (xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges,
AS_t rc, container_t container)
{
}
}
- //let's get routes
- xbt_dict_cursor_t cursor1 = NULL, cursor2 = NULL;
- container_t child1, child2;
- const char *child1_name, *child2_name;
- xbt_dict_foreach(container->children, cursor1, child1_name, child1) {
- //if child1 is not a link, a smpi node, a msg process, a msg vm or a msg task
- if (child1->kind == INSTR_LINK || child1->kind == INSTR_SMPI || child1->kind == INSTR_MSG_PROCESS || child1->kind == INSTR_MSG_VM || child1->kind == INSTR_MSG_TASK) continue;
-
- xbt_dict_foreach(container->children, cursor2, child2_name, child2) {
- //if child2 is not a link, a smpi node, a msg process or a msg task
- if (child2->kind == INSTR_LINK || child2->kind == INSTR_SMPI || child2->kind == INSTR_MSG_PROCESS || child2->kind == INSTR_MSG_VM || child2->kind == INSTR_MSG_TASK) continue;
-
- //if child1 is not child2
- if (strcmp (child1_name, child2_name) == 0) continue;
-
- //get the route
- sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t,1);
- route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t),NULL);
- rc->get_route_and_latency(rc, child1->net_elm, child2->net_elm,
- route, NULL);
-
- //user might want to extract a graph using routes with only one link
- //see --cfg=tracing/onelink_only:1 or --help-tracing for details
- if (TRACE_onelink_only() && xbt_dynar_length (route->link_list) > 1) continue;
-
- //traverse the route connecting the containers
- unsigned int cpt;
- void *link;
- xbt_node_t current, previous;
- if (route->gw_src){
- previous = new_xbt_graph_node(graph, route->gw_src->name, nodes);
- }else{
- previous = new_xbt_graph_node(graph, child1_name, nodes);
- }
-
- xbt_dynar_foreach (route->link_list, cpt, link) {
- char *link_name = ((link_CM02_t)link)->lmm_resource.generic_resource.name;
- current = new_xbt_graph_node(graph, link_name, nodes);
- new_xbt_graph_edge (graph, previous, current, edges);
- //previous -> current
- previous = current;
- }
- if (route->gw_dst){
- current = new_xbt_graph_node(graph, route->gw_dst->name, nodes);
- }else{
- current = new_xbt_graph_node(graph, child2_name, nodes);
- }
- new_xbt_graph_edge (graph, previous, current, edges);
- generic_free_route(route);
- }
- }
-
+ rc->get_graph(graph,nodes,edges,rc);
}
xbt_graph_t instr_routing_platform_graph (void)
void (*get_route_and_latency) (AS_t as, sg_routing_edge_t src, sg_routing_edge_t dst, sg_platf_route_cbarg_t into, double *latency);
xbt_dynar_t(*get_onelink_routes) (AS_t as);
+ void (*get_graph) (xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges, AS_t rc);
sg_platf_route_cbarg_t(*get_bypass_route) (AS_t as, sg_routing_edge_t src, sg_routing_edge_t dst, double *lat);
void (*finalize) (AS_t as);
XBT_PUBLIC(void) routing_get_route_and_latency(sg_routing_edge_t src, sg_routing_edge_t dst,
xbt_dynar_t * route, double *latency);
+XBT_PUBLIC(void) generic_get_graph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges, AS_t rc);
/**
* Resource protected methods
*/
bprintf("%s%s_router%s", cluster->prefix, cluster->id,
cluster->suffix);
sg_platf_new_router(&router);
+ ((as_cluster_t)current_routing)->router = xbt_lib_get_or_null(as_router_lib, router.id, ROUTING_ASR_LEVEL);
free(newid);
//Make the backbone
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "surf_routing_private.h"
+#include "xbt/graph.h"
/* Global vars */
/* Business methods */
static void cluster_get_route_and_latency(AS_t as,
- sg_routing_edge_t src, sg_routing_edge_t dst,
- sg_platf_route_cbarg_t route, double *lat) {
-
- s_surf_parsing_link_up_down_t info;
- XBT_DEBUG("cluster_get_route_and_latency from '%s'[%d] to '%s'[%d]",
- src->name,src->id,
- dst->name,dst->id);
-
- if(src->rc_type != SURF_NETWORK_ELEMENT_ROUTER){ // No specific link for router
- info = xbt_dynar_get_as(as->link_up_down_list,src->id,s_surf_parsing_link_up_down_t);
- if(info.link_up) { // link up
- xbt_dynar_push_as(route->link_list,void*,info.link_up);
- if (lat)
- *lat += surf_network_model->extension.network.get_link_latency(info.link_up);
- }
+ sg_routing_edge_t src,
+ sg_routing_edge_t dst,
+ sg_platf_route_cbarg_t route,
+ double *lat)
+{
+
+ s_surf_parsing_link_up_down_t info;
+ XBT_DEBUG("cluster_get_route_and_latency from '%s'[%d] to '%s'[%d]",
+ src->name, src->id, dst->name, dst->id);
+
+ if (src->rc_type != SURF_NETWORK_ELEMENT_ROUTER) { // No specific link for router
+ info =
+ xbt_dynar_get_as(as->link_up_down_list, src->id,
+ s_surf_parsing_link_up_down_t);
+ if (info.link_up) { // link up
+ xbt_dynar_push_as(route->link_list, void *, info.link_up);
+ if (lat)
+ *lat +=
+ surf_network_model->extension.network.get_link_latency(info.
+ link_up);
}
+ }
+
+ if (((as_cluster_t) as)->backbone) {
+ xbt_dynar_push_as(route->link_list, void *, ((as_cluster_t) as)->backbone);
+ if (lat)
+ *lat +=
+ surf_network_model->extension.network.
+ get_link_latency(((as_cluster_t) as)->backbone);
+ }
- if ( ((as_cluster_t)as)->backbone ) {
- xbt_dynar_push_as(route->link_list,void*, ((as_cluster_t)as)->backbone) ;
+ if (dst->rc_type != SURF_NETWORK_ELEMENT_ROUTER) { // No specific link for router
+ info =
+ xbt_dynar_get_as(as->link_up_down_list, dst->id,
+ s_surf_parsing_link_up_down_t);
+ if (info.link_down) { // link down
+ xbt_dynar_push_as(route->link_list, void *, info.link_down);
if (lat)
- *lat += surf_network_model->extension.network.get_link_latency(((as_cluster_t)as)->backbone);
+ *lat +=
+ surf_network_model->extension.network.get_link_latency(info.
+ link_down);
+ }
+ }
+}
+
+static void cluster_get_graph(xbt_graph_t graph, xbt_dict_t nodes,
+ xbt_dict_t edges, AS_t rc)
+{
+ int isrc;
+ int table_size = xbt_dynar_length(rc->index_network_elm);
+
+ sg_routing_edge_t src;
+ xbt_node_t current, previous, backboneNode = NULL, routerNode;
+ s_surf_parsing_link_up_down_t info;
+
+ xbt_assert(((as_cluster_t) rc)->router,"Malformed cluster");
+
+ /* create the router */
+ char *link_name =
+ ((sg_routing_edge_t) ((as_cluster_t) rc)->router)->name;
+ routerNode = new_xbt_graph_node(graph, link_name, nodes);
+
+ if(((as_cluster_t) rc)->backbone) {
+ char *link_nameR =
+ ((surf_resource_t) ((as_cluster_t) rc)->backbone)->name;
+ backboneNode = new_xbt_graph_node(graph, link_nameR, nodes);
+
+ new_xbt_graph_edge(graph, routerNode, backboneNode, edges);
+ }
+
+ for (isrc = 0; isrc < table_size; isrc++) {
+ src = xbt_dynar_get_as(rc->index_network_elm, isrc, sg_routing_edge_t);
+
+ if (src->rc_type != SURF_NETWORK_ELEMENT_ROUTER) {
+ previous = new_xbt_graph_node(graph, src->name, nodes);
+
+ info = xbt_dynar_get_as(rc->link_up_down_list, src->id,
+ s_surf_parsing_link_up_down_t);
+
+ if (info.link_up) { // link up
+
+ char *link_name = ((surf_resource_t) info.link_up)->name;
+ current = new_xbt_graph_node(graph, link_name, nodes);
+ new_xbt_graph_edge(graph, previous, current, edges);
+
+ if (((as_cluster_t) rc)->backbone) {
+ new_xbt_graph_edge(graph, current, backboneNode, edges);
+ } else {
+ new_xbt_graph_edge(graph, current, routerNode, edges);
+ }
+
+ }
+
+ if (info.link_down) { // link down
+ char *link_name = ((surf_resource_t) info.link_down)->name;
+ current = new_xbt_graph_node(graph, link_name, nodes);
+ new_xbt_graph_edge(graph, previous, current, edges);
+
+ if (((as_cluster_t) rc)->backbone) {
+ new_xbt_graph_edge(graph, current, backboneNode, edges);
+ } else {
+ new_xbt_graph_edge(graph, current, routerNode, edges);
+ }
+
+ }
+/*
+ if (((as_cluster_t) rc)->backbone) {
+ char *link_name =
+ ((surf_resource_t) ((as_cluster_t) rc)->backbone)->name;
+
+ current = new_xbt_graph_node(graph, link_name, nodes);
+ new_xbt_graph_edge(graph, previous, current, edges);
+ previous = current;
+
+ revCurrent = new_xbt_graph_node(graph, link_name, nodes);
+ new_xbt_graph_edge(graph, revCurrent, revPrevious, edges);
+ revPrevious = revCurrent;
+ } else {
+ info = xbt_dynar_get_as(rc->link_up_down_list, dst->id,
+ s_surf_parsing_link_up_down_t);
+
+ if (info.link_up) { // link up
+ char *link_name = ((surf_resource_t) info.link_up)->name;
+ current = new_xbt_graph_node(graph, link_name, nodes);
+ new_xbt_graph_edge(graph, previous, current, edges);
+ previous = current;
+ } else if (info.link_down) { // link down
+ char *link_name = ((surf_resource_t) info.link_down)->name;
+ revCurrent = new_xbt_graph_node(graph, link_name, nodes);
+ new_xbt_graph_edge(graph, revCurrent, revPrevious, edges);
+ revPrevious = revCurrent;
+ }
+ }
+*/
}
+ }
+/*
+ if(rc->)
+ for (isrc = 0; isrc < table_size; isrc++) {
+ src = xbt_dynar_get_as(rc->index_network_elm, isrc, sg_routing_edge_t);
+
+ previous = new_xbt_graph_node(graph, src->name, nodes);
+ revPrevious = new_xbt_graph_node(graph, src->name, nodes);
+
+ for (idst = isrc + 1; idst < table_size; idst++) {
+ dst = xbt_dynar_get_as(rc->index_network_elm, idst, sg_routing_edge_t);
+
+ s_surf_parsing_link_up_down_t info;
+
+ if (src->rc_type != SURF_NETWORK_ELEMENT_ROUTER) { // No specific link for router
+ info =
+ xbt_dynar_get_as(rc->link_up_down_list, src->id,
+ s_surf_parsing_link_up_down_t);
- if(dst->rc_type != SURF_NETWORK_ELEMENT_ROUTER){ // No specific link for router
- info = xbt_dynar_get_as(as->link_up_down_list,dst->id,s_surf_parsing_link_up_down_t);
- if(info.link_down) { // link down
- xbt_dynar_push_as(route->link_list,void*,info.link_down);
- if (lat)
- *lat += surf_network_model->extension.network.get_link_latency(info.link_down);
+ if (info.link_up) { // link up
+ char *link_name = ((surf_resource_t) info.link_up)->name;
+ current = new_xbt_graph_node(graph, link_name, nodes);
+ new_xbt_graph_edge(graph, previous, current, edges);
+ previous = current;
+ } else if (info.link_down) { // link down
+ char *link_name = ((surf_resource_t) info.link_down)->name;
+ revCurrent = new_xbt_graph_node(graph, link_name, nodes);
+ new_xbt_graph_edge(graph, revCurrent, revPrevious, edges);
+ revPrevious = revCurrent;
+ }
}
+
+
+
+ if (((as_cluster_t) rc)->backbone) {
+ char *link_name =
+ ((surf_resource_t) ((as_cluster_t) rc)->backbone)->name;
+
+ current = new_xbt_graph_node(graph, link_name, nodes);
+ new_xbt_graph_edge(graph, previous, current, edges);
+ previous = current;
+
+ revCurrent = new_xbt_graph_node(graph, link_name, nodes);
+ new_xbt_graph_edge(graph, revCurrent, revPrevious, edges);
+ revPrevious = revCurrent;
+ }
+
+ if (dst->rc_type != SURF_NETWORK_ELEMENT_ROUTER) { // No specific link for router
+ info =
+ xbt_dynar_get_as(rc->link_up_down_list, dst->id,
+ s_surf_parsing_link_up_down_t);
+
+ if (info.link_up) { // link up
+ char *link_name = ((surf_resource_t) info.link_up)->name;
+ current = new_xbt_graph_node(graph, link_name, nodes);
+ new_xbt_graph_edge(graph, previous, current, edges);
+ previous = current;
+ } else if (info.link_down) { // link down
+ char *link_name = ((surf_resource_t) info.link_down)->name;
+ revCurrent = new_xbt_graph_node(graph, link_name, nodes);
+ new_xbt_graph_edge(graph, revCurrent, revPrevious, edges);
+ revPrevious = revCurrent;
+ }
+ }
+
+ }
}
+*/
}
-static void model_cluster_finalize(AS_t as) {
+static void model_cluster_finalize(AS_t as)
+{
model_none_finalize(as);
}
AS_t result = model_none_create_sized(sizeof(s_as_cluster_t));
result->get_route_and_latency = cluster_get_route_and_latency;
result->finalize = model_cluster_finalize;
+ result->get_graph = cluster_get_graph;
result->parse_AS = cluster_parse_AS;
result->parse_PU = cluster_parse_PU;
if (!found) {
sg_platf_route_cbarg_t e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
e_route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL);
- xbt_dynar_push(e_route->link_list,
- &routing_platf->loopback);
+ xbt_dynar_push(e_route->link_list, &routing_platf->loopback);
xbt_graph_new_edge(as->route_graph, node, node, e_route);
}
}
new_component->generic_routing.get_route_and_latency = dijkstra_get_route_and_latency;
new_component->generic_routing.get_onelink_routes =
dijkstra_get_onelink_routes;
+ new_component->generic_routing.get_graph = generic_get_graph;
new_component->generic_routing.finalize = dijkstra_finalize;
new_component->cached = cached;
new_component->generic_routing.get_route_and_latency = floyd_get_route_and_latency;
new_component->generic_routing.get_onelink_routes =
floyd_get_onelink_routes;
+ new_component->generic_routing.get_graph = generic_get_graph;
new_component->generic_routing.finalize = floyd_finalize;
return (AS_t)new_component;
}
new_component->generic_routing.parse_ASroute = model_full_set_route;
new_component->generic_routing.get_route_and_latency =
full_get_route_and_latency;
+ new_component->generic_routing.get_graph = generic_get_graph;
+
new_component->generic_routing.get_onelink_routes = full_get_onelink_routes;
new_component->generic_routing.finalize = full_finalize;
#include "surf_routing_private.h"
#include "surf/surf_routing.h"
#include "surf/surfxml_parse_values.h"
+#include "xbt/graph.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_routing_generic, surf_route, "Generic implementation of the surf routing");
return NULL;
}
-sg_platf_route_cbarg_t generic_get_bypassroute(AS_t rc, sg_routing_edge_t src, sg_routing_edge_t dst, double *lat)
+static const char *instr_node_name(xbt_node_t node)
+{
+ void *data = xbt_graph_node_get_data(node);
+ char *str = (char *) data;
+ return str;
+}
+
+xbt_node_t new_xbt_graph_node(xbt_graph_t graph, const char *name,
+ xbt_dict_t nodes)
+{
+ xbt_node_t ret = xbt_dict_get_or_null(nodes, name);
+ if (ret)
+ return ret;
+
+ ret = xbt_graph_new_node(graph, xbt_strdup(name));
+ xbt_dict_set(nodes, name, ret, NULL);
+ return ret;
+}
+
+xbt_edge_t new_xbt_graph_edge(xbt_graph_t graph, xbt_node_t s, xbt_node_t d,
+ xbt_dict_t edges)
+{
+ xbt_edge_t ret;
+
+ const char *sn = instr_node_name(s);
+ const char *dn = instr_node_name(d);
+ int len = strlen(sn) + strlen(dn) + 1;
+ char *name = (char *) xbt_malloc(len * sizeof(char));
+
+
+ snprintf(name, len, "%s%s", sn, dn);
+ ret = xbt_dict_get_or_null(edges, name);
+ if (ret == NULL) {
+ snprintf(name, len, "%s%s", dn, sn);
+ ret = xbt_dict_get_or_null(edges, name);
+ }
+
+ if (ret == NULL) {
+ ret = xbt_graph_new_edge(graph, s, d, NULL);
+ xbt_dict_set(edges, name, ret, NULL);
+ }
+ free(name);
+ return ret;
+}
+
+void generic_get_graph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges,
+ AS_t rc)
+{
+ int src, dst;
+ int table_size = xbt_dynar_length(rc->index_network_elm);
+
+ sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
+ route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL);
+
+ for (src = 0; src < table_size; src++) {
+ sg_routing_edge_t my_src =
+ xbt_dynar_get_as(rc->index_network_elm, src, sg_routing_edge_t);
+ for (dst = 0; dst < table_size; dst++) {
+ if (src == dst)
+ continue;
+ sg_routing_edge_t my_dst =
+ xbt_dynar_get_as(rc->index_network_elm, dst, sg_routing_edge_t);
+
+ rc->get_route_and_latency(rc, my_src, my_dst, route, NULL);
+
+ if (route) {
+ unsigned int cpt;
+ void *link;
+
+ xbt_node_t current, previous;
+
+ if (route->gw_src) {
+ previous = new_xbt_graph_node(graph, route->gw_src->name, nodes);
+ } else {
+ previous = new_xbt_graph_node(graph, my_src->name, nodes);
+ }
+
+ xbt_dynar_foreach(route->link_list, cpt, link) {
+ char *link_name = ((surf_resource_t) link)->name;
+ current = new_xbt_graph_node(graph, link_name, nodes);
+ new_xbt_graph_edge(graph, previous, current, edges);
+ previous = current;
+ }
+
+ if (route->gw_dst) {
+ current = new_xbt_graph_node(graph, route->gw_dst->name, nodes);
+ } else {
+ current = new_xbt_graph_node(graph, my_dst->name, nodes);
+ }
+ new_xbt_graph_edge(graph, previous, current, edges);
+
+ }
+ }
+ }
+}
+
+sg_platf_route_cbarg_t generic_get_bypassroute(AS_t rc, sg_routing_edge_t src,
+ sg_routing_edge_t dst,
+ double *lat)
{
// If never set a bypass route return NULL without any further computations
- XBT_DEBUG("generic_get_bypassroute from %s to %s",src->name,dst->name);
- if(no_bypassroute_declared)
+ XBT_DEBUG("generic_get_bypassroute from %s to %s", src->name, dst->name);
+ if (no_bypassroute_declared)
return NULL;
sg_platf_route_cbarg_t e_route_bypass = NULL;
*lat = 0.0;
}
+static void none_get_graph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges, AS_t rc)
+{
+ XBT_INFO("No routing no graph");
+}
+
static sg_platf_route_cbarg_t none_get_bypass_route(AS_t rc,
sg_routing_edge_t src,
sg_routing_edge_t dst, double *lat) {
new_component->get_onelink_routes = none_get_onelink_routes;
new_component->get_bypass_route = none_get_bypass_route;
new_component->finalize = model_none_finalize;
+ new_component->get_graph = none_get_graph;
new_component->routing_sons = xbt_dict_new_homogeneous(NULL);
new_component->index_network_elm = xbt_dynar_new(sizeof(char*),NULL);
void generic_src_dst_check(AS_t rc, sg_routing_edge_t src,
sg_routing_edge_t dst);
-
/* ************************************************************************** */
/* *************************** FLOYD ROUTING ******************************** */
AS_t model_floyd_create(void); /* create structures for floyd routing model */
typedef struct {
s_as_t generic_routing;
void *backbone;
+ sg_routing_edge_t router;
} s_as_cluster_t, *as_cluster_t;
AS_t model_cluster_create(void); /* create structures for cluster routing model */
void model_full_end(AS_t as); /* finalize the creation of full routing model */
void model_full_set_route( /* Set the route and ASroute between src and dst */
AS_t rc, sg_platf_route_cbarg_t route);
+/* ************************************************************************** */
+/* ************************* GRAPH EXPORTING FUNCTIONS ********************** */
+xbt_node_t new_xbt_graph_node (xbt_graph_t graph, const char *name, xbt_dict_t nodes);
+xbt_edge_t new_xbt_graph_edge (xbt_graph_t graph, xbt_node_t s, xbt_node_t d, xbt_dict_t edges);
#endif /* _SURF_SURF_ROUTING_PRIVATE_H */
static int model_rulebased_parse_PU(AS_t rc, sg_routing_edge_t elm)
{
AS_rulebased_t routing = (AS_rulebased_t) rc;
- xbt_dynar_push(routing->generic_routing.index_network_elm,(void *)elm);
+ xbt_dynar_push(routing->generic_routing.index_network_elm,&elm);
return -1;
}
static int model_rulebased_parse_AS(AS_t rc, sg_routing_edge_t elm)
{
AS_rulebased_t routing = (AS_rulebased_t) rc;
- xbt_dynar_push(routing->generic_routing.index_network_elm,(void *)elm);
+ xbt_dynar_push(routing->generic_routing.index_network_elm,&elm);
return -1;
}
new_component->generic_routing.get_onelink_routes = rulebased_get_onelink_routes;
new_component->generic_routing.get_route_and_latency = rulebased_get_route_and_latency;
new_component->generic_routing.get_bypass_route = rulebased_get_bypass_route;
+ new_component->generic_routing.get_graph = generic_get_graph;
new_component->generic_routing.finalize = rulebased_finalize;
/* initialization of internal structures */
new_component->list_route = xbt_dynar_new(sizeof(rule_route_t), &rule_route_free);
AS_t new_component = model_rulebased_create();
new_component->get_route_and_latency = vivaldi_get_route_and_latency;
new_component->parse_PU = vivaldi_parse_PU;
+ new_component->get_graph = generic_get_graph;
return new_component;
}
xbt_dynar_free(&surf_parsed_filename_stack);
free(surf_parsed_filename);
+ surf_parsed_filename = NULL;
if (surf_file_to_parse) {
surf_parse__delete_buffer(surf_input_buffer);
/** @brief Returns the position of the element in the dynar
*
+ * Beware that if your dynar contains pointed values (such as strings) instead
+ * of scalar, this function compares the pointer value, not what's pointed. The only
+ * solution to search for a pointed value is then to write the foreach loop yourself:
+ * \code
+ * signed int position = -1;
+ * xbt_dynar_foreach(dynar, iter, elem) {
+ * if (!memcmp(elem, searched_element, sizeof(*elem))) {
+ * position = iter;
+ * break;
+ * }
+ * }
+ * \endcode
+ *
* Raises not_found_error if not found. If you have less than 2 millions elements,
* you probably want to use #xbt_dynar_search_or_negative() instead, so that you
* don't have to TRY/CATCH on element not found.
/** @brief Returns the position of the element in the dynar (or -1 if not found)
*
+ * Beware that if your dynar contains pointed values (such as
+ * strings) instead of scalar, this function is probably not what you
+ * want. Check the documentation of xbt_dynar_search() for more info.
+ *
* Note that usually, the dynar indices are unsigned integers. If you have more
* than 2 million elements in your dynar, this very function will not work (but the other will).
*/
return -1;
}
-/** @brief Returns a boolean indicating whether the element is part of the dynar */
+/** @brief Returns a boolean indicating whether the element is part of the dynar
+ *
+ * Beware that if your dynar contains pointed values (such as
+ * strings) instead of scalar, this function is probably not what you
+ * want. Check the documentation of xbt_dynar_search() for more info.
+ */
int xbt_dynar_member(xbt_dynar_t const dynar, void *const elem)
{
#
# If there was a Unix standard interface to ps, we could check for orphaned
# processes...
-if ps -fwu $LOGNAME > /dev/null 2>&1 ; then
+if ps --version | grep procps > /dev/null 2>&1 ; then
+ # This is a try to be a better choice than ps -u because it
+ # restricts the list of processes to those of the current session.
+ # The options are known to work with the ps command from the procps
+ # package.
+ SESSION=`ps -o sess= $$`
+ PSPGM="ps -o pid,tname,command -s $SESSION"
+elif ps -fwu $LOGNAME > /dev/null 2>&1 ; then
# This is a better choice than ps aux because it restricts the list of
# processes to those of the running user. The w is needed on some
# systems to get a long output for the command