"\tExample: %s ../msg_platform.xml chord.xml\n",
argv[0], argv[0]);
char** options = &argv[1];
- while (!strncmp(options[0], "-", 1)) {
+ while (not strncmp(options[0], "-", 1)) {
unsigned int length = strlen("-nb_bits=");
- if (!strncmp(options[0], "-nb_bits=", length) && strlen(options[0]) > length) {
+ if (not strncmp(options[0], "-nb_bits=", length) && strlen(options[0]) > length) {
nb_bits = xbt_str_parse_int(options[0] + length, "Invalid nb_bits parameter: %s");
XBT_DEBUG("Set nb_bits to %d", nb_bits);
} else {
length = strlen("-timeout=");
- if (!strncmp(options[0], "-timeout=", length) && strlen(options[0]) > length) {
+ if (not strncmp(options[0], "-timeout=", length) && strlen(options[0]) > length) {
timeout = xbt_str_parse_int(options[0] + length, "Invalid timeout parameter: %s");
XBT_DEBUG("Set timeout to %d", timeout);
} else {
{
msg_netzone_t as = MSG_zone_get_root();
jobject jas = jnetzone_new_instance(env);
- if (!jas) {
+ if (not jas) {
jxbt_throw_jni(env, "java As instantiation failed");
return nullptr;
}
jas = jnetzone_ref(env, jas);
- if (!jas) {
+ if (not jas) {
jxbt_throw_jni(env, "new global ref allocation failed");
return nullptr;
}
jclass cls = env->FindClass("org/simgrid/msg/As");
- if (!cls)
+ if (not cls)
return nullptr;
jtable = env->NewObjectArray(static_cast<jsize>(self_as->children()->size()), cls, nullptr);
- if (!jtable) {
+ if (not jtable) {
jxbt_throw_jni(env, "Hosts table allocation failed");
return nullptr;
}
for (auto tmp_as : *self_as->children()) {
jobject tmp_jas = jnetzone_new_instance(env);
- if (!tmp_jas) {
+ if (not tmp_jas) {
jxbt_throw_jni(env, "java As instantiation failed");
return nullptr;
}
tmp_jas = jnetzone_ref(env, tmp_jas);
- if (!tmp_jas) {
+ if (not tmp_jas) {
jxbt_throw_jni(env, "new global ref allocation failed");
return nullptr;
}
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_As_getProperty(JNIEnv *env, jobject jas, jobject jname) {
simgrid::s4u::NetZone* as = jnetzone_get_native(env, jas);
- if (!as) {
+ if (not as) {
jxbt_throw_notbound(env, "as", jas);
return nullptr;
}
const char *name = env->GetStringUTFChars(static_cast<jstring>(jname), 0);
const char* property = MSG_zone_get_property_value(as, name);
- if (!property) {
+ if (not property) {
return nullptr;
}
simgrid::s4u::NetZone* as = jnetzone_get_native(env, jas);
jclass cls = jxbt_get_class(env, "org/simgrid/msg/Host");
- if (!cls)
+ if (not cls)
return nullptr;
std::vector<sg_host_t> table;
jtable = env->NewObjectArray(static_cast<jsize>(table.size()), cls, nullptr);
- if (!jtable) {
+ if (not jtable) {
jxbt_throw_jni(env, "Hosts table allocation failed");
return nullptr;
}
int index = 0;
for (auto host : table) {
jhost = static_cast<jobject>(host->extension(JAVA_HOST_LEVEL));
- if (!jhost) {
+ if (not jhost) {
jname = env->NewStringUTF(host->cname());
jhost = Java_org_simgrid_msg_Host_getByName(env, cls, jname);
return JNI_TRUE;
}
- if (!comm) {
+ if (not comm) {
jxbt_throw_null(env, bprintf("comm is null"));
return JNI_FALSE;
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Comm_waitCompletion(JNIEnv *env, jobject jcomm, jdouble timeout) {
msg_comm_t comm = (msg_comm_t) (uintptr_t) env->GetLongField(jcomm, jcomm_field_Comm_bind);
- if (!comm) {
+ if (not comm) {
jxbt_throw_null(env, bprintf("comm is null"));
return;
}
break;
comms[i] = (msg_comm_t) (uintptr_t) env->GetLongField(jcomm, jcomm_field_Comm_bind);
- if (!comms[i]) {
+ if (not comms[i]) {
jxbt_throw_null(env, bprintf("comm at rank %d is null", i));
return nullptr;
}
{
int count;
msg_comm_t* comms = jarray_to_commArray(env, jcomms, &count);
- if (!comms)
+ if (not comms)
return;
MSG_comm_waitall(comms, count, static_cast<double>(timeout));
{
int count;
msg_comm_t* comms = jarray_to_commArray(env, jcomms, &count);
- if (!comms)
+ if (not comms)
return -1;
xbt_dynar_t dyn = xbt_dynar_new(sizeof(msg_comm_t),nullptr);
for (int i=0; i<count; i++) {
/* get the host by name (the hosts are created during the grid resolution) */
msg_host_t host = MSG_host_by_name(name);
- if (!host) { /* invalid name */
+ if (not host) { /* invalid name */
jxbt_throw_host_not_found(env, name);
env->ReleaseStringUTFChars(jname, name);
return nullptr;
}
env->ReleaseStringUTFChars(jname, name);
- if (!host->extension(JAVA_HOST_LEVEL)) { /* native host not associated yet with java host */
+ if (not host->extension(JAVA_HOST_LEVEL)) { /* native host not associated yet with java host */
/* Instantiate a new java host */
jobject jhost = jhost_new_instance(env);
- if (!jhost) {
+ if (not jhost) {
jxbt_throw_jni(env, "java host instantiation failed");
return nullptr;
}
/* get a global reference to the newly created host */
jhost = jhost_ref(env, jhost);
- if (!jhost) {
+ if (not jhost) {
jxbt_throw_jni(env, "new global ref allocation failed");
return nullptr;
}
msg_host_t host = MSG_host_self();
- if (!host->extension(JAVA_HOST_LEVEL)) {
+ if (not host->extension(JAVA_HOST_LEVEL)) {
/* the native host not yet associated with the java host instance */
/* instanciate a new java host instance */
jhost = jhost_new_instance(env);
- if (!jhost) {
+ if (not jhost) {
jxbt_throw_jni(env, "java host instantiation failed");
return nullptr;
}
/* get a global reference to the newly created host */
jhost = jhost_ref(env, jhost);
- if (!jhost) {
+ if (not jhost) {
jxbt_throw_jni(env, "global ref allocation failed");
return nullptr;
}
JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getSpeed(JNIEnv * env, jobject jhost) {
msg_host_t host = jhost_get_native(env, jhost);
- if (!host) {
+ if (not host) {
jxbt_throw_notbound(env, "host", jhost);
return -1;
}
JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getCoreNumber(JNIEnv * env, jobject jhost) {
msg_host_t host = jhost_get_native(env, jhost);
- if (!host) {
+ if (not host) {
jxbt_throw_notbound(env, "host", jhost);
return -1;
}
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_getProperty(JNIEnv *env, jobject jhost, jobject jname) {
msg_host_t host = jhost_get_native(env, jhost);
- if (!host) {
+ if (not host) {
jxbt_throw_notbound(env, "host", jhost);
return nullptr;
}
const char *name = env->GetStringUTFChars((jstring) jname, 0);
const char *property = MSG_host_get_property_value(host, name);
- if (!property) {
+ if (not property) {
return nullptr;
}
Java_org_simgrid_msg_Host_setProperty(JNIEnv *env, jobject jhost, jobject jname, jobject jvalue) {
msg_host_t host = jhost_get_native(env, jhost);
- if (!host) {
+ if (not host) {
jxbt_throw_notbound(env, "host", jhost);
return;
}
{
msg_host_t host = jhost_get_native(env, jhost);
- if (!host) {
+ if (not host) {
jxbt_throw_notbound(env, "host", jhost);
return 0;
}
jobject jstorage;
jstring jname;
- if (!host) {
+ if (not host) {
jxbt_throw_notbound(env, "host", jhost);
return 0;
}
jtable = env->NewObjectArray((jsize) count, cls, nullptr);
- if (!jtable) {
- jxbt_throw_jni(env, "Storages table allocation failed");
- return nullptr;
+ if (not jtable) {
+ jxbt_throw_jni(env, "Storages table allocation failed");
+ return nullptr;
}
xbt_dict_cursor_t cursor=nullptr;
{
msg_host_t host = jhost_get_native(env, jhost);
- if (!host) {
+ if (not host) {
jxbt_throw_notbound(env, "host", jhost);
return 0;
}
{
msg_host_t host = jhost_get_native(env, jhost);
- if (!host) {
+ if (not host) {
jxbt_throw_notbound(env, "host", jhost);
return 0;
}
int count = xbt_dynar_length(table);
jclass cls = jxbt_get_class(env, "org/simgrid/msg/Host");
- if (!cls)
+ if (not cls)
return nullptr;
jobjectArray jtable = env->NewObjectArray((jsize)count, cls, nullptr);
- if (!jtable) {
+ if (not jtable) {
jxbt_throw_jni(env, "Hosts table allocation failed");
return nullptr;
}
msg_host_t host = xbt_dynar_get_as(table, index, msg_host_t);
jobject jhost = static_cast<jobject>(host->extension(JAVA_HOST_LEVEL));
- if (!jhost) {
+ if (not jhost) {
jstring jname = env->NewStringUTF(host->cname());
jhost = Java_org_simgrid_msg_Host_getByName(env, cls_arg, jname);
}
{
msg_host_t host = jhost_get_native(env, jhost);
- if (!host) {
+ if (not host) {
jxbt_throw_notbound(env, "host", jhost);
return 0;
}
{
msg_process_t process = MSG_process_from_PID(pid);
- if (!process) {
+ if (not process) {
jxbt_throw_process_not_found(env, bprintf("PID = %d",static_cast<int>(pid)));
return nullptr;
}
jobject jprocess = jprocess_from_native(process);
- if (!jprocess) {
+ if (not jprocess) {
jxbt_throw_jni(env, "get process failed");
return nullptr;
}
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_getProperty(JNIEnv *env, jobject jprocess, jobject jname) {
msg_process_t process = jprocess_to_native(jprocess, env);
- if (!process) {
+ if (not process) {
jxbt_throw_notbound(env, "process", jprocess);
return nullptr;
}
const char *name = env->GetStringUTFChars((jstring)jname, 0);
const char *property = MSG_process_get_property_value(process, name);
- if (!property)
+ if (not property)
return nullptr;
jobject jproperty = env->NewStringUTF(property);
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_getCurrentProcess(JNIEnv * env, jclass cls)
{
jobject jprocess = jprocess_from_native(MSG_process_self());
- if (!jprocess)
+ if (not jprocess)
jxbt_throw_jni(env, xbt_strdup("SIMIX_process_get_jprocess() failed"));
return jprocess;
{
msg_process_t process = jprocess_to_native(jprocess, env);
- if (!process) {
+ if (not process) {
jxbt_throw_notbound(env, "process", jprocess);
return;
}
{
msg_process_t process = jprocess_to_native(jprocess, env);
- if (!process) {
+ if (not process) {
jxbt_throw_notbound(env, "process", jprocess);
return;
}
JNICALL Java_org_simgrid_msg_Process_setAutoRestart (JNIEnv *env, jobject jprocess, jboolean jauto_restart) {
msg_process_t process = jprocess_to_native(jprocess, env);
- if (!process) {
+ if (not process) {
jxbt_throw_notbound(env, "process", jprocess);
return;
}
msg_process_t process = jprocess_to_native(jprocess, env);
xbt_ex_t e;
- if (!process) {
+ if (not process) {
jxbt_throw_notbound(env, "process", jprocess);
return;
}
{
msg_process_t process = jprocess_to_native(jprocess, env);
- if (!process) {
+ if (not process) {
jxbt_throw_notbound(env, "process", jprocess);
return 0;
}
{
/* get the native instances from the java ones */
msg_process_t process = jprocess_to_native(jprocess, env);
- if (!process) {
+ if (not process) {
jxbt_throw_notbound(env, "process", jprocess);
return;
}
{
msg_process_t process = jprocess_to_native(jprocess, env);
- if (!process) {
+ if (not process) {
jxbt_throw_notbound(env, "process", jprocess);
return;
}
msg_host_t host = jhost_get_native(env, jhost);
- if (!host) {
+ if (not host) {
jxbt_throw_notbound(env, "host", jhost);
return;
}
RngStream jrngstream_to_native(JNIEnv *env, jobject jrngstream) {
RngStream rngstream = (RngStream)(intptr_t)env->GetLongField(jrngstream, jrngstream_bind);
- if (!rngstream) {
+ if (not rngstream) {
jxbt_throw_notbound(env, "rngstream", jrngstream);
return nullptr;
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_RngStream_resetStart(JNIEnv *env, jobject jrngstream) {
RngStream rngstream = jrngstream_to_native(env, jrngstream);
- if (!rngstream)
+ if (not rngstream)
return;
RngStream_ResetStartStream(rngstream);
JNIEXPORT void JNICALL Java_org_simgrid_msg_RngStream_resetStartSubstream(JNIEnv *env, jobject jrngstream) {
RngStream rngstream = jrngstream_to_native(env, jrngstream);
- if (!rngstream)
+ if (not rngstream)
return;
RngStream_ResetStartSubstream(rngstream);
JNIEXPORT void JNICALL Java_org_simgrid_msg_RngStream_resetNextSubstream(JNIEnv *env, jobject jrngstream) {
RngStream rngstream = jrngstream_to_native(env, jrngstream);
- if (!rngstream)
+ if (not rngstream)
return;
RngStream_ResetNextSubstream(rngstream);
JNIEXPORT void JNICALL Java_org_simgrid_msg_RngStream_setAntithetic(JNIEnv *env, jobject jrngstream, jboolean ja) {
RngStream rngstream = jrngstream_to_native(env, jrngstream);
- if (!rngstream)
+ if (not rngstream)
return;
if (ja == JNI_TRUE) {
env->GetIntArrayRegion(jseed, 0, 6, buffer);
RngStream rngstream = jrngstream_to_native(env, jrngstream);
- if (!rngstream)
+ if (not rngstream)
return JNI_FALSE;
// The C API expects unsigned long which are wider than int on LP64.
JNIEXPORT void JNICALL Java_org_simgrid_msg_RngStream_advanceState(JNIEnv *env, jobject jrngstream, jint e, jint g) {
RngStream rngstream = jrngstream_to_native(env, jrngstream);
- if (!rngstream)
+ if (not rngstream)
return;
RngStream_AdvanceState(rngstream, (long)e, (long)g);
JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_RngStream_randU01(JNIEnv *env, jobject jrngstream) {
RngStream rngstream = jrngstream_to_native(env, jrngstream);
- if (!rngstream)
+ if (not rngstream)
return 0;
return (jdouble)RngStream_RandU01(rngstream);
JNIEXPORT jint JNICALL Java_org_simgrid_msg_RngStream_randInt(JNIEnv *env, jobject jrngstream, jint i, jint j) {
RngStream rngstream = jrngstream_to_native(env, jrngstream);
- if (!rngstream)
+ if (not rngstream)
return 0;
return (jint)RngStream_RandInt(rngstream, (int)i, (int)j);
const char *name = env->GetStringUTFChars(jname, 0);
storage = MSG_storage_get_by_name(name);
- if (!storage) { /* invalid name */
+ if (not storage) { /* invalid name */
jxbt_throw_storage_not_found(env, name);
env->ReleaseStringUTFChars(jname, name);
return nullptr;
/* Instantiate a new java storage */
jstorage = jstorage_new_instance(env);
- if (!jstorage) {
+ if (not jstorage) {
jxbt_throw_jni(env, "java storage instantiation failed");
return nullptr;
}
/* get a global reference to the newly created storage */
jstorage = jstorage_ref(env, jstorage);
- if (!jstorage) {
+ if (not jstorage) {
jxbt_throw_jni(env, "new global ref allocation failed");
return nullptr;
}
JNIEXPORT jlong JNICALL Java_org_simgrid_msg_Storage_getSize(JNIEnv * env,jobject jstorage) {
msg_storage_t storage = jstorage_get_native(env, jstorage);
- if (!storage) {
+ if (not storage) {
jxbt_throw_notbound(env, "storage", jstorage);
return -1;
}
JNIEXPORT jlong JNICALL Java_org_simgrid_msg_Storage_getFreeSize(JNIEnv * env,jobject jstorage) {
msg_storage_t storage = jstorage_get_native(env, jstorage);
- if (!storage) {
+ if (not storage) {
jxbt_throw_notbound(env, "storage", jstorage);
return -1;
}
JNIEXPORT jlong JNICALL Java_org_simgrid_msg_Storage_getUsedSize(JNIEnv * env,jobject jstorage) {
msg_storage_t storage = jstorage_get_native(env, jstorage);
- if (!storage) {
+ if (not storage) {
jxbt_throw_notbound(env, "storage", jstorage);
return -1;
}
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getProperty(JNIEnv *env, jobject jstorage, jobject jname) {
msg_storage_t storage = jstorage_get_native(env, jstorage);
- if (!storage) {
+ if (not storage) {
jxbt_throw_notbound(env, "storage", jstorage);
return nullptr;
}
const char *name = env->GetStringUTFChars((jstring) jname, 0);
const char *property = MSG_storage_get_property_value(storage, name);
- if (!property) {
+ if (not property) {
return nullptr;
}
jobject jproperty = env->NewStringUTF(property);
Java_org_simgrid_msg_Storage_setProperty(JNIEnv *env, jobject jstorage, jobject jname, jobject jvalue) {
msg_storage_t storage = jstorage_get_native(env, jstorage);
- if (!storage) {
+ if (not storage) {
jxbt_throw_notbound(env, "storage", jstorage);
return;
}
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getHost(JNIEnv * env,jobject jstorage) {
msg_storage_t storage = jstorage_get_native(env, jstorage);
- if (!storage) {
+ if (not storage) {
jxbt_throw_notbound(env, "storage", jstorage);
return nullptr;
}
const char *host_name = MSG_storage_get_host(storage);
- if (!host_name) {
+ if (not host_name) {
return nullptr;
}
jobject jhost_name = env->NewStringUTF(host_name);
jclass cls = jxbt_get_class(env, "org/simgrid/msg/Storage");
- if (!cls) {
+ if (not cls) {
return nullptr;
}
jtable = env->NewObjectArray((jsize) count, cls, nullptr);
- if (!jtable) {
+ if (not jtable) {
jxbt_throw_jni(env, "Storages table allocation failed");
return nullptr;
}
{
msg_task_t ptask = jtask_to_native(jtask, env);
- if (!ptask) {
+ if (not ptask) {
jxbt_throw_notbound(env, "task", jtask);
return;
}
{
msg_task_t task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
jxbt_throw_notbound(env, "task", jtask);
return;
}
{
msg_task_t task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
jxbt_throw_notbound(env, "task", jtask);
return;
}
JNIEXPORT jstring JNICALL Java_org_simgrid_msg_Task_getName(JNIEnv * env, jobject jtask) {
msg_task_t task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
jxbt_throw_notbound(env, "task", jtask);
return nullptr;
}
msg_task_t task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
jxbt_throw_notbound(env, "task", jtask);
return nullptr;
}
msg_host_t host;
msg_task_t task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
jxbt_throw_notbound(env, "task", jtask);
return nullptr;
}
if (host == nullptr) {
return nullptr;
}
- if (!host->extension(JAVA_HOST_LEVEL)) {
+ if (not host->extension(JAVA_HOST_LEVEL)) {
jxbt_throw_jni(env, "MSG_task_get_source() failed");
return nullptr;
}
{
msg_task_t ptask = jtask_to_native(jtask, env);
- if (!ptask) {
+ if (not ptask) {
jxbt_throw_notbound(env, "task", jtask);
return -1;
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_setName(JNIEnv *env, jobject jtask, jobject jname) {
msg_task_t task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
jxbt_throw_notbound(env, "task", jtask);
return;
}
{
msg_task_t task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
jxbt_throw_notbound(env, "task", jtask);
return;
}
{
msg_task_t task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
jxbt_throw_notbound(env, "task", jtask);
return;
}
{
msg_task_t task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
jxbt_throw_notbound(env, "task", jtask);
return;
}
jdouble jtimeout,jdouble maxrate)
{
msg_task_t task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
jxbt_throw_notbound(env, "task", jtask);
return;
}
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_irecv(JNIEnv * env, jclass cls, jstring jmailbox) {
jclass comm_class = env->FindClass("org/simgrid/msg/Comm");
- if (!comm_class)
+ if (not comm_class)
return nullptr;
//pointer to store the task object pointer.
/* There should be a cache here */
jobject jcomm = env->NewObject(comm_class, jtask_method_Comm_constructor);
- if (!jcomm) {
+ if (not jcomm) {
jxbt_throw_jni(env, "Can't create a Comm object.");
return nullptr;
}
jdouble rate)
{
jclass comm_class = env->FindClass("org/simgrid/msg/Comm");
- if (!comm_class)
+ if (not comm_class)
return nullptr;
// pointer to store the task object pointer.
msg_task_t* task = xbt_new0(msg_task_t, 1);
jobject jcomm = env->NewObject(comm_class, jtask_method_Comm_constructor);
- if (!jcomm) {
+ if (not jcomm) {
jxbt_throw_jni(env, "Can't create a Comm object.");
return nullptr;
}
jclass comm_class = env->FindClass("org/simgrid/msg/Comm");
- if (!comm_class) return nullptr;
+ if (not comm_class)
+ return nullptr;
jobject jcomm = env->NewObject(comm_class, jtask_method_Comm_constructor);
const char* mailbox = env->GetStringUTFChars(jmailbox, 0);
msg_task_t task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
env->ReleaseStringUTFChars(jmailbox, mailbox);
env->DeleteLocalRef(jcomm);
jxbt_throw_notbound(env, "task", jtask);
const char *mailbox;
jclass comm_class = env->FindClass("org/simgrid/msg/Comm");
- if (!comm_class)
+ if (not comm_class)
return nullptr;
jcomm = env->NewObject(comm_class, jtask_method_Comm_constructor);
task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
env->ReleaseStringUTFChars(jmailbox, mailbox);
env->DeleteLocalRef(jcomm);
jxbt_throw_notbound(env, "task", jtask);
{
msg_task_t task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
jxbt_throw_notbound(env, "task", jtask);
return;
}
msg_task_t task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
env->ReleaseStringUTFChars(jalias, alias);
jxbt_throw_notbound(env, "task", jtask);
return;
msg_task_t task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
env->ReleaseStringUTFChars(jalias, alias);
jxbt_throw_notbound(env, "task", jtask);
return;
int count = vms.size();
jclass cls = jxbt_get_class(env, "org/simgrid/msg/VM");
- if (!cls)
+ if (not cls)
return nullptr;
jobjectArray jtable = env->NewObjectArray((jsize)count, cls, nullptr);
- if (!jtable) {
+ if (not jtable) {
jxbt_throw_jni(env, "Hosts table allocation failed");
return nullptr;
}
/* get the VM by name (VMs are just special hosts, unfortunately) */
msg_host_t host = MSG_host_by_name(name);
- if (!host) { /* invalid name */
+ if (not host) { /* invalid name */
jxbt_throw_host_not_found(env, name);
env->ReleaseStringUTFChars(jname, name);
return nullptr;
{
jclass cls = env->FindClass(name);
- if (!cls) {
+ if (not cls) {
jxbt_throw_jni(env, std::string("Class ") + name + " not found");
return nullptr;
}
{
jmethodID id;
- if (!cls)
+ if (not cls)
return 0;
id = env->GetMethodID(cls, name, signature);
- if (!id) {
+ if (not id) {
jmethodID tostr_id = env->GetMethodID(cls, "getName", "()Ljava/lang/String;");
jstring jclassname = (jstring) env->CallObjectMethod(cls, tostr_id, nullptr);
{
jmethodID id;
- if (!cls)
+ if (not cls)
return 0;
id = env->GetStaticMethodID(cls, name, signature);
- if (!id) {
+ if (not id) {
jmethodID tostr_id = env->GetMethodID(cls, "getName", "()Ljava/lang/String;");
jstring jclassname = (jstring) env->CallObjectMethod(cls, tostr_id, nullptr);
const char *classname = env->GetStringUTFChars(jclassname, 0);
jmethodID id;
cls = jxbt_get_class(env, classname);
- if (!cls)
+ if (not cls)
return 0;
id = env->GetStaticMethodID(cls, name, signature);
- if (!id) {
+ if (not id) {
jxbt_throw_jni(env, std::string("Cannot find static method") + name + "(" + signature + ") in " + classname);
return 0;
}
jmethodID id;
cls = jxbt_get_class(env, classname);
- if (!cls)
+ if (not cls)
return 0;
id = env->GetMethodID(cls, name, signature);
- if (!id) {
+ if (not id) {
jxbt_throw_jni(env, std::string("Cannot find method") + name + "(" + signature + ") in " + classname);
return 0;
}
{
jfieldID id;
- if (!cls)
+ if (not cls)
return 0;
id = env->GetFieldID(cls, name, signature);
- if (!id) {
+ if (not id) {
jmethodID getname_id = env->GetMethodID(cls, "getName", "()Ljava/lang/String;");
jstring jclassname = (jstring) env->CallObjectMethod(cls, getname_id, nullptr);
const char *classname = env->GetStringUTFChars(jclassname, 0);
jclass cls = jxbt_get_class(env, classname);
jfieldID id;
- if (!cls)
+ if (not cls)
return 0;
id = env->GetFieldID(cls, name, signature);
- if (!id) {
+ if (not id) {
jxbt_throw_jni(env, std::string("Cannot find field") + signature + " " + name + " in " + classname);
return 0;
}
XBT_DEBUG("Checking the task's metatable: expected %p, found %p", correct_mt, actual_mt);
sglua_stack_dump(L, "my_checkudata: ");
- if (p == nullptr || !lua_getmetatable(L, ud) || !lua_rawequal(L, -1, -2))
+ if (p == nullptr || not lua_getmetatable(L, ud) || not lua_rawequal(L, -1, -2))
XBT_ERROR("Error: Userdata is nullptr, couldn't find metatable or top of stack does not equal element below it.");
lua_pop(L, 2);
return p;
if (pi == nullptr)
XBT_ERROR("luaL_checkudata() returned nullptr");
sg_host_t ht = *pi;
- if (!ht)
+ if (not ht)
luaL_error(L, "null Host");
return ht;
}
lua_pushstring(L, "sharing_policy");
type = lua_gettable(L, -2);
const char* policy = lua_tostring(L, -1);
- if (policy && !strcmp(policy,"FULLDUPLEX")) {
+ if (policy && not strcmp(policy, "FULLDUPLEX")) {
link.policy = SURF_LINK_FULLDUPLEX;
- } else if (policy && !strcmp(policy,"FATPIPE")) {
+ } else if (policy && not strcmp(policy, "FATPIPE")) {
link.policy = SURF_LINK_FATPIPE;
} else {
link.policy = SURF_LINK_SHARED;
// get core
lua_pushstring(L, "core");
lua_gettable(L, -2);
- if(!lua_isnumber(L,-1))
- host.core_amount = 1;// Default value
+ if (not lua_isnumber(L, -1))
+ host.core_amount = 1; // Default value
else
host.core_amount = lua_tonumber(L, -1);
if (host.core_amount == 0)
lua_gettable(L, -2);
policy = lua_tostring(L, -1);
lua_pop(L, 1);
- if (policy && !strcmp(policy,"FULLDUPLEX")) {
+ if (policy && not strcmp(policy, "FULLDUPLEX")) {
link.policy = SURF_LINK_FULLDUPLEX;
- } else if (policy && !strcmp(policy,"FATPIPE")) {
+ } else if (policy && not strcmp(policy, "FATPIPE")) {
link.policy = SURF_LINK_FATPIPE;
} else {
link.policy = SURF_LINK_SHARED;
lua_pop(L, 1);
int mode_int = A_surfxml_AS_routing_None;
- if(!strcmp(mode,"Full")) mode_int = A_surfxml_AS_routing_Full;
- else if(!strcmp(mode,"Floyd")) mode_int = A_surfxml_AS_routing_Floyd;
- else if(!strcmp(mode,"Dijkstra")) mode_int = A_surfxml_AS_routing_Dijkstra;
- else if(!strcmp(mode,"DijkstraCache")) mode_int = A_surfxml_AS_routing_DijkstraCache;
- else if(!strcmp(mode,"Vivaldi")) mode_int = A_surfxml_AS_routing_Vivaldi;
- else if(!strcmp(mode,"Cluster")) mode_int = A_surfxml_AS_routing_Cluster;
- else if(!strcmp(mode,"none")) mode_int = A_surfxml_AS_routing_None;
+ if (not strcmp(mode, "Full"))
+ mode_int = A_surfxml_AS_routing_Full;
+ else if (not strcmp(mode, "Floyd"))
+ mode_int = A_surfxml_AS_routing_Floyd;
+ else if (not strcmp(mode, "Dijkstra"))
+ mode_int = A_surfxml_AS_routing_Dijkstra;
+ else if (not strcmp(mode, "DijkstraCache"))
+ mode_int = A_surfxml_AS_routing_DijkstraCache;
+ else if (not strcmp(mode, "Vivaldi"))
+ mode_int = A_surfxml_AS_routing_Vivaldi;
+ else if (not strcmp(mode, "Cluster"))
+ mode_int = A_surfxml_AS_routing_Cluster;
+ else if (not strcmp(mode, "none"))
+ mode_int = A_surfxml_AS_routing_None;
else xbt_die("Don't have the model name '%s'",mode);
s_sg_platf_AS_cbarg_t AS;
/* open the trace file(s) */
const char* format = xbt_cfg_get_string(OPT_TRACING_FORMAT);
XBT_DEBUG("Tracing format %s\n", format);
- if(!strcmp(format, "Paje")){
+ if (not strcmp(format, "Paje")) {
TRACE_paje_start();
- }else if (!strcmp(format, "TI")){
+ } else if (not strcmp(format, "TI")) {
instr_fmt_type = instr_fmt_TI;
TRACE_TI_start();
}else{
int TRACE_end()
{
int retval;
- if (!trace_active) {
+ if (not trace_active) {
retval = 1;
} else {
retval = 0;
/* close the trace files */
const char* format = xbt_cfg_get_string(OPT_TRACING_FORMAT);
XBT_DEBUG("Tracing format %s\n", format);
- if(!strcmp(format, "Paje")){
+ if (not strcmp(format, "Paje")) {
TRACE_paje_end();
- }else if (!strcmp(format, "TI")){
+ } else if (not strcmp(format, "TI")) {
TRACE_TI_end();
}else{
xbt_die("Unknown trace format :%s ", format);
void instr_pause_tracing ()
{
previous_trace_state = trace_enabled;
- if (!TRACE_is_enabled()){
+ if (not TRACE_is_enabled()) {
XBT_DEBUG ("Tracing is already paused, therefore do nothing.");
}else{
XBT_DEBUG ("Tracing is being paused.");
static xbt_dynar_t instr_dict_to_dynar (xbt_dict_t filter)
{
- if (!TRACE_is_enabled() || !TRACE_needs_platform())
+ if (not TRACE_is_enabled() || not TRACE_needs_platform())
return nullptr;
xbt_dynar_t ret = xbt_dynar_new (sizeof(char*), &xbt_free_ref);
void TRACE_category_with_color (const char *category, const char *color)
{
/* safe switches. tracing has to be activated and if platform is not traced, we can't deal with categories */
- if (!TRACE_is_enabled() || !TRACE_needs_platform())
+ if (not TRACE_is_enabled() || not TRACE_needs_platform())
return;
if (!(TRACE_categorized() && category != nullptr))
//define final_color
char final_color[INSTR_DEFAULT_STR_SIZE];
- if (!color){
+ if (not color) {
//generate a random color
double red = drand48();
double green = drand48();
*/
xbt_dynar_t TRACE_get_categories ()
{
- if (!TRACE_is_enabled() || !TRACE_categorized())
+ if (not TRACE_is_enabled() || not TRACE_categorized())
return nullptr;
return instr_dict_to_dynar (created_categories);
void TRACE_declare_mark(const char *mark_type)
{
/* safe switchs. tracing has to be activated and if platform is not traced, we can't deal with marks */
- if (!TRACE_is_enabled() || !TRACE_needs_platform())
+ if (not TRACE_is_enabled() || not TRACE_needs_platform())
return;
- if (!mark_type)
+ if (not mark_type)
THROWF (tracing_error, 1, "mark_type is nullptr");
//check if mark_type is already declared
void TRACE_declare_mark_value_with_color (const char *mark_type, const char *mark_value, const char *mark_color)
{
/* safe switches. tracing has to be activated and if platform is not traced, we can't deal with marks */
- if (!TRACE_is_enabled() || !TRACE_needs_platform())
+ if (not TRACE_is_enabled() || not TRACE_needs_platform())
return;
- if (!mark_type)
+ if (not mark_type)
THROWF (tracing_error, 1, "mark_type is nullptr");
- if (!mark_value)
+ if (not mark_value)
THROWF (tracing_error, 1, "mark_value is nullptr");
type_t type = PJ_type_get (mark_type, PJ_type_get_root());
- if (!type){
+ if (not type) {
THROWF (tracing_error, 1, "mark_type with name (%s) is not declared", mark_type);
}
char white[INSTR_DEFAULT_STR_SIZE] = "1.0 1.0 1.0";
- if (!mark_color)
+ if (not mark_color)
mark_color = white;
XBT_DEBUG("MARK,declare_value %s %s %s", mark_type, mark_value, mark_color);
void TRACE_mark(const char *mark_type, const char *mark_value)
{
/* safe switches. tracing has to be activated and if platform is not traced, we can't deal with marks */
- if (!TRACE_is_enabled() || !TRACE_needs_platform())
+ if (not TRACE_is_enabled() || not TRACE_needs_platform())
return;
- if (!mark_type)
+ if (not mark_type)
THROWF (tracing_error, 1, "mark_type is nullptr");
- if (!mark_value)
+ if (not mark_value)
THROWF (tracing_error, 1, "mark_value is nullptr");
//check if mark_type is already declared
type_t type = PJ_type_get (mark_type, PJ_type_get_root());
- if (!type){
+ if (not type) {
THROWF (tracing_error, 1, "mark_type with name (%s) is not declared", mark_type);
}
*/
xbt_dynar_t TRACE_get_marks ()
{
- if (!TRACE_is_enabled())
+ if (not TRACE_is_enabled())
return nullptr;
return instr_dict_to_dynar (declared_marks);
double value, InstrUserVariable what, const char *color, xbt_dict_t filter)
{
/* safe switches. tracing has to be activated and if platform is not traced, we don't allow user variables */
- if (!TRACE_is_enabled() || !TRACE_needs_platform())
+ if (not TRACE_is_enabled() || not TRACE_needs_platform())
return;
//check if variable is already declared
char *created = (char*)xbt_dict_get_or_null(filter, variable);
if (what == INSTR_US_DECLARE){
- if (!created) { // not declared yet
+ if (not created) { // not declared yet
xbt_dict_set (filter, variable, xbt_strdup("1"), nullptr);
instr_new_user_variable_type (father_type, variable, color);
}
const char *father_type, double value, InstrUserVariable what)
{
sg_netpoint_t src_elm = sg_netpoint_by_name_or_null(src);
- if(!src_elm)
+ if (not src_elm)
xbt_die("Element '%s' not found!",src);
sg_netpoint_t dst_elm = sg_netpoint_by_name_or_null(dst);
- if(!dst_elm)
+ if (not dst_elm)
xbt_die("Element '%s' not found!",dst);
std::vector<simgrid::surf::LinkImpl*> route;
int TRACE_platform_graph_export_graphviz (const char *filename)
{
/* returns 1 if successful, 0 otherwise */
- if (!TRACE_is_enabled())
+ if (not TRACE_is_enabled())
return 0;
xbt_graph_t g = instr_routing_platform_graph();
if (g == nullptr)
TRACE_paje_dump_buffer(1);
//trace my destruction
- if (!TRACE_disable_destroy() && container != PJ_container_get_root()){
+ if (not TRACE_disable_destroy() && container != PJ_container_get_root()) {
//do not trace the container destruction if user requests
//or if the container is root
new DestroyContainerEvent(container);
rootContainer = nullptr;
//checks
- if (!xbt_dict_is_empty(allContainers)){
+ if (not xbt_dict_is_empty(allContainers)) {
THROWF(tracing_error, 0, "some containers still present even after destroying all of them");
}
}
void dump_comment (const char *comment)
{
- if (!strlen(comment)) return;
+ if (not strlen(comment))
+ return;
fprintf (tracing_file, "# %s\n", comment);
}
void dump_comment_file (const char *filename)
{
- if (!strlen(filename)) return;
+ if (not strlen(filename))
+ return;
FILE *file = fopen (filename, "r");
- if (!file){
+ if (not file) {
THROWF (system_error, 1, "Comment file %s could not be opened for reading.", filename);
}
- while (!feof(file)){
+ while (not feof(file)) {
char c;
c = fgetc(file);
if (feof(file)) break;
//dumps the trace file until the timestamp TRACE_last_timestamp_to_dump
void TRACE_paje_dump_buffer (int force)
{
- if (!TRACE_is_enabled()) return;
+ if (not TRACE_is_enabled())
+ return;
XBT_DEBUG("%s: dump until %f. starts", __FUNCTION__, TRACE_last_timestamp_to_dump);
if (force){
for (auto event : buffer){
prefix = xbt_os_time();
}
- if (!xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file") || ti_unique_file == nullptr) {
- char *folder_name = bprintf("%s_files", TRACE_get_filename());
- char *filename = bprintf("%s/%f_%s.txt", folder_name, prefix, container->name);
+ if (not xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file") || ti_unique_file == nullptr) {
+ char* folder_name = bprintf("%s_files", TRACE_get_filename());
+ char* filename = bprintf("%s/%f_%s.txt", folder_name, prefix, container->name);
#ifdef WIN32
_mkdir(folder_name);
#else
print_row();
} else if (instr_fmt_type == instr_fmt_TI) {
- if (!xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file")|| xbt_dict_length(tracing_files) == 1) {
- FILE* f = (FILE*)xbt_dict_get_or_null(tracing_files, container->name);
- fclose(f);
- }
- xbt_dict_remove(tracing_files, container->name);
- } else {
- THROW_IMPOSSIBLE;
- }
+ if (not xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file") || xbt_dict_length(tracing_files) == 1) {
+ FILE* f = (FILE*)xbt_dict_get_or_null(tracing_files, container->name);
+ fclose(f);
+ }
+ xbt_dict_remove(tracing_files, container->name);
+ } else {
+ THROW_IMPOSSIBLE;
+ }
}
SetVariableEvent::SetVariableEvent (double timestamp, container_t container, type_t type, double value)
type_t ret = nullptr;
char white[INSTR_DEFAULT_STR_SIZE] = "1 1 1";
- if (!color){
+ if (not color) {
ret = newType (name, name, white, TYPE_VARIABLE, father);
}else{
ret = newType (name, name, color, TYPE_VARIABLE, father);
snprintf (key, n, "%s%s", resource, variable);
// check if key exists: if it doesn't, set the variable to zero and mark this in the dict
- if (!xbt_dict_get_or_null(platform_variables, key)) {
+ if (not xbt_dict_get_or_null(platform_variables, key)) {
container_t container = PJ_container_get (resource);
type_t type = PJ_type_get (variable, container->type);
new SetVariableEvent (now, container, type, 0);
void TRACE_surf_link_set_utilization(const char *resource, const char *category, double value, double now, double delta)
{
//only trace link utilization if link is known by tracing mechanism
- if (!PJ_container_get_or_null(resource))
+ if (not PJ_container_get_or_null(resource))
return;
- if (!value)
+ if (not value)
return;
//trace uncategorized link utilization
//trace categorized utilization
if (TRACE_categorized()){
- if (!category)
+ if (not category)
return;
//variable of this category starts by 'b', because we have a link here
char category_type[INSTR_DEFAULT_STR_SIZE];
{
//only trace host utilization if host is known by tracing mechanism
container_t container = PJ_container_get_or_null(resource);
- if (!container || !value)
+ if (not container || not value)
return;
//trace uncategorized host utilization
//trace categorized utilization
if (TRACE_categorized()){
- if (!category)
+ if (not category)
return;
//variable of this category starts by 'p', because we have a host here
char category_type[INSTR_DEFAULT_STR_SIZE];
}
void Jedule::writeOutput(FILE *file) {
- if (!this->event_set.empty()){
+ if (not this->event_set.empty()) {
fprintf(file, "<jedule>\n");
- if (!this->meta_info.empty()){
+ if (not this->meta_info.empty()) {
fprintf(file, " <jedule_meta>\n");
for (auto elm: this->meta_info)
fprintf(file, " <prop key=\"%s\" value=\"%s\" />\n",elm.first,elm.second);
Event::~Event()
{
- if (!this->resource_subsets->empty()){
+ if (not this->resource_subsets->empty()) {
for (auto subset: *this->resource_subsets)
delete subset;
delete this->resource_subsets;
fprintf(jed_file, " <prop key=\"end\" value=\"%g\" />\n", this->end_time);
fprintf(jed_file, " <prop key=\"type\" value=\"%s\" />\n", this->type.c_str());
- xbt_assert(!this->resource_subsets-> empty());
+ xbt_assert(not this->resource_subsets->empty());
fprintf(jed_file, " <res_util>\n");
for (auto subset: *this->resource_subsets) {
fprintf(jed_file, " <select resources=\"");
}
fprintf(jed_file, " </res_util>\n");
- if (!this->characteristics_list.empty()){
+ if (not this->characteristics_list.empty()) {
fprintf(jed_file, " <characteristics>\n");
for (auto ch: this->characteristics_list)
fprintf(jed_file, " <characteristic name=\"%s\" />\n", ch);
fprintf(jed_file, " </characteristics>\n");
}
- if (!this->info_map.empty()){
+ if (not this->info_map.empty()) {
fprintf(jed_file, " <info>\n");
for (auto elm: this->info_map)
fprintf(jed_file, " <prop key=\"%s\" value=\"%s\" />\n",elm.first,elm.second);
Container::~Container()
{
- if(!this->children.empty())
+ if (not this->children.empty())
for (auto child: this->children)
delete child;
}
if(this->parent != nullptr ) {
- if(!this->parent->children.empty()) {
+ if (not this->parent->children.empty()) {
// we are in the last level
return this->parent->getHierarchy();
} else {
void Container::printResources(FILE * jed_file)
{
unsigned int i=0;
- xbt_assert(!this->resource_list.empty());
+ xbt_assert(not this->resource_list.empty());
unsigned int res_nb = this->resource_list.size();
std::string resid = this->getHierarchyAsString();
{
xbt_assert( this != nullptr );
fprintf(jed_file, " <res name=\"%s\">\n", this->name.c_str());
- if( !this->children.empty()){
+ if (not this->children.empty()) {
for (auto child: this->children) {
child->print(jed_file);
}
{
if (my_jedule) {
char *fname;
- if (!filename) {
+ if (not filename) {
fname = bprintf("%s.jed", xbt_binary_name);
} else {
fname = xbt_strdup(filename);
xbt_assert(name, "Mailboxes must have a name");
/* two processes may have pushed the same mbox_create simcall at the same time */
smx_mailbox_t mbox = static_cast<smx_mailbox_t>(xbt_dict_get_or_null(mailboxes, name));
- if (!mbox) {
+ if (not mbox) {
mbox = new MailboxImpl(name);
XBT_DEBUG("Creating a mailbox at %p with name %s", mbox, name);
xbt_dict_set(mailboxes, mbox->name_, mbox, nullptr);
if (state == SIMIX_WAITING) {
mbox->remove(this);
state = SIMIX_CANCELED;
- }
- else if (!MC_is_active() /* when running the MC there are no surf actions */
- && !MC_record_replay_is_active()
- && (state == SIMIX_READY || state == SIMIX_RUNNING)) {
+ } else if (not MC_is_active() /* when running the MC there are no surf actions */
+ && not MC_record_replay_is_active() && (state == SIMIX_READY || state == SIMIX_RUNNING)) {
surf_comm->cancel();
}
cleanupSurf();
/* if there are simcalls associated with the synchro, then answer them */
- if (!simcalls.empty())
+ if (not simcalls.empty())
SIMIX_comm_finish(this);
}
}
/* If there are simcalls associated with the synchro, then answer them */
- if (!simcalls.empty())
+ if (not simcalls.empty())
SIMIX_execution_finish(this);
}
void simgrid::kernel::activity::Sleep::post()
{
- while (!simcalls.empty()) {
+ while (not simcalls.empty()) {
smx_simcall_t simcall = simcalls.front();
simcalls.pop_front();
{
BoostContext::parallel_ = SIMIX_context_is_parallel();
if (BoostContext::parallel_) {
-#if !HAVE_THREAD_CONTEXTS
- xbt_die("No thread support for parallel context execution");
-#else
+#if HAVE_THREAD_CONTEXTS
int nthreads = SIMIX_context_get_nthreads();
BoostContext::parmap_ = xbt_parmap_new(nthreads, SIMIX_context_get_parallel_mode());
BoostContext::workers_context_.clear();
BoostContext::workers_context_.resize(nthreads, nullptr);
BoostContext::maestro_context_ = nullptr;
xbt_os_thread_key_create(&BoostContext::worker_id_key_);
+#else
+ xbt_die("No thread support for parallel context execution");
#endif
}
}
BoostContext::~BoostContext()
{
#if HAVE_BOOST_CONTEXTS == 1
- if (!this->stack_)
+ if (not this->stack_)
delete this->fc_;
#endif
if (this == maestro_context_)
std::function<void()> code,
void_pfn_smxprocess_t cleanup, smx_actor_t process)
{
- return this->new_context<ThreadContext>(std::move(code), cleanup, process, !code);
+ return this->new_context<ThreadContext>(std::move(code), cleanup, process, not code);
}
void ThreadContextFactory::run_all()
void ClusterZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg_t route, double* lat)
{
XBT_VERB("cluster getLocalRoute from '%s'[%d] to '%s'[%d]", src->cname(), src->id(), dst->cname(), dst->id());
- xbt_assert(!privateLinks_.empty(),
+ xbt_assert(not privateLinks_.empty(),
"Cluster routing: no links attached to the source node - did you use host_link tag?");
if ((src->id() == dst->id()) && hasLoopback_) {
- xbt_assert(!src->isRouter(), "Routing from a cluster private router to itself is meaningless");
+ xbt_assert(not src->isRouter(), "Routing from a cluster private router to itself is meaningless");
std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(src->id() * linkCountPerNode_);
route->link_list->push_back(info.first);
return;
}
- if (!src->isRouter()) { // No private link for the private router
+ if (not src->isRouter()) { // No private link for the private router
if (hasLimiter_) { // limiter for sender
std::pair<surf::LinkImpl*, surf::LinkImpl*> info =
privateLinks_.at(src->id() * linkCountPerNode_ + (hasLoopback_ ? 1 : 0));
*lat += backbone_->latency();
}
- if (!dst->isRouter()) { // No specific link for router
+ if (not dst->isRouter()) { // No specific link for router
std::pair<surf::LinkImpl*, surf::LinkImpl*> info =
privateLinks_.at(dst->id() * linkCountPerNode_ + hasLoopback_ + hasLimiter_);
}
for (auto src : vertices_) {
- if (!src->isRouter()) {
+ if (not src->isRouter()) {
xbt_node_t previous = new_xbt_graph_node(graph, src->cname(), nodes);
std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(src->id());
unsigned int cursor;
/* Create the topology graph */
- if (!routeGraph_)
+ if (not routeGraph_)
routeGraph_ = xbt_graph_new_graph(1, nullptr);
- if (!graphNodeMap_)
+ if (not graphNodeMap_)
graphNodeMap_ = xbt_dict_new_homogeneous(&graph_node_map_elem_free);
/* Add the loopback if needed */
}
}
- if (!found) {
+ if (not found) {
sg_platf_route_cbarg_t e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
e_route->link_list = new std::vector<surf::LinkImpl*>();
e_route->link_list->push_back(surf_network_model->loopback_);
xbt_dict_set_ext(routeCache_, (char*)(&src_id), sizeof(int), (xbt_dictelm_t)elm, nullptr);
}
- if (!routeCache_)
+ if (not routeCache_)
xbt_free(pred_arr);
}
addRouteCheckParams(route);
/* Create the topology graph */
- if (!routeGraph_)
+ if (not routeGraph_)
routeGraph_ = xbt_graph_new_graph(1, nullptr);
- if (!graphNodeMap_)
+ if (not graphNodeMap_)
graphNodeMap_ = xbt_dict_new_homogeneous(&graph_node_map_elem_free);
/* we don't check whether the route already exist, because the algorithm may find another path through some other
// Symmetrical YES
if (route->symmetrical == true) {
- if (!route->gw_dst && !route->gw_src)
+ if (not route->gw_dst && not route->gw_src)
XBT_DEBUG("Load Route from \"%s\" to \"%s\"", dstName, srcName);
else
XBT_DEBUG("Load NetzoneRoute from %s@%s to %s@%s", dstName, route->gw_dst->name().c_str(), srcName,
FatTreeNode* currentNode = source;
// up part
- while (!isInSubTree(currentNode, destination)) {
+ while (not isInSubTree(currentNode, destination)) {
int d = destination->position; // as in d-mod-k
for (unsigned int i = 0; i < currentNode->level; i++)
}
sg_netpoint_t prev_dst_gw = nullptr;
- while (!route_stack.empty()) {
+ while (not route_stack.empty()) {
sg_platf_route_cbarg_t e_route = route_stack.back();
route_stack.pop_back();
if (hierarchy_ == RoutingMode::recursive && prev_dst_gw != nullptr &&
addRouteCheckParams(route);
- if (!linkTable_) {
+ if (not linkTable_) {
/* Create Cost, Predecessor and Link tables */
costTable_ = xbt_new0(double, table_size* table_size); /* link cost from host to host */
predecessorTable_ = xbt_new0(int, table_size* table_size); /* predecessor host numbers */
route->gw_dst = gw_tmp;
}
- if (!route->gw_src && !route->gw_dst)
+ if (not route->gw_src && not route->gw_dst)
XBT_DEBUG("Load Route from \"%s\" to \"%s\"", route->dst->name().c_str(), route->src->name().c_str());
else
XBT_DEBUG("Load NetzoneRoute from \"%s(%s)\" to \"%s(%s)\"", route->dst->name().c_str(), route->gw_src->name().c_str(),
/* set the size of table routing */
size_t table_size = vertices_.size();
- if (!linkTable_) {
+ if (not linkTable_) {
/* Create Cost, Predecessor and Link tables */
costTable_ = xbt_new0(double, table_size* table_size); /* link cost from host to host */
predecessorTable_ = xbt_new0(int, table_size* table_size); /* predecessor host numbers */
if (surf_network_model->loopback_ && hierarchy_ == RoutingMode::base) {
for (unsigned int i = 0; i < table_size; i++) {
sg_platf_route_cbarg_t e_route = TO_FLOYD_LINK(i, i);
- if (!e_route) {
+ if (not e_route) {
e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
e_route->gw_src = nullptr;
e_route->gw_dst = nullptr;
int table_size = static_cast<int>(vertices_.size());
/* Create table if needed */
- if (!routingTable_)
+ if (not routingTable_)
routingTable_ = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size);
/* Add the loopback if needed */
if (surf_network_model->loopback_ && hierarchy_ == RoutingMode::base) {
for (int i = 0; i < table_size; i++) {
sg_platf_route_cbarg_t e_route = TO_ROUTE_FULL(i, i);
- if (!e_route) {
+ if (not e_route) {
e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
e_route->gw_src = nullptr;
e_route->gw_dst = nullptr;
size_t table_size = vertices_.size();
- if (!routingTable_)
+ if (not routingTable_)
routingTable_ = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size);
/* Check that the route does not already exist */
if (e_route->gw_dst) {
XBT_DEBUG("Load bypassNetzoneRoute from %s@%s to %s@%s", e_route->src->cname(), e_route->gw_src->cname(),
e_route->dst->cname(), e_route->gw_dst->cname());
- xbt_assert(!e_route->link_list->empty(), "Bypass route between %s@%s and %s@%s cannot be empty.",
+ xbt_assert(not e_route->link_list->empty(), "Bypass route between %s@%s and %s@%s cannot be empty.",
e_route->src->cname(), e_route->gw_src->cname(), e_route->dst->cname(), e_route->gw_dst->cname());
xbt_assert(bypassRoutes_.find({e_route->src, e_route->dst}) == bypassRoutes_.end(),
"The bypass route between %s@%s and %s@%s already exists.", e_route->src->cname(),
e_route->gw_src->cname(), e_route->dst->cname(), e_route->gw_dst->cname());
} else {
XBT_DEBUG("Load bypassRoute from %s to %s", e_route->src->cname(), e_route->dst->cname());
- xbt_assert(!e_route->link_list->empty(), "Bypass route between %s and %s cannot be empty.", e_route->src->cname(),
- e_route->dst->cname());
+ xbt_assert(not e_route->link_list->empty(), "Bypass route between %s and %s cannot be empty.",
+ e_route->src->cname(), e_route->dst->cname());
xbt_assert(bypassRoutes_.find({e_route->src, e_route->dst}) == bypassRoutes_.end(),
"The bypass route between %s and %s already exists.", e_route->src->cname(), e_route->dst->cname());
}
const char* srcName = src->cname();
const char* dstName = dst->cname();
- if (!route->gw_dst && !route->gw_src) {
+ if (not route->gw_dst && not route->gw_src) {
XBT_DEBUG("Load Route from \"%s\" to \"%s\"", srcName, dstName);
xbt_assert(src, "Cannot add a route from %s to %s: %s does not exist.", srcName, dstName, srcName);
xbt_assert(dst, "Cannot add a route from %s to %s: %s does not exist.", srcName, dstName, dstName);
- xbt_assert(!route->link_list->empty(), "Empty route (between %s and %s) forbidden.", srcName, dstName);
- xbt_assert(!src->isNetZone(),
- "When defining a route, src cannot be a netzone such as '%s'. Did you meant to have an NetzoneRoute?", srcName);
- xbt_assert(!dst->isNetZone(),
- "When defining a route, dst cannot be a netzone such as '%s'. Did you meant to have an NetzoneRoute?", dstName);
+ xbt_assert(not route->link_list->empty(), "Empty route (between %s and %s) forbidden.", srcName, dstName);
+ xbt_assert(not src->isNetZone(),
+ "When defining a route, src cannot be a netzone such as '%s'. Did you meant to have an NetzoneRoute?",
+ srcName);
+ xbt_assert(not dst->isNetZone(),
+ "When defining a route, dst cannot be a netzone such as '%s'. Did you meant to have an NetzoneRoute?",
+ dstName);
} else {
XBT_DEBUG("Load NetzoneRoute from %s@%s to %s@%s", srcName, route->gw_src->cname(), dstName, route->gw_dst->cname());
xbt_assert(src->isNetZone(), "When defining a NetzoneRoute, src must be a netzone but '%s' is not", srcName);
dstName, route->gw_dst->cname(), srcName);
xbt_assert(dst, "Cannot add a route from %s@%s to %s@%s: %s does not exist.", srcName, route->gw_src->cname(),
dstName, route->gw_dst->cname(), dstName);
- xbt_assert(!route->link_list->empty(), "Empty route (between %s@%s and %s@%s) forbidden.", srcName,
+ xbt_assert(not route->link_list->empty(), "Empty route (between %s@%s and %s@%s) forbidden.", srcName,
route->gw_src->cname(), dstName, route->gw_dst->cname());
}
std::vector<std::string> dimensions;
boost::split(dimensions, cluster->topo_parameters, boost::is_any_of(","));
- if (!dimensions.empty()) {
+ if (not dimensions.empty()) {
/* We are in a torus cluster
* Parse attribute dimensions="dim1,dim2,dim3,...,dimN" and safe it in a vector.
* Additionally, we need to know how many ranks we have in total
Coords::Coords(NetPoint* netpoint, const char* coordStr)
{
- if (!Coords::EXTENSION_ID.valid())
+ if (not Coords::EXTENSION_ID.valid())
Coords::EXTENSION_ID = NetPoint::extension_create<Coords>();
std::vector<std::string> string_values;
int register_id = simgrid::dwarf::dwarf_register_to_libunwind(
op->atom - DW_OP_breg0);
unw_word_t res;
- if (!context.cursor)
+ if (not context.cursor)
throw evaluation_error("Missing stack context");
unw_get_reg(context.cursor, register_id, &res);
stack.push(res + op->number);
* Warning: the CFA returned by libunwind (UNW_X86_64_RSP, etc.)
* is the SP of the *current* frame. */
- if (!context.cursor)
+ if (not context.cursor)
throw evaluation_error("Missint cursor");
// Get frame:
// Address from the base address of this ELF object.
// Push the address on the stack (base_address + argument).
case DW_OP_addr: {
- if (!context.object_info)
+ if (not context.object_info)
throw evaluation_error("No base address");
Dwarf_Off addr = (Dwarf_Off) (std::uintptr_t)
context.object_info->base_address() + op->number;
case DW_OP_deref:
// Computed address:
- if (!context.address_space)
+ if (not context.address_space)
throw evaluation_error("Missing address space");
context.address_space->read_bytes(
&stack.top(), sizeof(uintptr_t), remote(stack.top()),
context.object_info = object_info;
context.process_index = process_index;
- if (!expression.empty()
- && expression[0].atom >= DW_OP_reg0
- && expression[0].atom <= DW_OP_reg31) {
+ if (not expression.empty() && expression[0].atom >= DW_OP_reg0 && expression[0].atom <= DW_OP_reg31) {
int dwarf_register = expression[0].atom - DW_OP_reg0;
xbt_assert(c, "Missing frame context for register operation DW_OP_reg%i", dwarf_register);
return Location(dwarf_register_to_libunwind(dwarf_register));
xbt_die("Could not resolve IP");
simgrid::dwarf::DwarfExpression const* expression =
find_expression(locations, ip);
- if (!expression)
+ if (not expression)
xbt_die("Could not resolve location");
return simgrid::dwarf::resolve(
*expression, object_info, c,
// The model-checked process SIGSTOP itself to signal it's ready:
pid_t res = waitpid(pid, &status, WAITPID_CHECKED_FLAGS);
- if (res < 0 || !WIFSTOPPED(status) || WSTOPSIG(status) != SIGSTOP)
+ if (res < 0 || not WIFSTOPPED(status) || WSTOPSIG(status) != SIGSTOP)
xbt_die("Could not wait model-checked process");
process_->init();
ssize_t size = process_->getChannel().receive(buffer, sizeof(buffer), false);
if (size == -1 && errno != EAGAIN)
throw simgrid::xbt::errno_error();
- if (!handle_message(buffer, size)) {
+ if (not handle_message(buffer, size)) {
event_base_loopbreak(base_);
}
}
typedef std::vector<Variable>::size_type size_type;
// If the current subprogram matches the given name:
- if ((subprogram_name == nullptr ||
- (!subprogram.name.empty()
- && subprogram.name == subprogram_name))
- && !scope.variables.empty()) {
+ if ((subprogram_name == nullptr || (not subprogram.name.empty() && subprogram.name == subprogram_name)) &&
+ not scope.variables.empty()) {
// Try to find the variable and remove it:
size_type start = 0;
static bool is_simgrid_lib(const char* libname)
{
- return !strcmp(libname, "libsimgrid");
+ return not strcmp(libname, "libsimgrid");
}
static bool is_filtered_lib(const char* libname)
map_basename = nullptr;
// Strip the version suffix:
- if(libname && !regexec(&res->version_re, libname, 1, &match, 0)) {
+ if (libname && not regexec(&res->version_re, libname, 1, &match, 0)) {
char* temp = libname;
libname = strndup(temp, match.rm_so);
free(temp);
// Read std_heap (is a struct mdesc*):
simgrid::mc::Variable* std_heap_var = this->find_variable("__mmalloc_default_mdp");
- if (!std_heap_var)
+ if (not std_heap_var)
xbt_die("No heap information in the target process");
- if(!std_heap_var->address)
+ if (not std_heap_var->address)
xbt_die("No constant address for this variable");
this->read_bytes(&this->heap_address, sizeof(struct mdesc*),
remote(std_heap_var->address),
void Process::refresh_heap()
{
// Read/dereference/refresh the std_heap pointer:
- if (!this->heap)
+ if (not this->heap)
this->heap = std::unique_ptr<s_xbt_mheap_t>(new s_xbt_mheap_t());
this->read_bytes(this->heap.get(), sizeof(struct mdesc),
remote(this->heap_address), simgrid::mc::ProcessIndexDisabled);
// [stack], [vvar], [vsyscall], [vdso] ...
if (pathname[0] == '[') {
- if ((reg.prot & PROT_WRITE) && !memcmp(pathname, "[stack]", 7)) {
+ if ((reg.prot & PROT_WRITE) && not memcmp(pathname, "[stack]", 7)) {
this->maestro_stack_start_ = remote(reg.start_addr);
this->maestro_stack_end_ = remote(reg.end_addr);
}
if (!(reg.prot & PROT_READ) && (reg.prot & PROT_EXEC))
continue;
- const bool is_executable = !i;
+ const bool is_executable = not i;
char* libname = nullptr;
- if (!is_executable) {
+ if (not is_executable) {
libname = get_lib_name(pathname, &res);
- if(!libname)
+ if (not libname)
continue;
if (is_filtered_lib(libname)) {
free(libname);
std::string Process::read_string(RemotePtr<char> address) const
{
- if (!address)
+ if (not address)
return {};
// TODO, use std::vector with .data() in C++17 to avoid useless copies
simgrid::mc::PatternCommunicationList* list =
xbt_dynar_get_as(initial_communications_pattern, process, simgrid::mc::PatternCommunicationList*);
- if(!backtracking){
+ if (not backtracking) {
e_mc_comm_pattern_difference_t diff = compare_comm_pattern(list->list[list->index_comm].get(), comm);
if (diff != NONE_DIFF) {
xbt_free(this->recv_diff);
this->recv_diff = print_determinism_result(diff, process, comm, list->index_comm + 1);
}
- if(_sg_mc_send_determinism && !this->send_deterministic){
+ if (_sg_mc_send_determinism && not this->send_deterministic) {
XBT_INFO("*********************************************************");
XBT_INFO("***** Non-send-deterministic communications pattern *****");
XBT_INFO("*********************************************************");
this->send_diff = nullptr;
simgrid::mc::session->logState();
mc_model_checker->exit(SIMGRID_MC_EXIT_NON_DETERMINISM);
- }else if(_sg_mc_comms_determinism
- && (!this->send_deterministic && !this->recv_deterministic)) {
+ } else if (_sg_mc_comms_determinism && (not this->send_deterministic && not this->recv_deterministic)) {
XBT_INFO("****************************************************");
XBT_INFO("***** Non-deterministic communications pattern *****");
XBT_INFO("****************************************************");
mc_model_checker->process().read_bytes(pattern->data.data(), pattern->data.size(), remote(synchro->src_buff));
}
if(mpi_request.detached()){
- if (!this->initial_communications_pattern_done) {
+ if (not this->initial_communications_pattern_done) {
/* Store comm pattern */
simgrid::mc::PatternCommunicationList* list =
xbt_dynar_get_as(initial_communications_pattern, pattern->src_proc, simgrid::mc::PatternCommunicationList*);
break;
}
- if(!completed)
+ if (not completed)
xbt_die("Corresponding communication not found!");
simgrid::mc::PatternCommunicationList* pattern =
xbt_dynar_get_as(initial_communications_pattern, issuer, simgrid::mc::PatternCommunicationList*);
- if (!this->initial_communications_pattern_done)
+ if (not this->initial_communications_pattern_done)
/* Store comm pattern */
pattern->list.push_back(std::move(comm_pattern));
else {
void CommunicationDeterminismChecker::logState() // override
{
Checker::logState();
- if (_sg_mc_comms_determinism && !this->recv_deterministic && this->send_deterministic) {
+ if (_sg_mc_comms_determinism && not this->recv_deterministic && this->send_deterministic) {
XBT_INFO("******************************************************");
XBT_INFO("**** Only-send-deterministic communication pattern ****");
XBT_INFO("******************************************************");
XBT_INFO("%s", this->recv_diff);
- } else if (_sg_mc_comms_determinism && !this->send_deterministic && this->recv_deterministic) {
+ } else if (_sg_mc_comms_determinism && not this->send_deterministic && this->recv_deterministic) {
XBT_INFO("******************************************************");
XBT_INFO("**** Only-recv-deterministic communication pattern ****");
XBT_INFO("******************************************************");
XBT_INFO("Expanded states = %lu", expandedStatesCount_);
XBT_INFO("Visited states = %lu", mc_model_checker->visited_states);
XBT_INFO("Executed transitions = %lu", mc_model_checker->executed_transitions);
- XBT_INFO("Send-deterministic : %s", !this->send_deterministic ? "No" : "Yes");
+ XBT_INFO("Send-deterministic : %s", not this->send_deterministic ? "No" : "Yes");
if (_sg_mc_comms_determinism)
- XBT_INFO("Recv-deterministic : %s", !this->recv_deterministic ? "No" : "Yes");
+ XBT_INFO("Recv-deterministic : %s", not this->recv_deterministic ? "No" : "Yes");
}
void CommunicationDeterminismChecker::prepare()
{
for (size_t current_actor = 1; current_actor < MC_smx_get_maxpid(); current_actor++) {
xbt_dynar_t pattern = xbt_dynar_get_as(incomplete_communications_pattern, current_actor, xbt_dynar_t);
- if (!xbt_dynar_is_empty(pattern)) {
+ if (not xbt_dynar_is_empty(pattern)) {
XBT_DEBUG("Some communications are not finished, cannot stop the exploration ! State not visited.");
return false;
}
std::unique_ptr<simgrid::mc::VisitedState> visited_state = nullptr;
smx_simcall_t req = nullptr;
- while (!stack_.empty()) {
+ while (not stack_.empty()) {
/* Get current state */
simgrid::mc::State* state = stack_.back().get();
mc_model_checker->handle_simcall(state->transition);
/* After this call req is no longer useful */
- if (!this->initial_communications_pattern_done)
+ if (not this->initial_communications_pattern_done)
MC_handle_comm_pattern(call, req, req_num, initial_communications_pattern, 0);
else
MC_handle_comm_pattern(call, req, req_num, nullptr, 0);
else
XBT_DEBUG("There are no more processes to interleave. (depth %zi)", stack_.size());
- if (!this->initial_communications_pattern_done)
+ if (not this->initial_communications_pattern_done)
this->initial_communications_pattern_done = 1;
/* Trash the current state, no longer needed */
throw new simgrid::mc::DeadlockError();
}
- while (!stack_.empty()) {
+ while (not stack_.empty()) {
std::unique_ptr<simgrid::mc::State> state = std::move(stack_.back());
stack_.pop_back();
if (state->interleaveSize() && stack_.size() < (std::size_t)_sg_mc_max_depth) {
return evaluate_label(l->u.or_and.left_exp, values)
&& evaluate_label(l->u.or_and.right_exp, values);
case xbt_automaton_exp_label::AUT_NOT:
- return !evaluate_label(l->u.exp_not, values);
+ return not evaluate_label(l->u.exp_not, values);
case xbt_automaton_exp_label::AUT_PREDICAT:{
unsigned int cursor = 0;
xbt_automaton_propositional_symbol_t p = nullptr;
{
/* Traverse the stack backwards until a pair with a non empty interleave
set is found, deleting all the pairs that have it empty in the way. */
- while (!explorationStack_.empty()) {
+ while (not explorationStack_.empty()) {
std::shared_ptr<simgrid::mc::Pair> current_pair = explorationStack_.back();
explorationStack_.pop_back();
if (current_pair->requests > 0) {
explorationStack_.push_back(this->newPair(nullptr, automaton_state, propos));
/* Actually run the double DFS search for counter-examples */
- while (!explorationStack_.empty()){
+ while (not explorationStack_.empty()) {
std::shared_ptr<Pair> current_pair = explorationStack_.back();
/* Update current state in buchi automaton */
}
std::shared_ptr<VisitedPair> reached_pair;
- if (current_pair->automaton_state->type == 1 && !current_pair->exploration_started
- && (reached_pair = this->insertAcceptancePair(current_pair.get())) == nullptr) {
+ if (current_pair->automaton_state->type == 1 && not current_pair->exploration_started &&
+ (reached_pair = this->insertAcceptancePair(current_pair.get())) == nullptr) {
this->showAcceptanceCycle(current_pair->depth);
throw simgrid::mc::LivenessError();
}
/* Pair already visited ? stop the exploration on the current path */
int visited_num = -1;
- if ((!current_pair->exploration_started)
- && (visited_num = this->insertVisitedPair(
- reached_pair, current_pair.get())) != -1) {
+ if ((not current_pair->exploration_started) &&
+ (visited_num = this->insertVisitedPair(reached_pair, current_pair.get())) != -1) {
if (dot_output != nullptr){
fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n",
this->previousPair_, visited_num,
/* Update stats */
mc_model_checker->executed_transitions++;
- if (!current_pair->exploration_started)
+ if (not current_pair->exploration_started)
visitedPairsCount_++;
/* Answer the request */
* We do so iteratively instead of recursively, dealing with the call stack manually.
* This allows to explore the call stack at wish. */
- while (!stack_.empty()) {
+ while (not stack_.empty()) {
/* Get current state */
simgrid::mc::State* state = stack_.back().get();
executed before it. If it does then add it to the interleave set of the
state that executed that previous request. */
- while (!stack_.empty()) {
+ while (not stack_.empty()) {
std::unique_ptr<simgrid::mc::State> state = std::move(stack_.back());
stack_.pop_back();
if (reductionMode_ == simgrid::mc::ReductionMode::dpor) {
state->num);
}
- if (!prev_state->actorStates[issuer->pid].isDone())
+ if (not prev_state->actorStates[issuer->pid].isDone())
prev_state->interleave(issuer);
else
XBT_DEBUG("Process %p is in done set", req->issuer);
}
}
- while (i2 < state.heaplimit && !equal) {
+ while (i2 < state.heaplimit && not equal) {
addr_block2 = (ADDR2UINT(i2) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
i2++;
}
- if (!equal) {
+ if (not equal) {
XBT_DEBUG("Block %zu not found (size_used = %zu, addr = %p)", i1, heapinfo1->busy_block.busy_size, addr_block1);
i1 = state.heaplimit + 1;
nb_diff1++;
equal = 0;
/* Try first to associate to same fragment in the other heap */
- if (heapinfo2->type == heapinfo1->type
- && !state.equals_to2_(i1, j1).valid) {
+ if (heapinfo2->type == heapinfo1->type && not state.equals_to2_(i1, j1).valid) {
addr_block2 = (ADDR2UINT(i1) - 1) * BLOCKSIZE +
(char *) state.std_heap_copy.heapbase;
addr_frag2 =
equal = 1;
}
- while (i2 < state.heaplimit && !equal) {
+ while (i2 < state.heaplimit && not equal) {
const malloc_info* heapinfo2b = (const malloc_info*) MC_region_read(
heap_region2, &heapinfo_temp2b, &heapinfos2[i2],
i2++;
}
- if (!equal) {
+ if (not equal) {
XBT_DEBUG("Block %zu, fragment %zu not found (size_used = %zd, address = %p)\n", i1, j1,
heapinfo1->busy_frag.frag_size[j1], addr_frag1);
i2 = state.heaplimit + 1;
heap_region1, &heapinfo_temp1, &heapinfos1[i], sizeof(malloc_info));
if (heapinfo1->type == MMALLOC_TYPE_UNFRAGMENTED && i1 == state.heaplimit && heapinfo1->busy_block.busy_size > 0 &&
- !state.equals_to1_(i, 0).valid) {
+ not state.equals_to1_(i, 0).valid) {
XBT_DEBUG("Block %zu not found (size used = %zu)", i, heapinfo1->busy_block.busy_size);
nb_diff1++;
}
if (heapinfo1->type <= 0)
continue;
for (j = 0; j < (size_t) (BLOCKSIZE >> heapinfo1->type); j++)
- if (i1 == state.heaplimit && heapinfo1->busy_frag.frag_size[j] > 0 && !state.equals_to1_(i, j).valid) {
+ if (i1 == state.heaplimit && heapinfo1->busy_frag.frag_size[j] > 0 && not state.equals_to1_(i, j).valid) {
XBT_DEBUG("Block %zu, Fragment %zu not found (size used = %zd)", i, j, heapinfo1->busy_frag.frag_size[j]);
nb_diff1++;
}
for (i=1; i < state.heaplimit; i++) {
const malloc_info* heapinfo2 = (const malloc_info*) MC_region_read(
heap_region2, &heapinfo_temp2, &heapinfos2[i], sizeof(malloc_info));
- if (heapinfo2->type == MMALLOC_TYPE_UNFRAGMENTED
- && i1 == state.heaplimit
- && heapinfo2->busy_block.busy_size > 0
- && !state.equals_to2_(i, 0).valid) {
+ if (heapinfo2->type == MMALLOC_TYPE_UNFRAGMENTED && i1 == state.heaplimit && heapinfo2->busy_block.busy_size > 0 &&
+ not state.equals_to2_(i, 0).valid) {
XBT_DEBUG("Block %zu not found (size used = %zu)", i,
heapinfo2->busy_block.busy_size);
nb_diff2++;
continue;
for (j = 0; j < (size_t) (BLOCKSIZE >> heapinfo2->type); j++)
- if (i1 == state.heaplimit
- && heapinfo2->busy_frag.frag_size[j] > 0
- && !state.equals_to2_(i, j).valid) {
+ if (i1 == state.heaplimit && heapinfo2->busy_frag.frag_size[j] > 0 && not state.equals_to2_(i, j).valid) {
XBT_DEBUG("Block %zu, Fragment %zu not found (size used = %zd)",
i, j, heapinfo2->busy_frag.frag_size[j]);
nb_diff2++;
return 1;
case DW_TAG_base_type:
- if (!type->name.empty() && type->name == "char") { /* String, hence random (arbitrary ?) size */
+ if (not type->name.empty() && type->name == "char") { /* String, hence random (arbitrary ?) size */
if (real_area1 == real_area2)
return -1;
else
// Find type_size:
if (type->type == DW_TAG_pointer_type ||
- (type->type == DW_TAG_base_type && !type->name.empty() && type->name == "char"))
+ (type->type == DW_TAG_base_type && not type->name.empty() && type->name == "char"))
type_size = -1;
else
type_size = type->byte_size;
if (heapinfo1->busy_block.busy_size != heapinfo2->busy_block.busy_size)
return 1;
- if (!previous->insert(simgrid::mc::makeHeapLocationPair(block1, -1, block2, -1)).second) {
+ if (not previous->insert(simgrid::mc::makeHeapLocationPair(block1, -1, block2, -1)).second) {
if (match_pairs)
state.match_equals(previous);
return 0;
}
if (offset1 == 0 && offset2 == 0 &&
- !previous->insert(simgrid::mc::makeHeapLocationPair(block1, frag1, block2, frag2)).second) {
+ not previous->insert(simgrid::mc::makeHeapLocationPair(block1, frag1, block2, frag2)).second) {
if (match_pairs)
state.match_equals(previous);
return 0;
return 0;
if (addr_pointed1 == nullptr || addr_pointed2 == nullptr)
return 1;
- if (!state.compared_pointers.insert(
- std::make_pair(addr_pointed1, addr_pointed2)).second)
+ if (not state.compared_pointers.insert(std::make_pair(addr_pointed1, addr_pointed2)).second)
return 0;
pointer_level++;
// The pointers are both in the current object R/W segment:
else if (region1->contain(simgrid::mc::remote(addr_pointed1))) {
- if (!region2->contain(simgrid::mc::remote(addr_pointed2)))
+ if (not region2->contain(simgrid::mc::remote(addr_pointed2)))
return 1;
- if (!type->type_id)
+ if (not type->type_id)
return (addr_pointed1 != addr_pointed2);
else
return compare_areas_with_type(state, process_index,
// * There MUST not be any false negative.
XBT_VERB("(%d - %d) State equality hash test is %s %s", num1, num2,
- (hash_result != 0) == (errors != 0) ? "true" : "false",
- !hash_result ? "positive" : "negative");
+ (hash_result != 0) == (errors != 0) ? "true" : "false", not hash_result ? "positive" : "negative");
}
#endif
smx_simcall_t req;
unsigned int iter;
- while (!xbt_dynar_is_empty(simix_global->process_to_run)) {
+ while (not xbt_dynar_is_empty(simix_global->process_to_run)) {
SIMIX_process_runall();
xbt_dynar_foreach(simix_global->process_that_ran, iter, process) {
req = &process->simcall;
- if (req->call != SIMCALL_NONE && !simgrid::mc::request_is_visible(req))
+ if (req->call != SIMCALL_NONE && not simgrid::mc::request_is_visible(req))
SIMIX_simcall_handle(req, 0);
}
}
case SIMCALL_SEM_ACQUIRE: {
static int warned = 0;
- if (!warned)
+ if (not warned)
XBT_INFO("Using semaphore in model-checked code is still experimental. Use at your own risk");
warned = 1;
return true;
case SIMCALL_COND_WAIT: {
static int warned = 0;
- if (!warned)
+ if (not warned)
XBT_INFO("Using condition variables in model-checked code is still experimental. Use at your own risk");
warned = 1;
return true;
int simcall_HANDLER_mc_random(smx_simcall_t simcall, int min, int max)
{
- if (!MC_is_active() && !MC_record_path)
+ if (not MC_is_active() && not MC_record_path)
return prng_random(min, max);
return simcall->mc_value;
}
if (type == simgrid::mc::RegionType::Data)
xbt_assert(object_info, "Missing object info for object.");
else if (type == simgrid::mc::RegionType::Heap)
- xbt_assert(!object_info, "Unexpected object info for heap region.");
+ xbt_assert(not object_info, "Unexpected object info for heap region.");
simgrid::mc::RegionSnapshot region;
#if HAVE_SMPI
// This is the non-GNU_RELRO-part of the data segment:
if (reg.prot == PROT_RW) {
- xbt_assert(!result->start_rw,
- "Multiple read-write segments for %s, not supported",
- maps[i].pathname.c_str());
+ xbt_assert(not result->start_rw, "Multiple read-write segments for %s, not supported", maps[i].pathname.c_str());
result->start_rw = (char*) reg.start_addr;
result->end_rw = (char*) reg.end_addr;
// This is the text segment:
else if (reg.prot == PROT_RX) {
- xbt_assert(!result->start_exec,
- "Multiple executable segments for %s, not supported",
+ xbt_assert(not result->start_exec, "Multiple executable segments for %s, not supported",
maps[i].pathname.c_str());
result->start_exec = (char*) reg.start_addr;
result->end_exec = (char*) reg.end_addr;
// This is the GNU_RELRO-part of the data segment:
else if (reg.prot == PROT_READ) {
- xbt_assert(!result->start_ro,
- "Multiple read only segments for %s, not supported",
- maps[i].pathname.c_str());
+ xbt_assert(not result->start_ro, "Multiple read only segments for %s, not supported", maps[i].pathname.c_str());
result->start_ro = (char*) reg.start_addr;
result->end_ro = (char*) reg.end_addr;
}
{
simgrid::mc::Process* process = &mc_model_checker->process();
- if (!scope || !scope->range.contain(stack_frame->ip))
+ if (not scope || not scope->range.contain(stack_frame->ip))
return;
for(simgrid::mc::Variable& current_variable :
scope->variables) {
- if (!valid_variable(¤t_variable, scope, (void *) stack_frame->ip))
+ if (not valid_variable(¤t_variable, scope, (void*)stack_frame->ip))
continue;
int region_type;
if (current_variable.address != nullptr)
new_var.address = current_variable.address;
- else if (!current_variable.location_list.empty()) {
+ else if (not current_variable.location_list.empty()) {
simgrid::dwarf::Location location =
simgrid::dwarf::resolve(
current_variable.location_list,
(void *) stack_frame->frame_base,
&mc_model_checker->process(), process_index);
- if (!location.in_memory())
+ if (not location.in_memory())
xbt_die("Cannot handle non-address variable");
new_var.address = location.address();
void MC_assert(int prop)
{
xbt_assert(mc_model_checker == nullptr);
- if (MC_is_active() && !prop)
+ if (MC_is_active() && not prop)
simgrid::mc::Client::get()->reportAssertionFailure();
}
void MC_cut(void)
{
xbt_assert(mc_model_checker == nullptr);
- if (!MC_is_active())
+ if (not MC_is_active())
return;
// FIXME, We want to do this in the model-checker:
xbt_die("MC_cut() not implemented");
void MC_ignore(void* addr, size_t size)
{
xbt_assert(mc_model_checker == nullptr);
- if (!MC_is_active())
+ if (not MC_is_active())
return;
simgrid::mc::Client::get()->ignoreMemory(addr, size);
}
void MC_automaton_new_propositional_symbol(const char *id, int(*fct)(void))
{
xbt_assert(mc_model_checker == nullptr);
- if (!MC_is_active())
+ if (not MC_is_active())
return;
xbt_die("Support for client-side function proposition is not implemented: "
"use MC_automaton_new_propositional_symbol_pointer instead.");
void MC_automaton_new_propositional_symbol_pointer(const char *name, int* value)
{
xbt_assert(mc_model_checker == nullptr);
- if (!MC_is_active())
+ if (not MC_is_active())
return;
simgrid::mc::Client::get()->declareSymbol(name, value);
}
void MC_register_stack_area(void *stack, smx_actor_t process, ucontext_t* context, size_t size)
{
xbt_assert(mc_model_checker == nullptr);
- if (!MC_is_active())
+ if (not MC_is_active())
return;
simgrid::mc::Client::get()->declareStack(stack, size, process, context);
}
void MC_ignore_global_variable(const char *name)
{
xbt_assert(mc_model_checker == nullptr);
- if (!MC_is_active())
+ if (not MC_is_active())
return;
// TODO, send a message to the model_checker
xbt_die("Unimplemented");
void MC_ignore_heap(void *address, size_t size)
{
xbt_assert(mc_model_checker == nullptr);
- if (!MC_is_active())
+ if (not MC_is_active())
return;
simgrid::mc::Client::get()->ignoreHeap(address, size);
}
void MC_remove_ignore_heap(void *address, size_t size)
{
xbt_assert(mc_model_checker == nullptr);
- if (!MC_is_active())
+ if (not MC_is_active())
return;
simgrid::mc::Client::get()->unignoreHeap(address, size);
}
("You are specifying a reduction strategy after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry.");
char *val = xbt_cfg_get_string(name);
- if (!strcasecmp(val, "none"))
+ if (not strcasecmp(val, "none"))
simgrid::mc::reduction_mode = simgrid::mc::ReductionMode::none;
- else if (!strcasecmp(val, "dpor"))
+ else if (not strcasecmp(val, "dpor"))
simgrid::mc::reduction_mode = simgrid::mc::ReductionMode::dpor;
else
xbt_die("configuration option %s can only take 'none' or 'dpor' as a value",
int attribute)
{
Dwarf_Attribute attr;
- if (!dwarf_attr_integrate(die, attribute, &attr))
+ if (not dwarf_attr_integrate(die, attribute, &attr))
return nullptr;
else
return dwarf_formstring(&attr);
static const char *MC_dwarf_at_linkage_name(Dwarf_Die * die)
{
const char *name = MC_dwarf_attr_integrate_string(die, DW_AT_linkage_name);
- if (!name)
+ if (not name)
name = MC_dwarf_attr_integrate_string(die, DW_AT_MIPS_linkage_name);
return name;
}
return MC_dwarf_attr_integrate_uint(die, DW_AT_count, 0);
// Otherwise compute DW_TAG_upper_bound-DW_TAG_lower_bound + 1:
- if (!dwarf_hasattr_integrate(die, DW_AT_upper_bound))
+ if (not dwarf_hasattr_integrate(die, DW_AT_upper_bound))
// This is not really 0, but the code expects this (we do not know):
return 0;
if (dwarf_hasattr(child, DW_AT_data_bit_offset))
xbt_die("Can't groke DW_AT_data_bit_offset.");
- if (!dwarf_hasattr_integrate(child, DW_AT_data_member_location)) {
+ if (not dwarf_hasattr_integrate(child, DW_AT_data_member_location)) {
if (type->type == DW_TAG_union_type)
return;
xbt_die
// Offset from the base address of the object:
{
Dwarf_Word offset;
- if (!dwarf_formudata(&attr, &offset))
+ if (not dwarf_formudata(&attr, &offset))
member->offset(offset);
else
xbt_die("Cannot get %s location <%" PRIx64 ">%s",
MC_dwarf_fill_member_location(type, &member, &child);
- if (!member.type_id)
+ if (not member.type_id)
xbt_die("Missing type for member %s of <%" PRIx64 ">%s",
member.name.c_str(),
(uint64_t) type->id, type->name.c_str());
{
simgrid::mc::Type type = MC_dwarf_die_to_type(info, die, unit, frame, ns);
auto& t = (info->types[type.id] = std::move(type));
- if (!t.name.empty() && type.byte_size != 0)
+ if (not t.name.empty() && type.byte_size != 0)
info->full_types_by_name[t.name] = &t;
}
{
std::unique_ptr<simgrid::mc::Variable> variable =
MC_die_to_variable(info, die, unit, frame, ns);
- if (!variable)
+ if (not variable)
return;
// Those arrays are sorted later:
else if (variable->global)
if (low_pc) {
// DW_AT_high_pc:
Dwarf_Attribute attr;
- if (!dwarf_attr_integrate(die, DW_AT_high_pc, &attr))
+ if (not dwarf_attr_integrate(die, DW_AT_high_pc, &attr))
xbt_die("Missing DW_AT_high_pc matching with DW_AT_low_pc");
Dwarf_Sword offset;
// Try with NT_GNU_BUILD_ID: we find the build ID in the ELF file and then
// use this ID to find the file in some known locations in the filesystem.
std::vector<char> build_id = get_build_id(elf);
- if (!build_id.empty()) {
+ if (not build_id.empty()) {
elf_end(elf);
close(fd);
simgrid::mc::Type* MC_resolve_type(
simgrid::mc::ObjectInformation* info, unsigned type_id)
{
- if (!type_id)
+ if (not type_id)
return nullptr;
simgrid::mc::Type* type = simgrid::util::find_map_ptr(info->types, type_id);
if (type == nullptr)
break;
// Resolve full_type:
- if (!subtype->name.empty() && subtype->byte_size == 0)
+ if (not subtype->name.empty() && subtype->byte_size == 0)
for (auto const& object_info : process->object_infos) {
auto i = object_info->full_types_by_name.find(subtype->name);
- if (i != object_info->full_types_by_name.end()
- && !i->second->name.empty() && i->second->byte_size) {
+ if (i != object_info->full_types_by_name.end() && not i->second->name.empty() && i->second->byte_size) {
type->full_type = i->second;
break;
}
unw_word_t off;
do {
- const char * name = !unw_get_proc_name(&cursor, buffer, 100, &off) ? buffer : "?";
+ const char* name = not unw_get_proc_name(&cursor, buffer, 100, &off) ? buffer : "?";
int status;
/* It creates the two heap regions: std_heap and mc_heap */
void MC_memory_init()
{
- if (!malloc_use_mmalloc())
+ if (not malloc_use_mmalloc())
xbt_die("Model-checking support is not enabled: run with simgrid-mc.");
}
// Choose a request:
smx_actor_t process = SIMIX_process_from_PID(transition.pid);
- if (!process)
+ if (not process)
xbt_die("Unexpected process.");
smx_simcall_t simcall = &(process->simcall);
- if(!simcall || simcall->call == SIMCALL_NONE)
+ if (not simcall || simcall->call == SIMCALL_NONE)
xbt_die("No simcall for this process.");
- if (!simgrid::mc::request_is_visible(simcall)
- || !simgrid::mc::request_is_enabled(simcall))
+ if (not simgrid::mc::request_is_visible(simcall) || not simgrid::mc::request_is_enabled(simcall))
xbt_die("Unexpected simcall.");
// Execute the request:
s_xbt_dynar_t comms;
mc_model_checker->process().read_bytes(
&comms, sizeof(comms), remote(simcall_comm_waitany__get__comms(req)));
- if (!xbt_dynar_is_empty(&comms)) {
+ if (not xbt_dynar_is_empty(&comms)) {
smx_activity_t remote_sync;
read_element(mc_model_checker->process(),
&remote_sync, remote(simcall_comm_waitany__get__comms(req)), value,
res = 0;
else
res = memcmp(buffer1, buffer2, size);
- if (!stack_alloc) {
+ if (not stack_alloc) {
free(buffer1a);
free(buffer2a);
}
xbt_test_add("Reading whole region data for %i page(s)", n);
const void* read = MC_region_read(®ion, destination, source, byte_size);
- xbt_test_assert(!memcmp(source, read, byte_size), "Mismatch in MC_region_read()");
+ xbt_test_assert(not memcmp(source, read, byte_size), "Mismatch in MC_region_read()");
xbt_test_add("Reading parts of region data for %i page(s)", n);
for(int j=0; j!=100; ++j) {
size_t offset = rand() % byte_size;
size_t size = rand() % (byte_size - offset);
const void* read = MC_region_read(®ion, destination, (const char*) source+offset, size);
- xbt_test_assert(!memcmp((char*) source+offset, read, size),
- "Mismatch in MC_region_read()");
+ xbt_test_assert(not memcmp((char*)source + offset, read, size), "Mismatch in MC_region_read()");
}
xbt_test_add("Compare whole region data for %i page(s)", n);
for(int j=0; j!=100; ++j) {
size_t offset = rand() % byte_size;
size_t size = rand() % (byte_size - offset);
- xbt_test_assert(!MC_snapshot_region_memcmp((char*) source+offset, ®ion, (char*) source+offset, ®ion, size),
- "Mismatch in MC_snapshot_region_memcmp()");
+ xbt_test_assert(
+ not MC_snapshot_region_memcmp((char*)source + offset, ®ion, (char*)source + offset, ®ion, size),
+ "Mismatch in MC_snapshot_region_memcmp()");
}
if (n==1) {
state->transition.argument = -1;
state->executed_req.call = SIMCALL_NONE;
- if (!procstate->isTodo())
+ if (not procstate->isTodo())
return nullptr; // Not considered by the checker algorithm
- if (!simgrid::mc::actor_is_enabled(actor))
+ if (not simgrid::mc::actor_is_enabled(actor))
return nullptr; // Not executable in the application
smx_simcall_t req = nullptr;
req = &actor->simcall;
break;
}
- if (!req)
+ if (not req)
return nullptr;
state->transition.pid = actor->pid;
if (write)
return -UNW_EREADONLYREG;
greg_t* preg = (greg_t*) get_reg(context, regnum);
- if (!preg)
+ if (not preg)
return -UNW_EBADREG;
*valp = *preg;
return 0;
{
simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*) arg;
simgrid::mc::Frame* frame = context->process_->find_function(remote(addr));
- if (!frame)
+ if (not frame)
return - UNW_ENOINFO;
*offp = (unw_word_t) frame->range.begin() - addr;
std::size_t read_length(AddressSpace const& as, RemotePtr<s_xbt_dynar_t> addr)
{
- if (!addr)
+ if (not addr)
return 0;
unsigned long res;
as.read_bytes(&res, sizeof(res),
{
// We are not in MC mode:
// TODO, handle this more gracefully.
- if (!std::getenv(MC_ENV_SOCKET_FD))
+ if (not std::getenv(MC_ENV_SOCKET_FD))
return nullptr;
// Do not break if we are called multiple times:
// Fetch socket from MC_ENV_SOCKET_FD:
char* fd_env = std::getenv(MC_ENV_SOCKET_FD);
- if (!fd_env)
+ if (not fd_env)
xbt_die("No MC socket passed in the environment");
int fd =
xbt_str_parse_int(fd_env, bprintf("Variable %s should contain a number but contains '%%s'", MC_ENV_SOCKET_FD));
case MC_MESSAGE_DEADLOCK_CHECK: {
// Check deadlock:
bool deadlock = false;
- if (!simix_global->process_list.empty()) {
+ if (not simix_global->process_list.empty()) {
deadlock = true;
for (auto kv : simix_global->process_list)
if (simgrid::mc::actor_is_enabled(kv.second)) {
xbt_die("Unexpected size for SIMCALL_HANDLE");
memcpy(&message, message_buffer, sizeof(message));
smx_actor_t process = SIMIX_process_from_PID(message.pid);
- if (!process)
+ if (not process)
xbt_die("Invalid pid %lu", (unsigned long)message.pid);
SIMIX_simcall_handle(&process->simcall, message.value);
if (channel_.send(MC_MESSAGE_WAITING))
msg_error_t res = MSG_main();
- if (!simgrid::xbt::action_queues.empty()) {
+ if (not simgrid::xbt::action_queues.empty()) {
XBT_WARN("Not all actions got consumed. If the simulation ended successfully (without deadlock),"
" you may want to add new processes to your deployment file.");
TRACE_global_init(argc, argv);
xbt_getpid = &MSG_process_self_PID;
- if (!msg_global) {
+ if (not msg_global) {
msg_global = new s_MSG_Global_t();
TRACE_msg_task_execute_start(task);
- xbt_assert((!simdata->compute) && !task->simdata->isused, "This task is executed somewhere else. Go fix your code!");
+ xbt_assert((not simdata->compute) && not task->simdata->isused,
+ "This task is executed somewhere else. Go fix your code!");
XBT_DEBUG("Computing on %s", MSG_process_get_name(MSG_process_self()));
- if (simdata->flops_amount <= 0.0 && !simdata->host_nb) {
+ if (simdata->flops_amount <= 0.0 && not simdata->host_nb) {
TRACE_msg_task_execute_end(task);
return MSG_OK;
}
simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::byName(alias);
simgrid::kernel::activity::Comm* comm = static_cast<simgrid::kernel::activity::Comm*>(mbox->front());
- if (!comm)
+ if (not comm)
return -1;
return MSG_process_get_PID( static_cast<msg_task_t>(comm->src_data)->simdata->sender );
priv->file_descriptor_table = new std::vector<int>(sg_storage_max_file_descriptors);
std::iota(priv->file_descriptor_table->rbegin(), priv->file_descriptor_table->rend(), 0); // Fill with ..., 1, 0.
}
- xbt_assert(!priv->file_descriptor_table->empty(), "Too much files are opened! Some have to be closed.");
+ xbt_assert(not priv->file_descriptor_table->empty(), "Too much files are opened! Some have to be closed.");
int desc = priv->file_descriptor_table->back();
priv->file_descriptor_table->pop_back();
return desc;
strncpy(file_mount_name, fullpath, strlen(mount_name) + 1);
file_mount_name[strlen(mount_name)] = '\0';
- if (!strcmp(file_mount_name, mount_name) && strlen(mount_name) > longest_prefix_length) {
+ if (not strcmp(file_mount_name, mount_name) && strlen(mount_name) > longest_prefix_length) {
/* The current mount name is found in the full path and is bigger than the previous*/
longest_prefix_length = strlen(mount_name);
storage_dest = (msg_storage_t)xbt_lib_get_elm_or_null(storage_lib, storage_name);
smx_actor_t process = simcall_process_create(name, std::move(code), msgExt, host, properties);
- if (!process) { /* Undo everything */
+ if (not process) { /* Undo everything */
delete msgExt;
return nullptr;
}
/* Let's create the process: SIMIX may decide to start it right now, even before returning the flow control to us */
smx_actor_t process = SIMIX_process_attach(name, new simgrid::MsgActorExt(data), host->cname(), properties, nullptr);
- if (!process)
+ if (not process)
xbt_die("Could not attach");
simcall_process_on_exit(process,(int_f_pvoid_pvoid_t)TRACE_msg_process_kill,process);
return process->ciface();
int pm_overcommit = pm->extension<simgrid::vm::VmHostExt>()->overcommit;
long vm_ramsize = typedVM->getRamsize();
- if (pm_ramsize && !pm_overcommit) { /* Only verify that we don't overcommit on need */
+ if (pm_ramsize && not pm_overcommit) { /* Only verify that we don't overcommit on need */
/* Retrieve the memory occupied by the VMs on that host. Yep, we have to traverse all VMs of all hosts for that */
long total_ramsize_of_vms = 0;
for (simgrid::s4u::VirtualMachine* ws_vm : simgrid::vm::VirtualMachineImpl::allVms_)
bool received_finalize = false;
char *finalize_task_name = get_mig_task_name(ms->vm, ms->src_pm, ms->dst_pm, 3);
- while (!received_finalize) {
+ while (not received_finalize) {
msg_task_t task = nullptr;
int ret = MSG_task_recv(&task, ms->mbox);
simgrid::vm::VirtualMachineImpl* pimpl = static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_;
pimpl->dp_enabled = 1;
- if (!pimpl->dp_objs)
+ if (not pimpl->dp_objs)
return;
char *key = nullptr;
dp->prev_clock = MSG_get_clock();
dp->prev_remaining = remaining;
}
- if (!pimpl->dp_objs)
+ if (not pimpl->dp_objs)
pimpl->dp_objs = xbt_dict_new_homogeneous(nullptr);
xbt_assert(xbt_dict_get_or_null(pimpl->dp_objs, key) == nullptr);
xbt_dict_set(pimpl->dp_objs, key, dp, nullptr);
start_dirty_page_tracking(ms->vm);
double computed_during_stage1 = 0;
- if (!skip_stage1) {
+ if (not skip_stage1) {
double clock_prev_send = MSG_get_clock();
try {
/* Stage2: send update pages iteratively until the size of remaining states becomes smaller than threshold value. */
- if (!skip_stage2) {
+ if (not skip_stage2) {
int stage2_round = 0;
for (;;) {
THROWF(vm_error, 0, "Cannot migrate VM '%s' from host '%s', which is offline.", vm->cname(), src_pm->cname());
if (dst_pm->isOff())
THROWF(vm_error, 0, "Cannot migrate VM '%s' to host '%s', which is offline.", vm->cname(), dst_pm->cname());
- if (!MSG_vm_is_running(vm))
+ if (not MSG_vm_is_running(vm))
THROWF(vm_error, 0, "Cannot migrate VM '%s' that is not running yet.", vm->cname());
if (typedVm->isMigrating())
THROWF(vm_error, 0, "Cannot migrate VM '%s' that is already migrating.", vm->cname());
/* dirty page tracking */
unsigned int size = xbt_dict_size(dp_objs);
static bool already_warned = false;
- if (size > 0 && !already_warned) {
+ if (size > 0 && not already_warned) {
xbt_dict_cursor_t cursor = nullptr;
xbt_dict_cursor_first(dp_objs, &cursor);
XBT_WARN("Dirty page tracking: %u pending task(s) on a destroyed VM (first one is %s).\n"
void VmHostExt::ensureVmExtInstalled()
{
- if (!EXTENSION_ID.valid())
+ if (not EXTENSION_ID.valid())
EXTENSION_ID = simgrid::s4u::Host::extension_create<VmHostExt>();
}
}
static s4u::NetZone* netzoneByNameRecursive(s4u::NetZone* current, const char* name)
{
- if(!strcmp(current->name(), name))
+ if (not strcmp(current->name(), name))
return current;
for (auto elem : *(current->children())) {
*/
void Host::destroy()
{
- if (!currentlyDestroying_) {
+ if (not currentlyDestroying_) {
currentlyDestroying_ = true;
onDestruction(*this);
host_list.erase(name_);
bool Mailbox::listen()
{
- return !this->empty() || (pimpl_->permanent_receiver && !pimpl_->done_comm_queue.empty());
+ return not this->empty() || (pimpl_->permanent_receiver && not pimpl_->done_comm_queue.empty());
}
smx_activity_t Mailbox::front()
current.push_back(task);
}
}
- while(!current.empty()){
+ while (not current.empty()) {
std::vector<SD_task_t> next;
for (auto t: current){
//Mark task
}
}
- if(!all_marked){
+ if (not all_marked) {
XBT_VERB("there is at least one cycle in your task graph");
xbt_dynar_foreach(dag,count,task){
if(task->kind != SD_TASK_COMM_E2E && task->predecessors->empty() && task->inputs->empty()){
}
}
//test if something has to be done for the next iteration
- while(!current.empty()){
+ while (not current.empty()) {
std::vector<SD_task_t> next;
//test if the current iteration is done
for (auto t: current){
}
}
- if (!acyclic_graph_detail(result)) {
+ if (not acyclic_graph_detail(result)) {
char* base = xbt_basename(filename);
XBT_ERROR("The DAX described in %s is not a DAG. It contains a cycle.", base);
free(base);
char *char_performer = agget(node, (char *) "performer");
char *char_order = agget(node, (char *) "order");
/* Tasks will execute on in a given "order" on a given set of "performer" hosts */
- int performer = ((!char_performer || !strcmp(char_performer,"")) ? -1:atoi(char_performer));
- int order = ((!char_order || !strcmp(char_order, ""))? -1:atoi(char_order));
+ int performer = ((not char_performer || not strcmp(char_performer, "")) ? -1 : atoi(char_performer));
+ int order = ((not char_order || not strcmp(char_order, "")) ? -1 : atoi(char_order));
if ((performer != -1 && order != -1) && performer < static_cast<int>(sg_host_count())) {
/* required parameters are given and less performers than hosts are required */
xbt_dynar_foreach(computer, i, task){
/* add dependency between the previous and the task to avoid parallel execution */
if(task){
- if(previous_task && !SD_task_dependency_exists(previous_task, task))
+ if (previous_task && not SD_task_dependency_exists(previous_task, task))
SD_task_dependency_add(nullptr, nullptr, previous_task, task);
SD_task_schedulel(task, 1, workstations[atoi(computer_name)]);
xbt_dict_free(&computers);
- if (result && !acyclic_graph_detail(result)) {
+ if (result && not acyclic_graph_detail(result)) {
char* base = xbt_basename(filename);
XBT_ERROR("The DOT described in %s is not a DAG. It contains a cycle.", base);
free(base);
sd_global->return_set->clear();
/* explore the runnable tasks */
- while(!sd_global->runnable_tasks->empty())
+ while (not sd_global->runnable_tasks->empty())
SD_task_run(*(sd_global->runnable_tasks->begin()));
double elapsed_time = 0.0;
double total_time = 0.0;
/* main loop */
- while (elapsed_time >= 0 && (how_long < 0 || 0.00001 < (how_long -total_time)) && !sd_global->watch_point_reached) {
+ while (elapsed_time >= 0 && (how_long < 0 || 0.00001 < (how_long - total_time)) &&
+ not sd_global->watch_point_reached) {
XBT_DEBUG("Total time: %f", total_time);
if (SD_task_get_state(succ) == SD_SCHEDULED && succ->predecessors->empty() && succ->inputs->empty())
SD_task_set_state(succ, SD_RUNNABLE);
- if (SD_task_get_state(succ) == SD_RUNNABLE && !sd_global->watch_point_reached)
+ if (SD_task_get_state(succ) == SD_RUNNABLE && not sd_global->watch_point_reached)
SD_task_run(succ);
}
task->successors->clear();
SD_task_get_name(output), SD_task_get_name(comm_dst), comm_dst->predecessors->size());
SD_task_set_state(comm_dst, SD_SCHEDULABLE);
}
- if (SD_task_get_state(output) == SD_RUNNABLE && !sd_global->watch_point_reached)
+ if (SD_task_get_state(output) == SD_RUNNABLE && not sd_global->watch_point_reached)
SD_task_run(output);
}
task->outputs->clear();
}
}
- if (!sd_global->watch_point_reached && how_long < 0 && !sd_global->initial_tasks->empty()) {
+ if (not sd_global->watch_point_reached && how_long < 0 && not sd_global->initial_tasks->empty()) {
XBT_WARN("Simulation is finished but %zu tasks are still not done", sd_global->initial_tasks->size());
for (const auto& t : *sd_global->initial_tasks)
XBT_WARN("%s is in %s state", SD_task_get_name(t), __get_state_name(SD_task_get_state(t)));
XBT_DEBUG("Destroying task %s...", SD_task_get_name(task));
/* First Remove all dependencies associated with the task. */
- while (!task->predecessors->empty())
+ while (not task->predecessors->empty())
SD_task_dependency_remove(*(task->predecessors->begin()), task);
- while (!task->inputs->empty())
+ while (not task->inputs->empty())
SD_task_dependency_remove(*(task->inputs->begin()), task);
- while (!task->successors->empty())
+ while (not task->successors->empty())
SD_task_dependency_remove(task, *(task->successors->begin()));
- while (!task->outputs->empty())
- SD_task_dependency_remove(task, *(task->outputs->begin()));
+ while (not task->outputs->empty())
+ SD_task_dependency_remove(task, *(task->outputs->begin()));
if (task->state == SD_SCHEDULED || task->state == SD_RUNNABLE)
__SD_task_destroy_scheduling_data(task);
XBT_VERB("Schedule computation task %s on %zu host(s)", task->name, task->allocation->size());
if (task->kind == SD_TASK_COMP_SEQ) {
- if (!task->flops_amount){ /*This task has failed and is rescheduled. Reset the flops_amount*/
+ if (not task->flops_amount) { /*This task has failed and is rescheduled. Reset the flops_amount*/
task->flops_amount = xbt_new0(double, 1);
task->flops_amount[0] = task->amount;
}
XBT_INFO(" - available speed: %.2f", sg_host_get_available_speed(host));
props = host->properties();
- if (!xbt_dict_is_empty(props)){
+ if (not xbt_dict_is_empty(props)) {
XBT_INFO(" - properties:");
xbt_dict_cursor_t cursor = nullptr;
char* key;
int j;
for (j = i = 1; i < *argc; i++) {
- if (!strncmp(argv[i], "--cfg=", strlen("--cfg="))) {
+ if (not strncmp(argv[i], "--cfg=", strlen("--cfg="))) {
char *opt = strchr(argv[i], '=');
opt++;
xbt_cfg_set_parse(opt);
XBT_DEBUG("Did apply '%s' as config setting", opt);
- } else if (!strcmp(argv[i], "--version")) {
+ } else if (not strcmp(argv[i], "--version")) {
printf("%s\n", SIMGRID_VERSION_STRING);
shall_exit = 1;
- } else if (!strcmp(argv[i], "--cfg-help") || !strcmp(argv[i], "--help")) {
+ } else if (not strcmp(argv[i], "--cfg-help") || not strcmp(argv[i], "--help")) {
printf("Description of the configuration accepted by this simulator:\n");
xbt_cfg_help();
printf(
"\n"
);
shall_exit = 1;
- } else if (!strcmp(argv[i], "--help-aliases")) {
+ } else if (not strcmp(argv[i], "--help-aliases")) {
printf("Here is a list of all deprecated option names, with their replacement.\n");
xbt_cfg_aliases();
printf("Please consider using the recent names\n");
shall_exit = 1;
- } else if (!strcmp(argv[i], "--help-models")) {
+ } else if (not strcmp(argv[i], "--help-models")) {
model_help("host", surf_host_model_description);
printf("\n");
model_help("CPU", surf_cpu_model_description);
surf_optimization_mode_description[k].description);
printf("Both network and CPU models have 'Lazy' as default optimization level\n\n");
shall_exit = 1;
- } else if (!strcmp(argv[i], "--help-tracing")) {
+ } else if (not strcmp(argv[i], "--help-tracing")) {
TRACE_help (1);
shall_exit = 1;
} else {
if (val==nullptr || val[0] == '\0')
return;
- if (!strcmp(val, "help")) {
+ if (not strcmp(val, "help")) {
model_help("plugin", surf_plugin_description);
sg_cfg_exit_early();
}
xbt_assert(_sg_cfg_init_status < 2, "Cannot change the model after the initialization");
char *val = xbt_cfg_get_string(name);
- if (!strcmp(val, "help")) {
+ if (not strcmp(val, "help")) {
model_help("host", surf_host_model_description);
sg_cfg_exit_early();
}
xbt_assert(_sg_cfg_init_status < 2, "Cannot change the model after the initialization");
char *val = xbt_cfg_get_string(name);
- if (!strcmp(val, "help")) {
+ if (not strcmp(val, "help")) {
model_help("CPU", surf_cpu_model_description);
sg_cfg_exit_early();
}
xbt_assert(_sg_cfg_init_status < 2, "Cannot change the model after the initialization");
char *val = xbt_cfg_get_string(name);
- if (!strcmp(val, "help")) {
+ if (not strcmp(val, "help")) {
model_help("optimization", surf_optimization_mode_description);
sg_cfg_exit_early();
}
xbt_assert(_sg_cfg_init_status < 2, "Cannot change the model after the initialization");
char *val = xbt_cfg_get_string(name);
- if (!strcmp(val, "help")) {
+ if (not strcmp(val, "help")) {
model_help("storage", surf_storage_model_description);
sg_cfg_exit_early();
}
xbt_assert(_sg_cfg_init_status < 2, "Cannot change the model after the initialization");
char *val = xbt_cfg_get_string(name);
- if (!strcmp(val, "help")) {
+ if (not strcmp(val, "help")) {
model_help("network", surf_network_model_description);
sg_cfg_exit_early();
}
static void _sg_cfg_cb_contexts_parallel_mode(const char *name)
{
const char* mode_name = xbt_cfg_get_string(name);
- if (!strcmp(mode_name, "posix")) {
+ if (not strcmp(mode_name, "posix")) {
SIMIX_context_set_parallel_mode(XBT_PARMAP_POSIX);
- }
- else if (!strcmp(mode_name, "futex")) {
+ } else if (not strcmp(mode_name, "futex")) {
SIMIX_context_set_parallel_mode(XBT_PARMAP_FUTEX);
- }
- else if (!strcmp(mode_name, "busy_wait")) {
+ } else if (not strcmp(mode_name, "busy_wait")) {
SIMIX_context_set_parallel_mode(XBT_PARMAP_BUSY_WAIT);
}
else {
/* cancel non-blocking communications */
smx_activity_t synchro = static_cast<smx_activity_t>(process->comms.front());
- while (!process->comms.empty()) {
+ while (not process->comms.empty()) {
simgrid::kernel::activity::Comm *comm = static_cast<simgrid::kernel::activity::Comm*>(synchro);
/* make sure no one will finish the comm after this process is destroyed,
/** This process will be terminated automatically when the last non-daemon process finishes */
void ActorImpl::daemonize()
{
- if (!daemon) {
+ if (not daemon) {
daemon = true;
simix_global->daemons.push_back(this);
SIMIX_process_on_exit(this, dying_daemon, this);
maestro->name = "";
maestro->data = nullptr;
- if (!code) {
+ if (not code) {
maestro->context = SIMIX_context_new(std::function<void()>(), nullptr, maestro);
} else {
- if (!simix_global)
+ if (not simix_global)
xbt_die("simix is not initialized, please call MSG_init first");
maestro->context =
simix_global->context_factory->create_maestro(code, maestro);
process->code = nullptr;
XBT_VERB("Create context %s", process->name.c_str());
- if (!simix_global)
+ if (not simix_global)
xbt_die("simix is not initialized, please call MSG_init first");
process->context = simix_global->context_factory->attach(
simix_global->cleanup_process_function, process);
TRACE_msg_process_create(process->cname(), process->pid, process->host);
auto context = dynamic_cast<simgrid::kernel::context::AttachContext*>(process->context);
- if (!context)
+ if (not context)
xbt_die("Not a suitable context");
context->attach_start();
void SIMIX_process_detach()
{
auto context = dynamic_cast<simgrid::kernel::context::AttachContext*>(SIMIX_context_self());
- if (!context)
+ if (not context)
xbt_die("Not a suitable context");
simix_global->cleanup_process_function(context->process());
process->waiting_synchro = nullptr;
}
- if(!xbt_dynar_member(simix_global->process_to_run, &(process)) && process != issuer) {
+ if (not xbt_dynar_member(simix_global->process_to_run, &(process)) && process != issuer) {
XBT_DEBUG("Inserting %s in the to_run list", process->name.c_str());
xbt_dynar_push_as(simix_global->process_to_run, smx_actor_t, process);
}
simgrid::kernel::activity::Sleep *sleep = dynamic_cast<simgrid::kernel::activity::Sleep*>(process->waiting_synchro);
if (sleep != nullptr) {
SIMIX_process_sleep_destroy(process->waiting_synchro);
- if (!xbt_dynar_member(simix_global->process_to_run, &(process)) && process != SIMIX_process_self()) {
+ if (not xbt_dynar_member(simix_global->process_to_run, &(process)) && process != SIMIX_process_self()) {
XBT_DEBUG("Inserting %s in the to_run list", process->name.c_str());
xbt_dynar_push_as(simix_global->process_to_run, smx_actor_t, process);
}
return;
}
- if (!process->suspended)
+ if (not process->suspended)
return;
process->suspended = 0;
{
smx_actor_t self = SIMIX_process_self();
- if (!self) {
+ if (not self) {
return nullptr;
}
return self->data;
if (sleep->surf_sleep) {
sleep->surf_sleep->cancel();
- while (!sleep->simcalls.empty()) {
+ while (not sleep->simcalls.empty()) {
smx_simcall_t simcall = sleep->simcalls.front();
sleep->simcalls.pop_front();
simcall_process_sleep__set__result(simcall, SIMIX_DONE);
void SIMIX_process_on_exit_runall(smx_actor_t process) {
s_smx_process_exit_fun_t exit_fun;
smx_process_exit_status_t exit_status = (process->context->iwannadie) ? SMX_EXIT_FAILURE : SMX_EXIT_SUCCESS;
- while (!process->on_exit.empty()) {
+ while (not process->on_exit.empty()) {
exit_fun = process->on_exit.back();
(exit_fun.fun)((void*)exit_status, exit_fun.arg);
process->on_exit.pop_back();
*/
smx_mutex_t simcall_mutex_init()
{
- if(!simix_global) {
+ if (not simix_global) {
fprintf(stderr,"You must run MSG_init before using MSG\n"); // We can't use xbt_die since we may get there before the initialization
xbt_abort();
}
/* This check should be useless and slows everyone. Reactivate if you see something
* weird in process scheduling.
*/
-/* if(!xbt_dynar_member(simix_global->process_to_run, &(simcall->issuer))) */
+ /* if(not xbt_dynar_member(simix_global->process_to_run, &(simcall->issuer))) */
xbt_dynar_push_as(simix_global->process_to_run, smx_actor_t, simcall->issuer);
/* else DIE_IMPOSSIBLE; */
}
{
xbt_assert(simix_global->context_factory == nullptr);
-#if HAVE_THREAD_CONTEXTS && !HAVE_THREAD_LOCAL_STORAGE
+#if HAVE_THREAD_CONTEXTS && not HAVE_THREAD_LOCAL_STORAGE
/* the __thread storage class is not available on this platform:
* use getspecific/setspecific instead to store the current context in each thread */
xbt_os_thread_key_create(&smx_current_context_key);
* growing downward (PTH_STACKGROWTH == -1). Protected pages need to be put
* after the stack when PTH_STACKGROWTH == 1. */
- if (smx_context_guard_size > 0 && !MC_is_active()) {
+ if (smx_context_guard_size > 0 && not MC_is_active()) {
#if !defined(PTH_STACKGROWTH) || (PTH_STACKGROWTH != -1)
static int warned_once = 0;
- if (!warned_once) {
+ if (not warned_once) {
XBT_WARN("Stack overflow protection is known to be broken on your system. Either stack grows upwards, or it was not even tested properly.");
warned_once = 1;
}
void SIMIX_context_stack_delete(void *stack)
{
- if (!stack)
+ if (not stack)
return;
#if HAVE_VALGRIND_H
#endif
#ifndef _WIN32
- if (smx_context_guard_size > 0 && !MC_is_active()) {
+ if (smx_context_guard_size > 0 && not MC_is_active()) {
stack = (char *)stack - smx_context_guard_size;
if (mprotect(stack, smx_context_guard_size, PROT_READ | PROT_WRITE) == -1) {
XBT_WARN("Failed to remove page protection: %s", strerror(errno));
if (nb_threads<=0) {
nb_threads = xbt_os_get_numcores();
XBT_INFO("Auto-setting contexts/nthreads to %d",nb_threads);
- }
+ }
#if !HAVE_THREAD_CONTEXTS
xbt_assert(nb_threads == 1, "Parallel runs are impossible when the pthreads are missing.");
#endif
try {
parse_status = surf_parse();
surf_parse_close();
- xbt_assert(!parse_status, "Parse error at %s:%d", file,surf_parse_lineno);
+ xbt_assert(not parse_status, "Parse error at %s:%d", file, surf_parse_lineno);
}
catch (xbt_ex& e) {
XBT_ERROR("Unrecoverable error at %s:%d. The full exception stack follows, in case it helps you to diagnose the problem.",
memset(&process,0,sizeof(process));
sg_host_t host = sg_host_by_name(process_host);
- if (!host)
+ if (not host)
THROWF(arg_error, 0, "Host '%s' unknown", process_host);
process.host = host->cname();
simgrid::mc::Client::initialize();
#endif
- if (!simix_global) {
+ if (not simix_global) {
simix_global = std::unique_ptr<simgrid::simix::Global>(new simgrid::simix::Global());
simgrid::simix::ActorImpl proc;
xbt_assert(s != nullptr, "Storage not found for name %s", name);
});
}
- if (!simix_timers)
+ if (not simix_timers)
simix_timers = xbt_heap_new(8, [](void* p) {
delete static_cast<smx_timer_t>(p);
});
smx_cleaned = 1;
XBT_DEBUG("SIMIX_clean called. Simulation's over.");
- if (!xbt_dynar_is_empty(simix_global->process_to_run) && SIMIX_get_clock() <= 0.0) {
+ if (not xbt_dynar_is_empty(simix_global->process_to_run) && SIMIX_get_clock() <= 0.0) {
XBT_CRITICAL(" ");
XBT_CRITICAL("The time is still 0, and you still have processes ready to run.");
XBT_CRITICAL("It seems that you forgot to run the simulation that you setup.");
task();
simix_global->tasksTemp.clear();
- } while (!simix_global->tasks.empty());
+ } while (not simix_global->tasks.empty());
return true;
}
SIMIX_execute_tasks();
- while (!xbt_dynar_is_empty(simix_global->process_to_run)) {
+ while (not xbt_dynar_is_empty(simix_global->process_to_run)) {
XBT_DEBUG("New Sub-Schedule Round; size(queue)=%lu", xbt_dynar_length(simix_global->process_to_run));
/* Run all processes that are ready to run, possibly in parallel */
XBT_DEBUG("### time %f, #processes %zu, #to_run %lu", time, simix_global->process_list.size(),
xbt_dynar_length(simix_global->process_to_run));
+ if (xbt_dynar_is_empty(simix_global->process_to_run) && not simix_global->process_list.empty())
+ simgrid::simix::onDeadlock();
- if (xbt_dynar_is_empty(simix_global->process_to_run) &&
- !simix_global->process_list.empty())
- simgrid::simix::onDeadlock();
-
- } while (time > -1.0 || !xbt_dynar_is_empty(simix_global->process_to_run));
+ } while (time > -1.0 || not xbt_dynar_is_empty(simix_global->process_to_run));
if (simix_global->process_list.size() != 0) {
Host::Host()
{
- if (!Host::EXTENSION_ID.valid())
+ if (not Host::EXTENSION_ID.valid())
Host::EXTENSION_ID = s4u::Host::extension_create<simix::Host>();
simgrid::simix::ActorImpl act;
arg->properties = properties;
arg->auto_restart = auto_restart;
- if (host->isOff() && !xbt_dict_get_or_null(watched_hosts_lib, host->cname())) {
+ if (host->isOff() && not xbt_dict_get_or_null(watched_hosts_lib, host->cname())) {
xbt_dict_set(watched_hosts_lib, host->cname(), host, nullptr);
XBT_DEBUG("Push host %s to watched_hosts_lib because state == SURF_RESOURCE_OFF", host->cname());
}
simgrid::kernel::activity::Exec *exec = new simgrid::kernel::activity::Exec(name, issuer->host);
/* set surf's action */
- if (!MC_is_active() && !MC_record_replay_is_active()) {
+ if (not MC_is_active() && not MC_record_replay_is_active()) {
exec->surf_exec = issuer->host->pimpl_cpu->execution_start(flops_amount);
exec->surf_exec->setData(exec);
}
/* set surf's synchro */
- if (!MC_is_active() && !MC_record_replay_is_active()) {
+ if (not MC_is_active() && not MC_record_replay_is_active()) {
exec->surf_exec = surf_host_model->executeParallelTask(host_nb, host_list_cpy, flops_amount, bytes_amount, rate);
exec->surf_exec->setData(exec);
if (timeout > 0) {
} else if (comm->type == SIMIX_COMM_RECEIVE) {
other_user_data = comm->dst_data;
}
- if (comm->type == type &&
- (! match_fun || match_fun(this_user_data, other_user_data, synchro)) &&
- (!comm->match_fun || comm->match_fun(other_user_data, this_user_data, my_synchro))) {
+ if (comm->type == type && (!match_fun || match_fun(this_user_data, other_user_data, synchro)) &&
+ (not comm->match_fun || comm->match_fun(other_user_data, this_user_data, my_synchro))) {
XBT_DEBUG("Found a matching communication synchro %p", comm);
if (remove_matching)
deque->erase(it);
simgrid::kernel::activity::Comm* other_comm =
_find_matching_comm(&mbox->comm_queue, SIMIX_COMM_RECEIVE, match_fun, data, this_comm, /*remove_matching*/ true);
- if (!other_comm) {
+ if (not other_comm) {
other_comm = this_comm;
if (mbox->permanent_receiver!=nullptr){
other_comm = _find_matching_comm(&mbox->done_comm_queue, SIMIX_COMM_SEND, match_fun, data, this_synchro,
/*remove_matching*/ true);
//if not found, assume the receiver came first, register it to the mailbox in the classical way
- if (!other_comm) {
+ if (not other_comm) {
XBT_DEBUG("We have messages in the permanent receive list, but not the one we are looking for, pushing request into list");
other_comm = this_synchro;
mbox->push(this_synchro);
other_comm = _find_matching_comm(&mbox->comm_queue, SIMIX_COMM_SEND, match_fun, data, this_synchro,
/*remove_matching*/ true);
- if (!other_comm) {
+ if (not other_comm) {
XBT_DEBUG("Receive pushed first %zu", mbox->comm_queue.size());
other_comm = this_synchro;
mbox->push(this_synchro);
smx_type = SIMIX_COMM_SEND;
}
smx_activity_t other_synchro=nullptr;
- if (mbox->permanent_receiver != nullptr && !mbox->done_comm_queue.empty()) {
+ if (mbox->permanent_receiver != nullptr && not mbox->done_comm_queue.empty()) {
XBT_DEBUG("first check in the permanent recv mailbox, to see if we already got something");
other_synchro = _find_matching_comm(&mbox->done_comm_queue,
(e_smx_comm_type_t) smx_type, match_fun, data, this_comm,/*remove_matching*/false);
}
- if (!other_synchro){
+ if (not other_synchro) {
XBT_DEBUG("check if we have more luck in the normal mailbox");
other_synchro = _find_matching_comm(&mbox->comm_queue,
(e_smx_comm_type_t) smx_type, match_fun, data, this_comm,/*remove_matching*/false);
simgrid::kernel::activity::Comm *comm = static_cast<simgrid::kernel::activity::Comm*>(synchro);
unsigned int destroy_count = 0;
- while (!synchro->simcalls.empty()) {
+ while (not synchro->simcalls.empty()) {
smx_simcall_t simcall = synchro->simcalls.front();
synchro->simcalls.pop_front();
SIMIX_timer_remove(simcall->timer);
simcall->timer = nullptr;
}
- if (!MC_is_active() && !MC_record_replay_is_active())
+ if (not MC_is_active() && not MC_record_replay_is_active())
simcall_comm_waitany__set__result(simcall, xbt_dynar_search(simcall_comm_waitany__get__comms(simcall), &synchro));
}
size_t buff_size = comm->src_buff_size;
/* If there is no data to copy then return */
- if (!comm->src_buff || !comm->dst_buff || comm->copied)
+ if (not comm->src_buff || not comm->dst_buff || comm->copied)
return;
XBT_DEBUG("Copying comm %p data from %s (%p) -> %s (%p) (%zu bytes)", comm,
void Mutex::unlock(smx_actor_t issuer)
{
XBT_IN("(%p, %p)", this, issuer);
- if(!this->locked)
+ if (not this->locked)
THROWF(mismatch_error, 0, "Cannot release that mutex: it was not locked.");
/* If the mutex is not owned by the issuer, that's not good */
SmpiHost::SmpiHost(simgrid::s4u::Host *ptr) : host(ptr)
{
- if (!SmpiHost::EXTENSION_ID.valid())
+ if (not SmpiHost::EXTENSION_ID.valid())
SmpiHost::EXTENSION_ID = simgrid::s4u::Host::extension_create<SmpiHost>();
const char* orecv_string = host->property("smpi/or");
block_size = extent * send_count;
- if (!is_2dmesh(num_procs, &X, &Y))
+ if (not is_2dmesh(num_procs, &X, &Y))
THROWF(arg_error,0, "allgather_2dmesh algorithm can't be used with this number of processes! ");
my_row_base = (rank / Y) * Y;
num_procs = comm->size();
extent = send_type->get_extent();
- if (!is_3dmesh(num_procs, &X, &Y, &Z))
+ if (not is_3dmesh(num_procs, &X, &Y, &Z))
THROWF(arg_error,0, "allgather_3dmesh algorithm can't be used with this number of processes! ");
if(comm->get_leaders_comm()==MPI_COMM_NULL){
comm->init_smp();
}
-
- if(!comm->is_uniform() || !comm->is_blocked())
+
+ if (not comm->is_uniform() || not comm->is_blocked())
THROWF(arg_error,0, "allgather MVAPICH2 smp algorithm can't be used with irregular deployment. Please insure that processes deployed on the same node are contiguous and that each node has the same number of processes");
if (recvcnt == 0) {
displs = static_cast<int *>(xbt_malloc(sizeof (int) * leader_comm_size));
recvcnts = static_cast<int *>(xbt_malloc(sizeof (int) * leader_comm_size));
- if (!displs || !recvcnts) {
- return MPI_ERR_OTHER;
+ if (not displs || not recvcnts) {
+ return MPI_ERR_OTHER;
}
recvcnts[0] = node_sizes[0] * recvcnt;
displs[0] = 0;
num_reqs = (2 * num_procs) - 2;
reqs = (MPI_Request *) xbt_malloc(num_reqs * sizeof(MPI_Request));
- if (!reqs) {
+ if (not reqs) {
printf("allgather-spreading-simple.c:40: cannot allocate memory\n");
MPI_Finalize();
exit(0);
min = 32768*8 / recvtype_extent;
/* Handle the case where the datatype extent is larger than
* the pipeline size. */
- if (!min)
+ if (not min)
min = 1;
sidx = rank;
rbuf = (char *)recvbuf + ((displs[ridx] + roffset) * recvtype_extent);
/* Protect against wrap-around of indices */
- if (!tosend)
+ if (not tosend)
sendnow = 0;
- if (!torecv)
+ if (not torecv)
recvnow = 0;
/* Communicate */
- if (!sendnow && !recvnow) {
- /* Don't do anything. This case is possible if two
- * consecutive processes contribute 0 bytes each. */
- }
- else if (!sendnow) { /* If there's no data to send, just do a recv call */
- Request::recv(rbuf, recvnow, recvtype, left, COLL_TAG_ALLGATHERV, comm, &status);
+ if (not sendnow && not recvnow) {
+ /* Don't do anything. This case is possible if two
+ * consecutive processes contribute 0 bytes each. */
+ } else if (not sendnow) { /* If there's no data to send, just do a recv call */
+ Request::recv(rbuf, recvnow, recvtype, left, COLL_TAG_ALLGATHERV, comm, &status);
- torecv -= recvnow;
- }
- else if (!recvnow) { /* If there's no data to receive, just do a send call */
- Request::send(sbuf, sendnow, recvtype, right, COLL_TAG_ALLGATHERV, comm);
+ torecv -= recvnow;
+ } else if (not recvnow) { /* If there's no data to receive, just do a send call */
+ Request::send(sbuf, sendnow, recvtype, right, COLL_TAG_ALLGATHERV, comm);
- tosend -= sendnow;
+ tosend -= sendnow;
}
else { /* There's data to be sent and received */
Request::sendrecv(sbuf, sendnow, recvtype, right, COLL_TAG_ALLGATHERV,
int inter_comm_size = (comm_size + num_core - 1) / num_core;
- if (!rank) {
+ if (not rank) {
//printf("intra com size = %d\n",num_core);
//printf("inter com size = %d\n",inter_comm_size);
}
int inter_comm_size = (comm_size + num_core - 1) / num_core;
- if (!rank) {
+ if (not rank) {
//printf("intra com size = %d\n",num_core);
//printf("inter com size = %d\n",inter_comm_size);
}
num_procs = comm->size();
extent = send_type->get_extent();
- if (!alltoall_check_is_2dmesh(num_procs, &X, &Y))
+ if (not alltoall_check_is_2dmesh(num_procs, &X, &Y))
return MPI_ERR_OTHER;
my_row_base = (rank / Y) * Y;
num_procs = comm->size();
extent = send_type->get_extent();
- if (!alltoall_check_is_3dmesh(num_procs, &X, &Y, &Z))
+ if (not alltoall_check_is_3dmesh(num_procs, &X, &Y, &Z))
return MPI_ERR_OTHER;
num_reqs = X;
#endif
) {
- if (!is_contig || !is_homogeneous) {
- tmp_buf=(void *)smpi_get_tmp_sendbuffer(nbytes);
-
- /* TODO: Pipeline the packing and communication */
- // position = 0;
-/* if (rank == root) {*/
-/* mpi_errno =*/
-/* MPIR_Pack_impl(buffer, count, datatype, tmp_buf, nbytes, &position);*/
-/* if (mpi_errno)*/
-/* MPIU_ERR_POP(mpi_errno);*/
-/* }*/
+ if (not is_contig || not is_homogeneous) {
+ tmp_buf = (void*)smpi_get_tmp_sendbuffer(nbytes);
+
+ /* TODO: Pipeline the packing and communication */
+ // position = 0;
+ /* if (rank == root) {*/
+ /* mpi_errno =*/
+ /* MPIR_Pack_impl(buffer, count, datatype, tmp_buf, nbytes, &position);*/
+ /* if (mpi_errno)*/
+ /* MPIU_ERR_POP(mpi_errno);*/
+ /* }*/
}
shmem_comm = comm->get_intra_comm();
- if (!is_contig || !is_homogeneous) {
- mpi_errno =
- MPIR_Bcast_inter_node_helper_MV2(tmp_buf, nbytes, MPI_BYTE,
- root, comm);
+ if (not is_contig || not is_homogeneous) {
+ mpi_errno = MPIR_Bcast_inter_node_helper_MV2(tmp_buf, nbytes, MPI_BYTE, root, comm);
} else {
mpi_errno =
MPIR_Bcast_inter_node_helper_MV2(buffer, count, datatype, root,
/* We are now done with the inter-node phase */
if (nbytes <= mv2_knomial_intra_node_threshold) {
- if (!is_contig || !is_homogeneous) {
- mpi_errno = MPIR_Shmem_Bcast_MV2(tmp_buf, nbytes, MPI_BYTE,
- root, shmem_comm);
+ if (not is_contig || not is_homogeneous) {
+ mpi_errno = MPIR_Shmem_Bcast_MV2(tmp_buf, nbytes, MPI_BYTE, root, shmem_comm);
} else {
mpi_errno = MPIR_Shmem_Bcast_MV2(buffer, count, datatype,
root, shmem_comm);
}
} else {
- if (!is_contig || !is_homogeneous) {
- mpi_errno =
- MPIR_Knomial_Bcast_intra_node_MV2(tmp_buf, nbytes,
- MPI_BYTE,
- INTRA_NODE_ROOT,
- shmem_comm);
+ if (not is_contig || not is_homogeneous) {
+ mpi_errno = MPIR_Knomial_Bcast_intra_node_MV2(tmp_buf, nbytes, MPI_BYTE, INTRA_NODE_ROOT, shmem_comm);
} else {
mpi_errno =
MPIR_Knomial_Bcast_intra_node_MV2(buffer, count,
xbt_die("we didn't receive enough !");
}
- if (!is_contig || !is_homogeneous)
- {
- if (rank != root)
- {
- position = 0;
- mpi_errno = MPI_Unpack(tmp_buf, nbytes, &position, buffer,
- count, datatype, comm);
- if (mpi_errno) xbt_die("error when unpacking %d", mpi_errno);
- }
+ if (not is_contig || not is_homogeneous) {
+ if (rank != root) {
+ position = 0;
+ mpi_errno = MPI_Unpack(tmp_buf, nbytes, &position, buffer, count, datatype, comm);
+ if (mpi_errno)
+ xbt_die("error when unpacking %d", mpi_errno);
+ }
}
fn_exit:
rank = comm->rank();
tree = (ompi_coll_tree_t*)malloc(sizeof(ompi_coll_tree_t));
- if (!tree) {
- XBT_DEBUG("coll:tuned:topo_build_tree PANIC::out of memory");
- return NULL;
+ if (not tree) {
+ XBT_DEBUG("coll:tuned:topo_build_tree PANIC::out of memory");
+ return NULL;
}
tree->tree_root = MPI_UNDEFINED;
rank = comm->rank();
tree = (ompi_coll_tree_t*)malloc(sizeof(ompi_coll_tree_t));
- if (!tree) {
- XBT_DEBUG(
- "coll:tuned:topo_build_tree PANIC::out of memory");
- return NULL;
+ if (not tree) {
+ XBT_DEBUG("coll:tuned:topo_build_tree PANIC::out of memory");
+ return NULL;
}
tree->tree_root = MPI_UNDEFINED;
{
ompi_coll_tree_t *ptr;
- if ((!tree)||(!*tree)) {
- return MPI_SUCCESS;
+ if ((not tree) || (!*tree)) {
+ return MPI_SUCCESS;
}
ptr = *tree;
index = rank -root;
bmtree = (ompi_coll_tree_t*)malloc(sizeof(ompi_coll_tree_t));
- if (!bmtree) {
- XBT_DEBUG("coll:tuned:topo:build_bmtree PANIC out of memory");
- return NULL;
+ if (not bmtree) {
+ XBT_DEBUG("coll:tuned:topo:build_bmtree PANIC out of memory");
+ return NULL;
}
bmtree->tree_bmtree = 1;
vrank = (rank - root + size) % size;
bmtree = (ompi_coll_tree_t*)xbt_malloc(sizeof(ompi_coll_tree_t));
- if (!bmtree) {
- XBT_DEBUG("coll:tuned:topo:build_bmtree PANIC out of memory");
- return NULL;
+ if (not bmtree) {
+ XBT_DEBUG("coll:tuned:topo:build_bmtree PANIC out of memory");
+ return NULL;
}
bmtree->tree_bmtree = 1;
* Allocate space for topology arrays if needed
*/
chain = (ompi_coll_tree_t*)malloc( sizeof(ompi_coll_tree_t) );
- if (!chain) {
- XBT_DEBUG("coll:tuned:topo:build_chain PANIC out of memory");
- fflush(stdout);
- return NULL;
+ if (not chain) {
+ XBT_DEBUG("coll:tuned:topo:build_chain PANIC out of memory");
+ fflush(stdout);
+ return NULL;
}
chain->tree_root = MPI_UNDEFINED;
chain->tree_nextsize = -1;
/* leader_root is the rank of the leader of the root in leader_comm.
* leader_root is to be used as the root of the inter-leader gather ops
*/
- if (!comm->is_uniform()) {
- if (local_rank == 0) {
- int *displs = NULL;
- int *recvcnts = NULL;
- int *node_sizes;
- int i = 0;
- /* Node leaders have all the data. But, different nodes can have
- * different number of processes. Do a Gather first to get the
- * buffer lengths at each leader, followed by a Gatherv to move
- * the actual data */
+ if (not comm->is_uniform()) {
+ if (local_rank == 0) {
+ int* displs = NULL;
+ int* recvcnts = NULL;
+ int* node_sizes;
+ int i = 0;
+ /* Node leaders have all the data. But, different nodes can have
+ * different number of processes. Do a Gather first to get the
+ * buffer lengths at each leader, followed by a Gatherv to move
+ * the actual data */
+
+ if (leader_comm_rank == leader_root && root != leader_of_root) {
+ /* The root of the Gather operation is not a node-level
+ * leader and this process's rank in the leader_comm
+ * is the same as leader_root */
+ if (rank == root) {
+ leader_gather_buf =
+ smpi_get_tmp_recvbuffer(recvcnt * MAX(recvtype_extent, recvtype_true_extent) * comm_size);
+ } else {
+ leader_gather_buf =
+ smpi_get_tmp_sendbuffer(sendcnt * MAX(sendtype_extent, sendtype_true_extent) * comm_size);
+ }
+ if (leader_gather_buf == NULL) {
+ mpi_errno = MPI_ERR_OTHER;
+ return mpi_errno;
+ }
+ }
- if (leader_comm_rank == leader_root && root != leader_of_root) {
- /* The root of the Gather operation is not a node-level
- * leader and this process's rank in the leader_comm
- * is the same as leader_root */
- if(rank == root) {
- leader_gather_buf = smpi_get_tmp_recvbuffer(recvcnt *
- MAX(recvtype_extent,
- recvtype_true_extent) *
- comm_size);
- } else {
- leader_gather_buf = smpi_get_tmp_sendbuffer(sendcnt *
- MAX(sendtype_extent,
- sendtype_true_extent) *
- comm_size);
- }
- if (leader_gather_buf == NULL) {
- mpi_errno = MPI_ERR_OTHER;
- return mpi_errno;
- }
- }
+ node_sizes = comm->get_non_uniform_map();
- node_sizes = comm->get_non_uniform_map();
+ if (leader_comm_rank == leader_root) {
+ displs = static_cast<int*>(xbt_malloc(sizeof(int) * leader_comm_size));
+ recvcnts = static_cast<int*>(xbt_malloc(sizeof(int) * leader_comm_size));
+ if (not displs || not recvcnts) {
+ mpi_errno = MPI_ERR_OTHER;
+ return mpi_errno;
+ }
+ }
- if (leader_comm_rank == leader_root) {
- displs = static_cast<int *>(xbt_malloc(sizeof (int) * leader_comm_size));
- recvcnts = static_cast<int *>(xbt_malloc(sizeof (int) * leader_comm_size));
- if (!displs || !recvcnts) {
- mpi_errno = MPI_ERR_OTHER;
- return mpi_errno;
- }
- }
+ if (root == leader_of_root) {
+ /* The root of the gather operation is also the node
+ * leader. Receive into recvbuf and we are done */
+ if (leader_comm_rank == leader_root) {
+ recvcnts[0] = node_sizes[0] * recvcnt;
+ displs[0] = 0;
- if (root == leader_of_root) {
- /* The root of the gather operation is also the node
- * leader. Receive into recvbuf and we are done */
- if (leader_comm_rank == leader_root) {
- recvcnts[0] = node_sizes[0] * recvcnt;
- displs[0] = 0;
-
- for (i = 1; i < leader_comm_size; i++) {
- displs[i] = displs[i - 1] + node_sizes[i - 1] * recvcnt;
- recvcnts[i] = node_sizes[i] * recvcnt;
- }
- }
- Colls::gatherv(tmp_buf,
- local_size * nbytes,
- MPI_BYTE, recvbuf, recvcnts,
- displs, recvtype,
- leader_root, leader_comm);
- } else {
- /* The root of the gather operation is not the node leader.
- * Receive into leader_gather_buf and then send
- * to the root */
- if (leader_comm_rank == leader_root) {
- recvcnts[0] = node_sizes[0] * nbytes;
- displs[0] = 0;
-
- for (i = 1; i < leader_comm_size; i++) {
- displs[i] = displs[i - 1] + node_sizes[i - 1] * nbytes;
- recvcnts[i] = node_sizes[i] * nbytes;
- }
- }
- Colls::gatherv(tmp_buf, local_size * nbytes,
- MPI_BYTE, leader_gather_buf,
- recvcnts, displs, MPI_BYTE,
- leader_root, leader_comm);
+ for (i = 1; i < leader_comm_size; i++) {
+ displs[i] = displs[i - 1] + node_sizes[i - 1] * recvcnt;
+ recvcnts[i] = node_sizes[i] * recvcnt;
}
- if (leader_comm_rank == leader_root) {
- xbt_free(displs);
- xbt_free(recvcnts);
+ }
+ Colls::gatherv(tmp_buf, local_size * nbytes, MPI_BYTE, recvbuf, recvcnts, displs, recvtype, leader_root,
+ leader_comm);
+ } else {
+ /* The root of the gather operation is not the node leader.
+ * Receive into leader_gather_buf and then send
+ * to the root */
+ if (leader_comm_rank == leader_root) {
+ recvcnts[0] = node_sizes[0] * nbytes;
+ displs[0] = 0;
+
+ for (i = 1; i < leader_comm_size; i++) {
+ displs[i] = displs[i - 1] + node_sizes[i - 1] * nbytes;
+ recvcnts[i] = node_sizes[i] * nbytes;
}
+ }
+ Colls::gatherv(tmp_buf, local_size * nbytes, MPI_BYTE, leader_gather_buf, recvcnts, displs, MPI_BYTE,
+ leader_root, leader_comm);
+ }
+ if (leader_comm_rank == leader_root) {
+ xbt_free(displs);
+ xbt_free(recvcnts);
}
+ }
} else {
/* All nodes have the same number of processes.
* Just do one Gather to get all
mask <<= 1;
}
- if (!is_commutative && (root != 0)){
+ if (not is_commutative && (root != 0)) {
if (rank == 0){
Request::send(recvbuf, count, datatype, root,tag, comm);
}else if (rank == root){
/* If this is a non-commutative operation we must copy
sendbuf to the accumbuf, in order to simplfy the loops */
- if ( (op!=MPI_OP_NULL && !op->is_commutative())) {
- Datatype::copy(
- (char*)sendtmpbuf, original_count, datatype,
- (char*)accumbuf, original_count, datatype);
+ if ((op != MPI_OP_NULL && not op->is_commutative())) {
+ Datatype::copy((char*)sendtmpbuf, original_count, datatype, (char*)accumbuf, original_count, datatype);
}
/* Allocate two buffers for incoming segments */
real_segment_size = true_extent + (count_by_segment - 1) * extent;
extent = datatype->get_extent();
/* If I'm not the root, then my recvbuf may not be valid, therefore
I have to allocate a temporary one */
- if (rank != root && !recvbuf) {
+ if (rank != root && not recvbuf) {
temporary_buffer=1;
recvbuf = (void *)smpi_get_tmp_recvbuffer(count * extent);
}
outgoing_data + recv_offset*true_extent,
incoming_data + recv_offset*true_extent,
&size, datatype);
- buf0_was_inout = !buf0_was_inout;
+ buf0_was_inout = not buf0_was_inout;
}
/* the next round of send/recv needs to happen within the block (of size
size = comm->size();
XBT_DEBUG("coll:tuned:reduce_scatter_ompi_basic_recursivehalving, rank %d", rank);
- if( (op!=MPI_OP_NULL && !op->is_commutative()))
+ if ((op != MPI_OP_NULL && not op->is_commutative()))
THROWF(arg_error,0, " reduce_scatter ompi_basic_recursivehalving can only be used for commutative operations! ");
/* Find displacements and the like */
}
if (leader_comm_size > 1 && local_rank == 0) {
- if (!comm->is_uniform()) {
- int *displs = NULL;
- int *sendcnts = NULL;
- int *node_sizes;
- int i = 0;
- node_sizes = comm->get_non_uniform_map();
-
- if (root != leader_of_root) {
- if (leader_comm_rank == leader_root) {
- displs = static_cast<int*>(xbt_malloc(sizeof (int) * leader_comm_size));
- sendcnts = static_cast<int*>(xbt_malloc(sizeof (int) * leader_comm_size));
- sendcnts[0] = node_sizes[0] * nbytes;
- displs[0] = 0;
-
- for (i = 1; i < leader_comm_size; i++) {
- displs[i] =
- displs[i - 1] + node_sizes[i - 1] * nbytes;
- sendcnts[i] = node_sizes[i] * nbytes;
- }
- }
- Colls::scatterv(leader_scatter_buf, sendcnts, displs,
- MPI_BYTE, tmp_buf, nbytes * local_size,
- MPI_BYTE, leader_root, leader_comm);
- } else {
- if (leader_comm_rank == leader_root) {
- displs = static_cast<int*>(xbt_malloc(sizeof (int) * leader_comm_size));
- sendcnts = static_cast<int*>(xbt_malloc(sizeof (int) * leader_comm_size));
- sendcnts[0] = node_sizes[0] * sendcnt;
- displs[0] = 0;
-
- for (i = 1; i < leader_comm_size; i++) {
- displs[i] =
- displs[i - 1] + node_sizes[i - 1] * sendcnt;
- sendcnts[i] = node_sizes[i] * sendcnt;
- }
- }
- Colls::scatterv(sendbuf, sendcnts, displs,
- sendtype, tmp_buf,
- nbytes * local_size, MPI_BYTE,
- leader_root, leader_comm);
+ if (not comm->is_uniform()) {
+ int* displs = NULL;
+ int* sendcnts = NULL;
+ int* node_sizes;
+ int i = 0;
+ node_sizes = comm->get_non_uniform_map();
+
+ if (root != leader_of_root) {
+ if (leader_comm_rank == leader_root) {
+ displs = static_cast<int*>(xbt_malloc(sizeof(int) * leader_comm_size));
+ sendcnts = static_cast<int*>(xbt_malloc(sizeof(int) * leader_comm_size));
+ sendcnts[0] = node_sizes[0] * nbytes;
+ displs[0] = 0;
+
+ for (i = 1; i < leader_comm_size; i++) {
+ displs[i] = displs[i - 1] + node_sizes[i - 1] * nbytes;
+ sendcnts[i] = node_sizes[i] * nbytes;
}
- if (leader_comm_rank == leader_root) {
- xbt_free(displs);
- xbt_free(sendcnts);
+ }
+ Colls::scatterv(leader_scatter_buf, sendcnts, displs, MPI_BYTE, tmp_buf, nbytes * local_size, MPI_BYTE,
+ leader_root, leader_comm);
+ } else {
+ if (leader_comm_rank == leader_root) {
+ displs = static_cast<int*>(xbt_malloc(sizeof(int) * leader_comm_size));
+ sendcnts = static_cast<int*>(xbt_malloc(sizeof(int) * leader_comm_size));
+ sendcnts[0] = node_sizes[0] * sendcnt;
+ displs[0] = 0;
+
+ for (i = 1; i < leader_comm_size; i++) {
+ displs[i] = displs[i - 1] + node_sizes[i - 1] * sendcnt;
+ sendcnts[i] = node_sizes[i] * sendcnt;
}
+ }
+ Colls::scatterv(sendbuf, sendcnts, displs, sendtype, tmp_buf, nbytes * local_size, MPI_BYTE, leader_root,
+ leader_comm);
+ }
+ if (leader_comm_rank == leader_root) {
+ xbt_free(displs);
+ xbt_free(sendcnts);
+ }
} else {
if (leader_of_root != root) {
mpi_errno =
}
if (leader_comm_size > 1 && local_rank == 0) {
- if (!comm->is_uniform()) {
- int *displs = NULL;
- int *sendcnts = NULL;
- int *node_sizes;
- int i = 0;
- node_sizes = comm->get_non_uniform_map();
-
- if (root != leader_of_root) {
- if (leader_comm_rank == leader_root) {
- displs = static_cast<int*>(xbt_malloc(sizeof (int) * leader_comm_size));
- sendcnts = static_cast<int*>(xbt_malloc(sizeof (int) * leader_comm_size));
- sendcnts[0] = node_sizes[0] * nbytes;
- displs[0] = 0;
-
- for (i = 1; i < leader_comm_size; i++) {
- displs[i] =
- displs[i - 1] + node_sizes[i - 1] * nbytes;
- sendcnts[i] = node_sizes[i] * nbytes;
- }
- }
- Colls::scatterv(leader_scatter_buf, sendcnts, displs,
- MPI_BYTE, tmp_buf, nbytes * local_size,
- MPI_BYTE, leader_root, leader_comm);
- } else {
- if (leader_comm_rank == leader_root) {
- displs = static_cast<int*>(xbt_malloc(sizeof (int) * leader_comm_size));
- sendcnts = static_cast<int*>(xbt_malloc(sizeof (int) * leader_comm_size));
- sendcnts[0] = node_sizes[0] * sendcnt;
- displs[0] = 0;
-
- for (i = 1; i < leader_comm_size; i++) {
- displs[i] =
- displs[i - 1] + node_sizes[i - 1] * sendcnt;
- sendcnts[i] = node_sizes[i] * sendcnt;
- }
- }
- Colls::scatterv(sendbuf, sendcnts, displs,
- sendtype, tmp_buf,
- nbytes * local_size, MPI_BYTE,
- leader_root, leader_comm);
+ if (not comm->is_uniform()) {
+ int* displs = NULL;
+ int* sendcnts = NULL;
+ int* node_sizes;
+ int i = 0;
+ node_sizes = comm->get_non_uniform_map();
+
+ if (root != leader_of_root) {
+ if (leader_comm_rank == leader_root) {
+ displs = static_cast<int*>(xbt_malloc(sizeof(int) * leader_comm_size));
+ sendcnts = static_cast<int*>(xbt_malloc(sizeof(int) * leader_comm_size));
+ sendcnts[0] = node_sizes[0] * nbytes;
+ displs[0] = 0;
+
+ for (i = 1; i < leader_comm_size; i++) {
+ displs[i] = displs[i - 1] + node_sizes[i - 1] * nbytes;
+ sendcnts[i] = node_sizes[i] * nbytes;
}
- if (leader_comm_rank == leader_root) {
- xbt_free(displs);
- xbt_free(sendcnts);
+ }
+ Colls::scatterv(leader_scatter_buf, sendcnts, displs, MPI_BYTE, tmp_buf, nbytes * local_size, MPI_BYTE,
+ leader_root, leader_comm);
+ } else {
+ if (leader_comm_rank == leader_root) {
+ displs = static_cast<int*>(xbt_malloc(sizeof(int) * leader_comm_size));
+ sendcnts = static_cast<int*>(xbt_malloc(sizeof(int) * leader_comm_size));
+ sendcnts[0] = node_sizes[0] * sendcnt;
+ displs[0] = 0;
+
+ for (i = 1; i < leader_comm_size; i++) {
+ displs[i] = displs[i - 1] + node_sizes[i - 1] * sendcnt;
+ sendcnts[i] = node_sizes[i] * sendcnt;
}
+ }
+ Colls::scatterv(sendbuf, sendcnts, displs, sendtype, tmp_buf, nbytes * local_size, MPI_BYTE, leader_root,
+ leader_comm);
+ }
+ if (leader_comm_rank == leader_root) {
+ xbt_free(displs);
+ xbt_free(sendcnts);
+ }
} else {
if (leader_of_root != root) {
mpi_errno =
if (NULL != tempbuf)
smpi_free_tmp_buffer(tempbuf);
- //!FIXME : store the tree, as done in ompi, instead of calculating it each time ?
+ // not FIXME : store the tree, as done in ompi, instead of calculating it each time ?
xbt_free(bmtree);
return MPI_SUCCESS;
//attempt to do a quick autotuning version of the collective,
-#define TRACE_AUTO_COLL(cat) if (TRACE_is_enabled()){\
- type_t type = PJ_type_get_or_null (#cat, PJ_type_get_root());\
- if (!type){\
- type=PJ_type_event_new(#cat, PJ_type_get_root());\
- }\
- char cont_name[25];\
- snprintf(cont_name,25, "rank-%d", smpi_process()->index());\
- val_t value = PJ_value_get_or_new(Colls::mpi_coll_##cat##_description[i].name,"1.0 1.0 1.0", type);\
- new NewEvent (SIMIX_get_clock(), PJ_container_get(cont_name), type, value);\
- }
+#define TRACE_AUTO_COLL(cat) \
+ if (TRACE_is_enabled()) { \
+ type_t type = PJ_type_get_or_null(#cat, PJ_type_get_root()); \
+ if (not type) { \
+ type = PJ_type_event_new(#cat, PJ_type_get_root()); \
+ } \
+ char cont_name[25]; \
+ snprintf(cont_name, 25, "rank-%d", smpi_process()->index()); \
+ val_t value = PJ_value_get_or_new(Colls::mpi_coll_##cat##_description[i].name, "1.0 1.0 1.0", type); \
+ new NewEvent(SIMIX_get_clock(), PJ_container_get(cont_name), type, value); \
+ }
-#define AUTOMATIC_COLL_BENCH(cat, ret, args, args2)\
- ret Coll_ ## cat ## _automatic:: cat (COLL_UNPAREN args)\
-{\
- double time1, time2, time_min=DBL_MAX;\
- int min_coll=-1, global_coll=-1;\
- int i;\
- double buf_in, buf_out, max_min=DBL_MAX;\
- for (i = 0; Colls::mpi_coll_##cat##_description[i].name; i++){\
- if(!strcmp(Colls::mpi_coll_##cat##_description[i].name, "automatic"))continue;\
- if(!strcmp(Colls::mpi_coll_##cat##_description[i].name, "default"))continue;\
- Coll_barrier_default::barrier(comm);\
- TRACE_AUTO_COLL(cat)\
- time1 = SIMIX_get_clock();\
- try {\
- ((int (*) args)\
- Colls::mpi_coll_##cat##_description[i].coll) args2 ;\
- }\
- catch (std::exception& ex) {\
- continue;\
- }\
- time2 = SIMIX_get_clock();\
- buf_out=time2-time1;\
- Coll_reduce_default::reduce((void*)&buf_out,(void*)&buf_in, 1, MPI_DOUBLE, MPI_MAX, 0,comm );\
- if(time2-time1<time_min){\
- min_coll=i;\
- time_min=time2-time1;\
- }\
- if(comm->rank()==0){\
- if(buf_in<max_min){\
- max_min=buf_in;\
- global_coll=i;\
- }\
- }\
- }\
- if(comm->rank()==0){\
- XBT_WARN("For rank 0, the quickest was %s : %f , but global was %s : %f at max",Colls::mpi_coll_##cat##_description[min_coll].name, time_min,Colls::mpi_coll_##cat##_description[global_coll].name, max_min);\
- }else\
- XBT_WARN("The quickest %s was %s on rank %d and took %f",#cat,Colls::mpi_coll_##cat##_description[min_coll].name, comm->rank(), time_min);\
- return (min_coll!=-1)?MPI_SUCCESS:MPI_ERR_INTERN;\
-}
+#define AUTOMATIC_COLL_BENCH(cat, ret, args, args2) \
+ ret Coll_##cat##_automatic::cat(COLL_UNPAREN args) \
+ { \
+ double time1, time2, time_min = DBL_MAX; \
+ int min_coll = -1, global_coll = -1; \
+ int i; \
+ double buf_in, buf_out, max_min = DBL_MAX; \
+ for (i = 0; Colls::mpi_coll_##cat##_description[i].name; i++) { \
+ if (not strcmp(Colls::mpi_coll_##cat##_description[i].name, "automatic")) \
+ continue; \
+ if (not strcmp(Colls::mpi_coll_##cat##_description[i].name, "default")) \
+ continue; \
+ Coll_barrier_default::barrier(comm); \
+ TRACE_AUTO_COLL(cat) \
+ time1 = SIMIX_get_clock(); \
+ try { \
+ ((int(*) args)Colls::mpi_coll_##cat##_description[i].coll) args2; \
+ } catch (std::exception & ex) { \
+ continue; \
+ } \
+ time2 = SIMIX_get_clock(); \
+ buf_out = time2 - time1; \
+ Coll_reduce_default::reduce((void*)&buf_out, (void*)&buf_in, 1, MPI_DOUBLE, MPI_MAX, 0, comm); \
+ if (time2 - time1 < time_min) { \
+ min_coll = i; \
+ time_min = time2 - time1; \
+ } \
+ if (comm->rank() == 0) { \
+ if (buf_in < max_min) { \
+ max_min = buf_in; \
+ global_coll = i; \
+ } \
+ } \
+ } \
+ if (comm->rank() == 0) { \
+ XBT_WARN("For rank 0, the quickest was %s : %f , but global was %s : %f at max", \
+ Colls::mpi_coll_##cat##_description[min_coll].name, time_min, \
+ Colls::mpi_coll_##cat##_description[global_coll].name, max_min); \
+ } else \
+ XBT_WARN("The quickest %s was %s on rank %d and took %f", #cat, \
+ Colls::mpi_coll_##cat##_description[min_coll].name, comm->rank(), time_min); \
+ return (min_coll != -1) ? MPI_SUCCESS : MPI_ERR_INTERN; \
+ }
namespace simgrid{
namespace smpi{
int rank = comm->rank();
int size = comm->size();
//non commutative case, use a working algo from openmpi
- if(op != MPI_OP_NULL && !op->is_commutative()){
+ if (op != MPI_OP_NULL && not op->is_commutative()) {
return Coll_reduce_ompi_basic_linear::reduce(sendtmpbuf, recvbuf, count, datatype, op, root, comm);
}
int index = 0;
for (int src = 0; src < size; src++) {
if (src != root) {
- if (!smpi_process()->replaying())
+ if (not smpi_process()->replaying())
tmpbufs[index] = xbt_malloc(count * dataext);
else
tmpbufs[index] = smpi_get_tmp_sendbuffer(count * dataext);
while (pof2 <= communicator_size) pof2 <<= 1;
pof2 >>= 1;
-
- if ((count < pof2) || (message_size < 2048) || (op!=MPI_OP_NULL && !op->is_commutative())) {
- return Coll_reduce_binomial::reduce (sendbuf, recvbuf, count, datatype, op, root, comm);
+ if ((count < pof2) || (message_size < 2048) || (op != MPI_OP_NULL && not op->is_commutative())) {
+ return Coll_reduce_binomial::reduce(sendbuf, recvbuf, count, datatype, op, root, comm);
}
return Coll_reduce_scatter_gather::reduce(sendbuf, recvbuf, count, datatype, op, root, comm/*, module,
segsize, max_requests*/);
if( (op==MPI_OP_NULL || op->is_commutative()) && total_message_size > 524288) {
return Coll_reduce_scatter_mpich_pair::reduce_scatter (sbuf, rbuf, rcounts,
dtype, op,
- comm);
- }else if ((op!=MPI_OP_NULL && !op->is_commutative())) {
- int is_block_regular = 1;
- for (i = 0; i < (comm_size - 1); ++i) {
- if (rcounts[i] != rcounts[i+1]) {
- is_block_regular = 0;
- break;
- }
+ comm);
+ } else if ((op != MPI_OP_NULL && not op->is_commutative())) {
+ int is_block_regular = 1;
+ for (i = 0; i < (comm_size - 1); ++i) {
+ if (rcounts[i] != rcounts[i + 1]) {
+ is_block_regular = 0;
+ break;
}
+ }
- /* slightly retask pof2 to mean pof2 equal or greater, not always greater as it is above */
- int pof2 = 1;
- while (pof2 < comm_size) pof2 <<= 1;
+ /* slightly retask pof2 to mean pof2 equal or greater, not always greater as it is above */
+ int pof2 = 1;
+ while (pof2 < comm_size)
+ pof2 <<= 1;
- if (pof2 == comm_size && is_block_regular) {
- /* noncommutative, pof2 size, and block regular */
- return Coll_reduce_scatter_mpich_noncomm::reduce_scatter(sbuf, rbuf, rcounts, dtype, op, comm);
- }
+ if (pof2 == comm_size && is_block_regular) {
+ /* noncommutative, pof2 size, and block regular */
+ return Coll_reduce_scatter_mpich_noncomm::reduce_scatter(sbuf, rbuf, rcounts, dtype, op, comm);
+ }
- return Coll_reduce_scatter_mpich_rdb::reduce_scatter(sbuf, rbuf, rcounts, dtype, op, comm);
+ return Coll_reduce_scatter_mpich_rdb::reduce_scatter(sbuf, rbuf, rcounts, dtype, op, comm);
}else{
return Coll_reduce_scatter_mpich_rdb::reduce_scatter(sbuf, rbuf, rcounts, dtype, op, comm);
}
if(comm->get_leaders_comm()==MPI_COMM_NULL){
comm->init_smp();
}
- if(!mv2_bcast_thresholds_table)
+ if (not mv2_bcast_thresholds_table)
init_mv2_bcast_tables_stampede();
comm_size = comm->size();
//rank = comm->rank();
mv2_bcast_thresholds_table[range].is_two_level_bcast[range_threshold];
#endif
if (two_level_bcast == 1) {
- if (!is_contig || !is_homogeneous) {
- tmp_buf=(void *)smpi_get_tmp_sendbuffer(nbytes);
-
-/* position = 0;*/
-/* if (rank == root) {*/
-/* mpi_errno =*/
-/* MPIR_Pack_impl(buffer, count, datatype, tmp_buf, nbytes, &position);*/
-/* if (mpi_errno)*/
-/* MPIU_ERR_POP(mpi_errno);*/
-/* }*/
+ if (not is_contig || not is_homogeneous) {
+ tmp_buf = (void*)smpi_get_tmp_sendbuffer(nbytes);
+
+ /* position = 0;*/
+ /* if (rank == root) {*/
+ /* mpi_errno =*/
+ /* MPIR_Pack_impl(buffer, count, datatype, tmp_buf, nbytes, &position);*/
+ /* if (mpi_errno)*/
+ /* MPIU_ERR_POP(mpi_errno);*/
+ /* }*/
}
#ifdef CHANNEL_MRAIL_GEN2
if ((mv2_enable_zcpy_bcast == 1) &&
- (&MPIR_Pipelined_Bcast_Zcpy_MV2 == MV2_Bcast_function)) {
- if (!is_contig || !is_homogeneous) {
- mpi_errno = MPIR_Pipelined_Bcast_Zcpy_MV2(tmp_buf, nbytes, MPI_BYTE,
- root, comm);
+ (&MPIR_Pipelined_Bcast_Zcpy_MV2 == MV2_Bcast_function)) {
+ if (not is_contig || not is_homogeneous) {
+ mpi_errno = MPIR_Pipelined_Bcast_Zcpy_MV2(tmp_buf, nbytes, MPI_BYTE, root, comm);
} else {
mpi_errno = MPIR_Pipelined_Bcast_Zcpy_MV2(buffer, count, datatype,
root, comm);
#endif /* defined(CHANNEL_MRAIL_GEN2) */
{
shmem_comm = comm->get_intra_comm();
- if (!is_contig || !is_homogeneous) {
- mpi_errno =
- MPIR_Bcast_tune_inter_node_helper_MV2(tmp_buf, nbytes, MPI_BYTE,
- root, comm);
+ if (not is_contig || not is_homogeneous) {
+ mpi_errno = MPIR_Bcast_tune_inter_node_helper_MV2(tmp_buf, nbytes, MPI_BYTE, root, comm);
} else {
mpi_errno =
MPIR_Bcast_tune_inter_node_helper_MV2(buffer, count, datatype, root,
root = INTRA_NODE_ROOT;
-
- if (!is_contig || !is_homogeneous) {
- mpi_errno = MV2_Bcast_intra_node_function(tmp_buf, nbytes,
- MPI_BYTE, root, shmem_comm);
+ if (not is_contig || not is_homogeneous) {
+ mpi_errno = MV2_Bcast_intra_node_function(tmp_buf, nbytes, MPI_BYTE, root, shmem_comm);
} else {
mpi_errno = MV2_Bcast_intra_node_function(buffer, count,
datatype, root, shmem_comm);
}
- }
-/* if (!is_contig || !is_homogeneous) {*/
-/* if (rank != root) {*/
-/* position = 0;*/
-/* mpi_errno = MPIR_Unpack_impl(tmp_buf, nbytes, &position, buffer,*/
-/* count, datatype);*/
-/* }*/
-/* }*/
+ }
+ /* if (not is_contig || not is_homogeneous) {*/
+ /* if (rank != root) {*/
+ /* position = 0;*/
+ /* mpi_errno = MPIR_Unpack_impl(tmp_buf, nbytes, &position, buffer,*/
+ /* count, datatype);*/
+ /* }*/
+ /* }*/
} else {
/* We use Knomial for intra node */
MV2_Bcast_intra_node_function = &MPIR_Knomial_Bcast_intra_node_MV2;
* If the operation is non commutative we currently have choice of linear
* or in-order binary tree algorithm.
*/
- if( (op!=MPI_OP_NULL) && !op->is_commutative() ) {
- if ((communicator_size < 12) && (message_size < 2048)) {
- return Coll_reduce_ompi_basic_linear::reduce (sendbuf, recvbuf, count, datatype, op, root, comm/*, module*/);
- }
- return Coll_reduce_ompi_in_order_binary::reduce (sendbuf, recvbuf, count, datatype, op, root, comm/*, module,
+ if ((op != MPI_OP_NULL) && not op->is_commutative()) {
+ if ((communicator_size < 12) && (message_size < 2048)) {
+ return Coll_reduce_ompi_basic_linear::reduce(sendbuf, recvbuf, count, datatype, op, root, comm /*, module*/);
+ }
+ return Coll_reduce_ompi_in_order_binary::reduce(sendbuf, recvbuf, count, datatype, op, root, comm /*, module,
0, max_requests*/);
}
}
}
- if( ((op!=MPI_OP_NULL) && !op->is_commutative()) || (zerocounts)) {
- Coll_reduce_scatter_default::reduce_scatter (sbuf, rbuf, rcounts,
- dtype, op,
- comm);
- return MPI_SUCCESS;
+ if (((op != MPI_OP_NULL) && not op->is_commutative()) || (zerocounts)) {
+ Coll_reduce_scatter_default::reduce_scatter(sbuf, rbuf, rcounts, dtype, op, comm);
+ return MPI_SUCCESS;
}
total_message_size *= dsize;
void TRACE_internal_smpi_set_category (const char *category)
{
- if (!TRACE_smpi_is_enabled())
+ if (not TRACE_smpi_is_enabled())
return;
//declare category
const char *TRACE_internal_smpi_get_category ()
{
- if (!TRACE_smpi_is_enabled())
+ if (not TRACE_smpi_is_enabled())
return nullptr;
char processid[INSTR_DEFAULT_STR_SIZE];
void TRACE_smpi_init(int rank)
{
- if (!TRACE_smpi_is_enabled())
+ if (not TRACE_smpi_is_enabled())
return;
char str[INSTR_DEFAULT_STR_SIZE];
void TRACE_smpi_finalize(int rank)
{
- if (!TRACE_smpi_is_enabled())
+ if (not TRACE_smpi_is_enabled())
return;
char str[INSTR_DEFAULT_STR_SIZE];
void TRACE_smpi_collective_in(int rank, int root, const char *operation, instr_extra_data extra)
{
- if (!TRACE_smpi_is_enabled()) {
- cleanup_extra_data(extra);
- return;
+ if (not TRACE_smpi_is_enabled()) {
+ cleanup_extra_data(extra);
+ return;
}
char str[INSTR_DEFAULT_STR_SIZE];
void TRACE_smpi_collective_out(int rank, int root, const char *operation)
{
- if (!TRACE_smpi_is_enabled())
+ if (not TRACE_smpi_is_enabled())
return;
char str[INSTR_DEFAULT_STR_SIZE];
void TRACE_smpi_computing_init(int rank)
{
//first use, initialize the color in the trace
- if (!TRACE_smpi_is_enabled() || !TRACE_smpi_is_computing())
- return;
-
- char str[INSTR_DEFAULT_STR_SIZE];
- smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
- container_t container = PJ_container_get (str);
- type_t type = PJ_type_get ("MPI_STATE", container->type);
- const char *color = instr_find_color ("computing");
- val_t value = PJ_value_get_or_new ("computing", color, type);
- new PushStateEvent (SIMIX_get_clock(), container, type, value);
+ if (not TRACE_smpi_is_enabled() || not TRACE_smpi_is_computing())
+ return;
+
+ char str[INSTR_DEFAULT_STR_SIZE];
+ smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
+ container_t container = PJ_container_get(str);
+ type_t type = PJ_type_get("MPI_STATE", container->type);
+ const char* color = instr_find_color("computing");
+ val_t value = PJ_value_get_or_new("computing", color, type);
+ new PushStateEvent(SIMIX_get_clock(), container, type, value);
}
void TRACE_smpi_computing_in(int rank, instr_extra_data extra)
{
//do not forget to set the color first, otherwise this will explode
- if (!TRACE_smpi_is_enabled()|| !TRACE_smpi_is_computing()) {
- cleanup_extra_data(extra);
- return;
+ if (not TRACE_smpi_is_enabled() || not TRACE_smpi_is_computing()) {
+ cleanup_extra_data(extra);
+ return;
}
char str[INSTR_DEFAULT_STR_SIZE];
void TRACE_smpi_computing_out(int rank)
{
- if (!TRACE_smpi_is_enabled()|| !TRACE_smpi_is_computing())
+ if (not TRACE_smpi_is_enabled() || not TRACE_smpi_is_computing())
return;
char str[INSTR_DEFAULT_STR_SIZE];
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
void TRACE_smpi_sleeping_init(int rank)
{
//first use, initialize the color in the trace
- if (!TRACE_smpi_is_enabled() || !TRACE_smpi_is_sleeping())
+ if (not TRACE_smpi_is_enabled() || not TRACE_smpi_is_sleeping())
return;
char str[INSTR_DEFAULT_STR_SIZE];
void TRACE_smpi_sleeping_in(int rank, instr_extra_data extra)
{
//do not forget to set the color first, otherwise this will explode
- if (!TRACE_smpi_is_enabled()|| !TRACE_smpi_is_sleeping()) {
- cleanup_extra_data(extra);
- return;
+ if (not TRACE_smpi_is_enabled() || not TRACE_smpi_is_sleeping()) {
+ cleanup_extra_data(extra);
+ return;
}
char str[INSTR_DEFAULT_STR_SIZE];
void TRACE_smpi_sleeping_out(int rank)
{
- if (!TRACE_smpi_is_enabled()|| !TRACE_smpi_is_sleeping())
+ if (not TRACE_smpi_is_enabled() || not TRACE_smpi_is_sleeping())
return;
char str[INSTR_DEFAULT_STR_SIZE];
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
void TRACE_smpi_testing_in(int rank, instr_extra_data extra)
{
//do not forget to set the color first, otherwise this will explode
- if (!TRACE_smpi_is_enabled()) {
- cleanup_extra_data(extra);
- return;
+ if (not TRACE_smpi_is_enabled()) {
+ cleanup_extra_data(extra);
+ return;
}
char str[INSTR_DEFAULT_STR_SIZE];
void TRACE_smpi_testing_out(int rank)
{
- if (!TRACE_smpi_is_enabled())
+ if (not TRACE_smpi_is_enabled())
return;
char str[INSTR_DEFAULT_STR_SIZE];
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
void TRACE_smpi_ptp_in(int rank, int src, int dst, const char *operation, instr_extra_data extra)
{
- if (!TRACE_smpi_is_enabled()) {
- cleanup_extra_data(extra);
- return;
+ if (not TRACE_smpi_is_enabled()) {
+ cleanup_extra_data(extra);
+ return;
}
char str[INSTR_DEFAULT_STR_SIZE];
void TRACE_smpi_ptp_out(int rank, int src, int dst, const char *operation)
{
- if (!TRACE_smpi_is_enabled())
+ if (not TRACE_smpi_is_enabled())
return;
char str[INSTR_DEFAULT_STR_SIZE];
void TRACE_smpi_send(int rank, int src, int dst, int tag, int size)
{
- if (!TRACE_smpi_is_enabled())
+ if (not TRACE_smpi_is_enabled())
return;
char key[INSTR_DEFAULT_STR_SIZE] = {0};
void TRACE_smpi_recv(int rank, int src, int dst, int tag)
{
- if (!TRACE_smpi_is_enabled())
+ if (not TRACE_smpi_is_enabled())
return;
char key[INSTR_DEFAULT_STR_SIZE] = {0};
{
char *name_list = nullptr;
for (int i = 0; table[i].name; i++)
- if (!strcmp(name, table[i].name)) {
+ if (not strcmp(name, table[i].name)) {
if (strcmp(table[i].name,"default"))
XBT_INFO("Switch to algorithm %s for collective %s",table[i].name,desc);
return i;
}
- if (!table[0].name)
+ if (not table[0].name)
xbt_die("No collective is valid for '%s'! This is a bug.",name);
name_list = xbt_strdup(table[0].name);
for (int i = 1; table[i].name; i++) {
(*newcomm) = new Comm(cp, this->topo());
int ret = MPI_SUCCESS;
- if(!attributes()->empty()){
+ if (not attributes()->empty()) {
int flag;
void* value_out;
for(auto it : *attributes()){
count = sendcount < recvcount ? sendcount : recvcount;
if(!(sendtype->flags() & DT_FLAG_DERIVED) && !(recvtype->flags() & DT_FLAG_DERIVED)) {
- if(!smpi_process()->replaying())
+ if (not smpi_process()->replaying())
memcpy(recvbuf, sendbuf, count);
}
else if (!(sendtype->flags() & DT_FLAG_DERIVED))
if(old_type->flags_ & DT_FLAG_DERIVED)
contiguous=false;
- if(!contiguous){
+ if (not contiguous) {
*new_type = new Type_Indexed(size * old_type->size(),lb,ub,
DT_FLAG_DERIVED|DT_FLAG_DATA, count, block_lengths, indices, old_type);
}else{
if (old_type->flags_ & DT_FLAG_DERIVED || lb!=0)
contiguous=false;
- if(!contiguous){
+ if (not contiguous) {
*new_type = new Type_Hindexed(size * old_type->size(),lb,ub,
DT_FLAG_DERIVED|DT_FLAG_DATA, count, block_lengths, indices, old_type);
}else{
forced_ub=true;
}
- if(!forced_lb && indices[i]+old_types[i]->lb()<lb)
+ if (not forced_lb && indices[i] + old_types[i]->lb() < lb)
lb = indices[i];
- if(!forced_ub && indices[i]+block_lengths[i]*old_types[i]->ub()>ub)
+ if (not forced_ub && indices[i] + block_lengths[i] * old_types[i]->ub() > ub)
ub = indices[i]+block_lengths[i]*old_types[i]->ub();
if ( (i< count -1) && (indices[i]+block_lengths[i]*static_cast<int>(old_types[i]->size()) != indices[i+1]) )
contiguous=false;
}
- if(!contiguous){
+ if (not contiguous) {
*new_type = new Type_Struct(size, lb,ub, DT_FLAG_DERIVED|DT_FLAG_DATA,
count, block_lengths, indices, old_types);
}else{
SIMIX_function_register(name, code);
static int already_called = 0;
- if (!already_called) {
+ if (not already_called) {
already_called = 1;
for (auto& item : simgrid::s4u::host_list) {
simgrid::s4u::Host* host = item.second;
{
MPI_Group group;
- if (!MC_is_active()) {
+ if (not MC_is_active()) {
global_timer = xbt_os_timer_new();
xbt_os_walltimer_start(global_timer);
}
if (xbt_cfg_get_string("smpi/comp-adjustment-file")[0] != '\0') {
std::string filename {xbt_cfg_get_string("smpi/comp-adjustment-file")};
std::ifstream fstream(filename);
- if (!fstream.is_open()) {
+ if (not fstream.is_open()) {
xbt_die("Could not open file %s. Does it exist?", filename.c_str());
}
MPI_COMM_WORLD = MPI_COMM_NULL;
- if (!MC_is_active()) {
+ if (not MC_is_active()) {
xbt_os_timer_free(global_timer);
}
smpi_cpu_threshold = DBL_MAX;
char* val = xbt_cfg_get_string("smpi/shared-malloc");
- if (!strcasecmp(val, "yes") || !strcmp(val, "1") || !strcasecmp(val, "on") || !strcasecmp(val, "global")) {
+ if (not strcasecmp(val, "yes") || not strcmp(val, "1") || not strcasecmp(val, "on") ||
+ not strcasecmp(val, "global")) {
smpi_cfg_shared_malloc = shmalloc_global;
- } else if (!strcasecmp(val, "local")) {
+ } else if (not strcasecmp(val, "local")) {
smpi_cfg_shared_malloc = shmalloc_local;
- } else if (!strcasecmp(val, "no") || !strcmp(val, "0") || !strcasecmp(val, "off")) {
+ } else if (not strcasecmp(val, "no") || not strcmp(val, "0") || not strcasecmp(val, "off")) {
smpi_cfg_shared_malloc = shmalloc_none;
} else {
xbt_die("Invalid value '%s' for option smpi/shared-malloc. Possible values: 'on' or 'global', 'local', 'off'",
if (handle == nullptr)
xbt_die("dlopen failed: %s (errno: %d -- %s)", dlerror(), errno, strerror(errno));
smpi_entry_point_type entry_point = smpi_resolve_function(handle);
- if (!entry_point)
+ if (not entry_point)
xbt_die("Could not resolve entry point");
smpi_run_entry_point(entry_point, args);
if (handle == nullptr)
xbt_die("dlopen failed for %s: %s (errno: %d -- %s)", executable, dlerror(), errno, strerror(errno));
smpi_entry_point_type entry_point = smpi_resolve_function(handle);
- if (!entry_point)
+ if (not entry_point)
xbt_die("main not found in %s", executable);
// TODO, register the executable for SMPI privatization
void smpi_initialize_global_memory_segments()
{
-#if !HAVE_PRIVATIZATION
- smpi_privatize_global_variables=false;
- xbt_die("You are trying to use privatization on a system that does not support it. Don't.");
- return;
-#else
-
+#if HAVE_PRIVATIZATION
smpi_get_executable_global_size();
XBT_DEBUG ("bss+data segment found : size %d starting at %p", smpi_size_data_exe, smpi_start_data_exe );
smpi_privatisation_regions[i].file_descriptor = file_descriptor;
smpi_privatisation_regions[i].address = address;
}
+#else /* ! HAVE_PRIVATIZATION */
+ smpi_privatize_global_variables = false;
+ xbt_die("You are trying to use privatization on a system that does not support it. Don't.");
+ return;
#endif
}
smpi_switch_data_segment(smpi_process()->index());
}
- if(!smpi_process()->replaying() && *len > 0){
+ if (not smpi_process()->replaying() && *len > 0) {
if(! is_fortran_op_)
this->func_(invec, inoutvec, len, &datatype);
else{
retval = MPI_ERR_ARG;
} else if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (!datatype->is_valid()) {
- retval = MPI_ERR_TYPE;
+ } else if (not datatype->is_valid()) {
+ retval = MPI_ERR_TYPE;
} else if (dst == MPI_PROC_NULL) {
retval = MPI_SUCCESS;
} else {
retval = MPI_ERR_ARG;
} else if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (!datatype->is_valid()) {
- retval = MPI_ERR_TYPE;
+ } else if (not datatype->is_valid()) {
+ retval = MPI_ERR_TYPE;
} else if (src == MPI_PROC_NULL) {
retval = MPI_SUCCESS;
} else {
retval = MPI_ERR_ARG;
} else if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (!datatype->is_valid()) {
- retval = MPI_ERR_TYPE;
+ } else if (not datatype->is_valid()) {
+ retval = MPI_ERR_TYPE;
} else if (dst == MPI_PROC_NULL) {
retval = MPI_SUCCESS;
} else {
retval = MPI_ERR_RANK;
} else if ((count < 0) || (buf==nullptr && count > 0)) {
retval = MPI_ERR_COUNT;
- } else if (!datatype->is_valid()) {
- retval = MPI_ERR_TYPE;
+ } else if (not datatype->is_valid()) {
+ retval = MPI_ERR_TYPE;
} else if(tag<0 && tag != MPI_ANY_TAG){
retval = MPI_ERR_TAG;
} else {
retval = MPI_ERR_RANK;
} else if ((count < 0) || (buf==nullptr && count > 0)) {
retval = MPI_ERR_COUNT;
- } else if (!datatype->is_valid()) {
- retval = MPI_ERR_TYPE;
+ } else if (not datatype->is_valid()) {
+ retval = MPI_ERR_TYPE;
} else if(tag<0 && tag != MPI_ANY_TAG){
retval = MPI_ERR_TAG;
} else {
retval = MPI_ERR_RANK;
} else if ((count < 0)|| (buf==nullptr && count > 0)) {
retval = MPI_ERR_COUNT;
- } else if (!datatype->is_valid()) {
- retval = MPI_ERR_TYPE;
+ } else if (not datatype->is_valid()) {
+ retval = MPI_ERR_TYPE;
} else if(tag<0 && tag != MPI_ANY_TAG){
retval = MPI_ERR_TAG;
} else {
retval = MPI_ERR_RANK;
} else if ((count < 0) || (buf==nullptr && count > 0)) {
retval = MPI_ERR_COUNT;
- } else if (!datatype->is_valid()) {
- retval = MPI_ERR_TYPE;
+ } else if (not datatype->is_valid()) {
+ retval = MPI_ERR_TYPE;
} else if(tag<0 && tag != MPI_ANY_TAG){
retval = MPI_ERR_TAG;
} else {
// the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
if (status != MPI_STATUS_IGNORE) {
src_traced = comm->group()->index(status->MPI_SOURCE);
- if (!TRACE_smpi_view_internals()) {
+ if (not TRACE_smpi_view_internals()) {
TRACE_smpi_recv(rank, src_traced, rank, tag);
}
}
retval = MPI_ERR_RANK;
} else if ((count < 0) || (buf == nullptr && count > 0)) {
retval = MPI_ERR_COUNT;
- } else if (!datatype->is_valid()) {
+ } else if (not datatype->is_valid()) {
retval = MPI_ERR_TYPE;
} else if(tag < 0 && tag != MPI_ANY_TAG){
retval = MPI_ERR_TAG;
}
extra->send_size = count*dt_size_send;
TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra);
- if (!TRACE_smpi_view_internals()) {
+ if (not TRACE_smpi_view_internals()) {
TRACE_smpi_send(rank, rank, dst_traced, tag,count*datatype->size());
}
retval = MPI_ERR_RANK;
} else if ((count < 0) || (buf==nullptr && count > 0)) {
retval = MPI_ERR_COUNT;
- } else if (!datatype->is_valid()){
+ } else if (not datatype->is_valid()) {
retval = MPI_ERR_TYPE;
} else if(tag<0 && tag != MPI_ANY_TAG){
retval = MPI_ERR_TAG;
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (!sendtype->is_valid() || !recvtype->is_valid()) {
+ } else if (not sendtype->is_valid() || not recvtype->is_valid()) {
retval = MPI_ERR_TYPE;
} else if (src == MPI_PROC_NULL || dst == MPI_PROC_NULL) {
simgrid::smpi::Status::empty(status);
MPI_Comm comm, MPI_Status* status)
{
int retval = 0;
- if (!datatype->is_valid()) {
+ if (not datatype->is_valid()) {
return MPI_ERR_TYPE;
} else if (count < 0) {
return MPI_ERR_COUNT;
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (!datatype->is_valid()) {
+ } else if (not datatype->is_valid()) {
retval = MPI_ERR_ARG;
} else {
int rank = comm != MPI_COMM_NULL ? smpi_process()->index() : -1;
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (((comm->rank() == root) && (!sendtype->is_valid())) ||
- ((recvbuf != MPI_IN_PLACE) && (!recvtype->is_valid()))) {
+ } else if (((comm->rank() == root) && (not sendtype->is_valid())) ||
+ ((recvbuf != MPI_IN_PLACE) && (not recvtype->is_valid()))) {
retval = MPI_ERR_TYPE;
} else if ((sendbuf == recvbuf) ||
((comm->rank()==root) && sendcount>0 && (sendbuf == nullptr))){
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (!datatype->is_valid() || op == MPI_OP_NULL) {
+ } else if (not datatype->is_valid() || op == MPI_OP_NULL) {
retval = MPI_ERR_ARG;
} else {
int rank = comm != MPI_COMM_NULL ? smpi_process()->index() : -1;
int retval = 0;
smpi_bench_end();
- if (!datatype->is_valid() || op == MPI_OP_NULL) {
+ if (not datatype->is_valid() || op == MPI_OP_NULL) {
retval = MPI_ERR_ARG;
} else {
op->apply(inbuf, inoutbuf, &count, datatype);
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (!datatype->is_valid()) {
+ } else if (not datatype->is_valid()) {
retval = MPI_ERR_TYPE;
} else if (op == MPI_OP_NULL) {
retval = MPI_ERR_OP;
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (!datatype->is_valid()) {
+ } else if (not datatype->is_valid()) {
retval = MPI_ERR_TYPE;
} else if (op == MPI_OP_NULL) {
retval = MPI_ERR_OP;
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (!datatype->is_valid()) {
+ } else if (not datatype->is_valid()) {
retval = MPI_ERR_TYPE;
} else if (op == MPI_OP_NULL) {
retval = MPI_ERR_OP;
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (!datatype->is_valid()) {
+ } else if (not datatype->is_valid()) {
retval = MPI_ERR_TYPE;
} else if (op == MPI_OP_NULL) {
retval = MPI_ERR_OP;
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (!datatype->is_valid()) {
+ } else if (not datatype->is_valid()) {
retval = MPI_ERR_TYPE;
} else if (op == MPI_OP_NULL) {
retval = MPI_ERR_OP;
{
if (status == nullptr || count == nullptr) {
return MPI_ERR_ARG;
- } else if (!datatype->is_valid()) {
+ } else if (not datatype->is_valid()) {
return MPI_ERR_TYPE;
} else {
size_t size = datatype->size();
} else if ((origin_count < 0 || target_count < 0) ||
(origin_addr==nullptr && origin_count > 0)){
retval = MPI_ERR_COUNT;
- } else if ((!origin_datatype->is_valid()) || (!target_datatype->is_valid())) {
+ } else if ((not origin_datatype->is_valid()) || (not target_datatype->is_valid())) {
retval = MPI_ERR_TYPE;
} else {
int rank = smpi_process()->index();
} else if ((origin_count < 0 || target_count < 0) ||
(origin_addr==nullptr && origin_count > 0)){
retval = MPI_ERR_COUNT;
- } else if ((!origin_datatype->is_valid()) || (!target_datatype->is_valid())) {
+ } else if ((not origin_datatype->is_valid()) || (not target_datatype->is_valid())) {
retval = MPI_ERR_TYPE;
} else if(request == nullptr){
retval = MPI_ERR_REQUEST;
} else if ((origin_count < 0 || target_count < 0) ||
(origin_addr==nullptr && origin_count > 0)){
retval = MPI_ERR_COUNT;
- } else if ((!origin_datatype->is_valid()) || (!target_datatype->is_valid())) {
+ } else if ((not origin_datatype->is_valid()) || (not target_datatype->is_valid())) {
retval = MPI_ERR_TYPE;
} else {
int rank = smpi_process()->index();
} else if ((origin_count < 0 || target_count < 0) ||
(origin_addr==nullptr && origin_count > 0)){
retval = MPI_ERR_COUNT;
- } else if ((!origin_datatype->is_valid()) || (!target_datatype->is_valid())) {
+ } else if ((not origin_datatype->is_valid()) || (not target_datatype->is_valid())) {
retval = MPI_ERR_TYPE;
} else if(request == nullptr){
retval = MPI_ERR_REQUEST;
} else if ((origin_count < 0 || target_count < 0) ||
(origin_addr==nullptr && origin_count > 0)){
retval = MPI_ERR_COUNT;
- } else if ((!origin_datatype->is_valid()) ||
- (!target_datatype->is_valid())) {
+ } else if ((not origin_datatype->is_valid()) || (not target_datatype->is_valid())) {
retval = MPI_ERR_TYPE;
} else if (op == MPI_OP_NULL) {
retval = MPI_ERR_OP;
} else if ((origin_count < 0 || target_count < 0) ||
(origin_addr==nullptr && origin_count > 0)){
retval = MPI_ERR_COUNT;
- } else if ((!origin_datatype->is_valid()) ||
- (!target_datatype->is_valid())) {
+ } else if ((not origin_datatype->is_valid()) || (not target_datatype->is_valid())) {
retval = MPI_ERR_TYPE;
} else if (op == MPI_OP_NULL) {
retval = MPI_ERR_OP;
(origin_addr==nullptr && origin_count > 0 && op != MPI_NO_OP) ||
(result_addr==nullptr && result_count > 0)){
retval = MPI_ERR_COUNT;
- } else if ((origin_datatype!=MPI_DATATYPE_NULL && !origin_datatype->is_valid()) ||
- (!target_datatype->is_valid())||
- (!result_datatype->is_valid())) {
+ } else if ((origin_datatype != MPI_DATATYPE_NULL && not origin_datatype->is_valid()) ||
+ (not target_datatype->is_valid()) || (not result_datatype->is_valid())) {
retval = MPI_ERR_TYPE;
} else if (op == MPI_OP_NULL) {
retval = MPI_ERR_OP;
(origin_addr==nullptr && origin_count > 0 && op != MPI_NO_OP) ||
(result_addr==nullptr && result_count > 0)){
retval = MPI_ERR_COUNT;
- } else if ((origin_datatype!=MPI_DATATYPE_NULL && !origin_datatype->is_valid()) ||
- (!target_datatype->is_valid())||
- (!result_datatype->is_valid())) {
+ } else if ((origin_datatype != MPI_DATATYPE_NULL && not origin_datatype->is_valid()) ||
+ (not target_datatype->is_valid()) || (not result_datatype->is_valid())) {
retval = MPI_ERR_TYPE;
} else if (op == MPI_OP_NULL) {
retval = MPI_ERR_OP;
retval = MPI_ERR_ARG;
} else if (origin_addr==nullptr || result_addr==nullptr || compare_addr==nullptr){
retval = MPI_ERR_COUNT;
- } else if (!datatype->is_valid()) {
+ } else if (not datatype->is_valid()) {
retval = MPI_ERR_TYPE;
} else {
int rank = smpi_process()->index();
int PMPI_Unpack(void* inbuf, int incount, int* position, void* outbuf, int outcount, MPI_Datatype type, MPI_Comm comm) {
if(incount<0 || outcount < 0 || inbuf==nullptr || outbuf==nullptr)
return MPI_ERR_ARG;
- if(!type->is_valid())
+ if (not type->is_valid())
return MPI_ERR_TYPE;
if(comm==MPI_COMM_NULL)
return MPI_ERR_COMM;
int PMPI_Pack(void* inbuf, int incount, MPI_Datatype type, void* outbuf, int outcount, int* position, MPI_Comm comm) {
if(incount<0 || outcount < 0|| inbuf==nullptr || outbuf==nullptr)
return MPI_ERR_ARG;
- if(!type->is_valid())
+ if (not type->is_valid())
return MPI_ERR_TYPE;
if(comm==MPI_COMM_NULL)
return MPI_ERR_COMM;
int PMPI_Pack_size(int incount, MPI_Datatype datatype, MPI_Comm comm, int* size) {
if(incount<0)
return MPI_ERR_ARG;
- if(!datatype->is_valid())
+ if (not datatype->is_valid())
return MPI_ERR_TYPE;
if(comm==MPI_COMM_NULL)
return MPI_ERR_COMM;
//allocate a single buffer for all sends, growing it if needed
void* smpi_get_tmp_sendbuffer(int size)
{
- if (!smpi_process()->replaying())
+ if (not smpi_process()->replaying())
return xbt_malloc(size);
if (sendbuffer_size<size){
sendbuffer=static_cast<char*>(xbt_realloc(sendbuffer,size));
//allocate a single buffer for all recv
void* smpi_get_tmp_recvbuffer(int size){
- if (!smpi_process()->replaying())
+ if (not smpi_process()->replaying())
return xbt_malloc(size);
if (recvbuffer_size<size){
recvbuffer=static_cast<char*>(xbt_realloc(recvbuffer,size));
}
void smpi_free_tmp_buffer(void* buf){
- if (!smpi_process()->replaying())
+ if (not smpi_process()->replaying())
xbt_free(buf);
}
extra->dst = dst_traced;
extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr);
TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra);
- if (!TRACE_smpi_view_internals())
+ if (not TRACE_smpi_view_internals())
TRACE_smpi_send(rank, rank, dst_traced, 0, size*MPI_CURRENT_TYPE->size());
Request::send(nullptr, size, MPI_CURRENT_TYPE, to , 0, MPI_COMM_WORLD);
extra->dst = dst_traced;
extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr);
TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra);
- if (!TRACE_smpi_view_internals())
+ if (not TRACE_smpi_view_internals())
TRACE_smpi_send(rank, rank, dst_traced, 0, size*MPI_CURRENT_TYPE->size());
MPI_Request request = Request::isend(nullptr, size, MPI_CURRENT_TYPE, to, 0,MPI_COMM_WORLD);
Request::recv(nullptr, size, MPI_CURRENT_TYPE, from, 0, MPI_COMM_WORLD, &status);
TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
- if (!TRACE_smpi_view_internals()) {
+ if (not TRACE_smpi_view_internals()) {
TRACE_smpi_recv(rank, src_traced, rank, 0);
}
/* and now, finalize everything */
/* One active process will stop. Decrease the counter*/
XBT_DEBUG("There are %zu elements in reqq[*]", get_reqq_self()->size());
- if (!get_reqq_self()->empty()){
+ if (not get_reqq_self()->empty()) {
unsigned int count_requests=get_reqq_self()->size();
MPI_Request requests[count_requests];
MPI_Status status[count_requests];
refcount_++;
if(!(old_type_->flags() & DT_FLAG_DERIVED)){
oldbuf = buf_;
- if (!process->replaying() && oldbuf != nullptr && size_!=0){
+ if (not process->replaying() && oldbuf != nullptr && size_ != 0) {
if((smpi_privatize_global_variables != 0)
&& (static_cast<char*>(buf_) >= smpi_start_data_exe)
&& (static_cast<char*>(buf_) < smpi_start_data_exe + smpi_size_data_exe )){
// we make a copy here, as the size is modified by simix, and we may reuse the request in another receive later
real_size_=size_;
- action_ = simcall_comm_isend(SIMIX_process_from_PID(src_+1), mailbox, size_, -1.0,
- buf, real_size_, &match_send,
- &xbt_free_f, // how to free the userdata if a detached send fails
- !process->replaying() ? smpi_comm_copy_data_callback
- : &smpi_comm_null_copy_buffer_callback, this,
- // detach if msg size < eager/rdv switch limit
- detached_);
+ action_ = simcall_comm_isend(
+ SIMIX_process_from_PID(src_ + 1), mailbox, size_, -1.0, buf, real_size_, &match_send,
+ &xbt_free_f, // how to free the userdata if a detached send fails
+ not process->replaying() ? smpi_comm_copy_data_callback : &smpi_comm_null_copy_buffer_callback, this,
+ // detach if msg size < eager/rdv switch limit
+ detached_);
XBT_DEBUG("send simcall posted");
/* FIXME: detached sends are not traceable (action_ == nullptr) */
map.push_back(i);
}
}
- if(!map.empty()) {
+ if (not map.empty()) {
//multiplier to the sleeptime, to increase speed of execution, each failed testany will increase it
static int nsleeps = 1;
if(smpi_test_sleep > 0)
// FIXME Handle the case of a partial shared malloc.
if (((req->flags_ & ACCUMULATE) != 0) ||
- (datatype->flags() & DT_FLAG_DERIVED)) { // && (!smpi_is_shared(req->old_buf_))){
+ (datatype->flags() & DT_FLAG_DERIVED)) { // && (not smpi_is_shared(req->old_buf_))){
- if (!smpi_process()->replaying()){
+ if (not smpi_process()->replaying()) {
if( smpi_privatize_global_variables != 0 && (static_cast<char*>(req->old_buf_) >= smpi_start_data_exe)
&& ((char*)req->old_buf_ < smpi_start_data_exe + smpi_size_data_exe )){
XBT_VERB("Privatization : We are unserializing to a zone in global memory Switch data segment ");
}
}
- if (!accumulates.empty()) {
+ if (not accumulates.empty()) {
std::sort(accumulates.begin(), accumulates.end(), sort_accumulates);
for (auto req : accumulates) {
finish_wait(&req, status);
char *huge_page_mount_point = xbt_cfg_get_string("smpi/shared-malloc-hugepage");
bool use_huge_page = huge_page_mount_point[0] != '\0';
#ifndef MAP_HUGETLB /* If the system header don't define that mmap flag */
- xbt_assert(!use_huge_page, "Huge pages are not available on your system, you cannot use the smpi/shared-malloc-hugepage option.");
- use_huge_page = 0;
+ xbt_assert(not use_huge_page,
+ "Huge pages are not available on your system, you cannot use the smpi/shared-malloc-hugepage option.");
+ use_huge_page = 0;
#endif
smpi_shared_malloc_blocksize = static_cast<unsigned long>(xbt_cfg_get_double("smpi/shared-malloc-blocksize"));
void *mem, *allocated_ptr;
}
void smpi_free_static() {
- while (!registered_static_variables_stack.empty()) {
+ while (not registered_static_variables_stack.empty()) {
s_smpi_static_t elm = registered_static_variables_stack.top();
elm.free_fn(elm.ptr);
registered_static_variables_stack.pop();
if (xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL) != nullptr) {
simgrid::surf::Storage* storage = static_cast<simgrid::surf::Storage*>(
xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL));
- if (!strcmp(static_cast<const char*>(storage->attach_), piface_->cname())) {
+ if (not strcmp(static_cast<const char*>(storage->attach_), piface_->cname())) {
storages->push_back(storage->cname());
}
}
int HostImpl::unlink(surf_file_t fd)
{
- if (!fd) {
+ if (not fd) {
XBT_WARN("No such file descriptor. Impossible to unlink");
return -1;
} else {
int HostImpl::fileMove(surf_file_t fd, const char* fullpath)
{
/* Check if the new full path is on the same mount point */
- if (!strncmp((const char*)fd->mount, fullpath, strlen(fd->mount))) {
+ if (not strncmp((const char*)fd->mount, fullpath, strlen(fd->mount))) {
std::map<std::string, sg_size_t*>* content = findStorageOnMountList(fd->mount)->content_;
if (content->find(fd->name) != content->end()) { // src file exists
sg_size_t* psize = content->at(std::string(fd->name));
/** @brief Change the value of a given key in the property set */
void PropertyHolder::setProperty(const char*key, const char*value) {
- if (!properties_)
+ if (not properties_)
properties_ = xbt_dict_new_homogeneous(xbt_free_f);
xbt_dict_set(properties_, key, xbt_strdup(value), nullptr);
}
/** @brief Return the whole set of properties. Don't mess with it, dude! */
xbt_dict_t PropertyHolder::getProperties() {
- if (!properties_)
+ if (not properties_)
properties_ = xbt_dict_new_homogeneous(xbt_free_f);
return properties_;
}
*********/
void surf_cpu_model_init_Cas01()
{
- xbt_assert(!surf_cpu_model_pm);
- xbt_assert(!surf_cpu_model_vm);
+ xbt_assert(not surf_cpu_model_pm);
+ xbt_assert(not surf_cpu_model_vm);
char *optim = xbt_cfg_get_string("cpu/optim");
- if (!strcmp(optim, "TI")) {
+ if (not strcmp(optim, "TI")) {
surf_cpu_model_init_ti();
return;
}
char *optim = xbt_cfg_get_string("cpu/optim");
bool select = xbt_cfg_get_boolean("cpu/maxmin-selective-update");
- if (!strcmp(optim, "Full")) {
+ if (not strcmp(optim, "Full")) {
updateMechanism_ = UM_FULL;
selectiveUpdate_ = select;
- } else if (!strcmp(optim, "Lazy")) {
+ } else if (not strcmp(optim, "Lazy")) {
updateMechanism_ = UM_LAZY;
selectiveUpdate_ = true;
xbt_assert(select || (xbt_cfg_is_default_value("cpu/maxmin-selective-update")),
trace_ = 0;
/* no availability file, fixed trace */
- if (!speedTrace) {
+ if (not speedTrace) {
type_ = TRACE_FIXED;
value_ = value;
XBT_DEBUG("No availability trace. Constant value = %f", value);
void surf_cpu_model_init_ti()
{
- xbt_assert(!surf_cpu_model_pm,"CPU model already initialized. This should not happen.");
- xbt_assert(!surf_cpu_model_vm,"CPU model already initialized. This should not happen.");
+ xbt_assert(not surf_cpu_model_pm, "CPU model already initialized. This should not happen.");
+ xbt_assert(not surf_cpu_model_vm, "CPU model already initialized. This should not happen.");
surf_cpu_model_pm = new simgrid::surf::CpuTiModel();
all_existing_models->push_back(surf_cpu_model_pm);
bool CpuTi::isUsed()
{
- return !actionSet_->empty();
+ return not actionSet_->empty();
}
double CpuTi::getAvailableSpeed()
void CpuTi::modified(bool modified){
CpuTiList* modifiedCpu = static_cast<CpuTiModel*>(model())->modifiedCpu_;
if (modified) {
- if (!cpu_ti_hook.is_linked()) {
+ if (not cpu_ti_hook.is_linked()) {
modifiedCpu->push_back(*this);
}
} else {
int CpuTiAction::unref()
{
refcount_--;
- if (!refcount_) {
+ if (not refcount_) {
if (action_hook.is_linked())
getStateSet()->erase(getStateSet()->iterator_to(*this));
/* remove from action_set */
nb++;
}
XBT_DEBUG("\tThere are %d variables", nb);
- if (nb > 0 && !cnst->sharing_policy)
+ if (nb > 0 && not cnst->sharing_policy)
nb = 1;
- if (!nb) {
+ if (not nb) {
cnst->remaining = 0.0;
cnst->usage = cnst->remaining;
xbt_swag_remove(cnst, cnst_list);
cnst->usage = MIN(cnst->usage, elem->value * elem->variable->mu);
}
}
- if (!cnst->sharing_policy) {
+ if (not cnst->sharing_policy) {
XBT_DEBUG("\tUpdate constraint %p (%g) by %g", cnst, cnst->remaining, cnst->usage);
double_update(&(cnst->remaining), cnst->usage, sg_maxmin_precision);
//find common father
container_t father = lowestCommonAncestor (src, dst);
- if (!father){
+ if (not father) {
xbt_die ("common father unknown, this is a tracing problem");
}
static void recursiveGraphExtraction(simgrid::s4u::NetZone* netzone, container_t container, xbt_dict_t filter)
{
- if (!TRACE_platform_topology()){
+ if (not TRACE_platform_topology()) {
XBT_DEBUG("Graph extraction disabled by user.");
return;
}
XBT_DEBUG("Graph extraction for NetZone = %s", netzone->name());
- if (!netzone->children()->empty()) {
+ if (not netzone->children()->empty()) {
//bottom-up recursion
for (auto nz_son : *netzone->children()) {
container_t child_container = static_cast<container_t>(xbt_dict_get(container->children, nz_son->name()));
type_t mpi = PJ_type_get_or_null ("MPI", root->type);
if (mpi == nullptr){
mpi = PJ_type_container_new("MPI", root->type);
- if (!TRACE_smpi_is_grouped())
+ if (not TRACE_smpi_is_grouped())
PJ_type_state_new ("MPI_STATE", mpi);
PJ_type_link_new ("MPI_LINK", PJ_type_get_root(), mpi, mpi);
}
{
//always need the call backs to ASes (we need only the root AS),
//to create the rootContainer and the rootType properly
- if (!TRACE_is_enabled() || !TRACE_needs_platform())
+ if (not TRACE_is_enabled() || not TRACE_needs_platform())
return;
simgrid::s4u::Link::onCreation.connect(instr_routing_parse_start_link);
simgrid::s4u::onPlatformCreated.connect(instr_routing_parse_end_platform);
*/
static void recursiveNewVariableType (const char *new_typename, const char *color, type_t root)
{
- if (!strcmp (root->name, "HOST")){
+ if (not strcmp(root->name, "HOST")) {
char tnstr[INSTR_DEFAULT_STR_SIZE];
snprintf (tnstr, INSTR_DEFAULT_STR_SIZE, "p%s", new_typename);
PJ_type_variable_new (tnstr, color, root);
}
- if (!strcmp (root->name, "MSG_VM")){
+ if (not strcmp(root->name, "MSG_VM")) {
char tnstr[INSTR_DEFAULT_STR_SIZE];
snprintf (tnstr, INSTR_DEFAULT_STR_SIZE, "p%s", new_typename);
PJ_type_variable_new (tnstr, color, root);
}
- if (!strcmp (root->name, "LINK")){
+ if (not strcmp(root->name, "LINK")) {
char tnstr[INSTR_DEFAULT_STR_SIZE];
snprintf (tnstr, INSTR_DEFAULT_STR_SIZE, "b%s", new_typename);
PJ_type_variable_new (tnstr, color, root);
static void recursiveNewUserVariableType (const char *father_type, const char *new_typename, const char *color, type_t root)
{
- if (!strcmp (root->name, father_type)){
+ if (not strcmp(root->name, father_type)) {
PJ_type_variable_new (new_typename, color, root);
}
xbt_dict_cursor_t cursor = nullptr;
static void recursiveNewUserStateType (const char *father_type, const char *new_typename, type_t root)
{
- if (!strcmp (root->name, father_type)){
+ if (not strcmp(root->name, father_type)) {
PJ_type_state_new (new_typename, root);
}
xbt_dict_cursor_t cursor = nullptr;
static void recursiveNewValueForUserStateType (const char *type_name, const char *value, const char *color, type_t root)
{
- if (!strcmp (root->name, type_name)){
+ if (not strcmp(root->name, type_name)) {
PJ_value_new (value, color, root);
}
xbt_dict_cursor_t cursor = nullptr;
static void recursiveXBTGraphExtraction(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges, sg_netzone_t netzone,
container_t container)
{
- if (!netzone->children()->empty()) {
+ if (not netzone->children()->empty()) {
//bottom-up recursion
for (auto netzone_child : *netzone->children()) {
container_t child_container = static_cast<container_t>(xbt_dict_get(container->children, netzone_child->name()));
void TRACE_surf_action(surf_action_t surf_action, const char *category)
{
- if (!TRACE_is_enabled())
+ if (not TRACE_is_enabled())
return;
- if (!TRACE_categorized ())
+ if (not TRACE_categorized())
return;
- if (!category)
+ if (not category)
return;
surf_action->setCategory(category);
xbt_swag_foreach(_var, var_list) {
var = static_cast<lmm_variable_t>(_var);
- if (!var->weight)
+ if (not var->weight)
break;
if (var->bound < 0)
continue;
var = static_cast<lmm_variable_t>(_var);
double sigma_i = 0.0;
- if (!var->weight)
+ if (not var->weight)
break;
for (int j = 0; j < var->cnsts_number; j++)
i = 0;
xbt_swag_foreach(_var, var_list) {
var = static_cast<lmm_variable_t>(_var);
- if (!var->weight)
- var->value = 0.0;
- else {
- int nb = 0;
- if (var->bound < 0.0) {
- XBT_DEBUG("#### NOTE var(%d) is a boundless variable", i);
- var->mu = -1.0;
- var->value = new_value(var);
- } else {
- var->mu = 1.0;
- var->new_mu = 2.0;
- var->value = new_value(var);
- }
- XBT_DEBUG("#### var(%p) ->weight : %e", var, var->weight);
- XBT_DEBUG("#### var(%p) ->mu : %e", var, var->mu);
- XBT_DEBUG("#### var(%p) ->weight: %e", var, var->weight);
- XBT_DEBUG("#### var(%p) ->bound: %e", var, var->bound);
- for (i = 0; i < var->cnsts_number; i++) {
- if (var->cnsts[i].value == 0.0)
- nb++;
- }
- if (nb == var->cnsts_number)
- var->value = 1.0;
+ if (not var->weight)
+ var->value = 0.0;
+ else {
+ int nb = 0;
+ if (var->bound < 0.0) {
+ XBT_DEBUG("#### NOTE var(%d) is a boundless variable", i);
+ var->mu = -1.0;
+ var->value = new_value(var);
+ } else {
+ var->mu = 1.0;
+ var->new_mu = 2.0;
+ var->value = new_value(var);
+ }
+ XBT_DEBUG("#### var(%p) ->weight : %e", var, var->weight);
+ XBT_DEBUG("#### var(%p) ->mu : %e", var, var->mu);
+ XBT_DEBUG("#### var(%p) ->weight: %e", var, var->weight);
+ XBT_DEBUG("#### var(%p) ->bound: %e", var, var->bound);
+ for (i = 0; i < var->cnsts_number; i++) {
+ if (var->cnsts[i].value == 0.0)
+ nb++;
+ }
+ if (nb == var->cnsts_number)
+ var->value = 1.0;
}
}
/* Improve the value of mu_i */
xbt_swag_foreach(_var, var_list) {
var = static_cast<lmm_variable_t>(_var);
- if (!var->weight)
+ if (not var->weight)
break;
if (var->bound >= 0) {
XBT_DEBUG("Working on var (%p)", var);
if (!__check_feasible(cnst_list, var_list, 0))
overall_modification = 1.0;
XBT_DEBUG("Iteration %d: overall_modification : %f", iteration, overall_modification);
-/* if(!dual_updated) { */
-/* XBT_WARN("Could not improve the convergence at iteration %d. Drop it!",iteration); */
-/* break; */
-/* } */
+ /* if(not dual_updated) { */
+ /* XBT_WARN("Could not improve the convergence at iteration %d. Drop it!",iteration); */
+ /* break; */
+ /* } */
}
__check_feasible(cnst_list, var_list, 1);
lmm_variable_t var = nullptr;
lmm_constraint_t cnst = nullptr;
- if (!sys)
+ if (not sys)
return;
while ((var = (lmm_variable_t) extract_variable(sys))) {
xbt_swag_remove(elem, &(elem->constraint->active_element_set));
nelements=xbt_swag_size(&(elem->constraint->enabled_element_set)) +
xbt_swag_size(&(elem->constraint->disabled_element_set));
- if (!nelements)
+ if (not nelements)
make_constraint_inactive(sys, elem->constraint);
else
lmm_on_disabled_var(sys,elem->constraint);
*/
inline void lmm_constraint_free(lmm_system_t sys,lmm_constraint_t cnst)
{
- xbt_assert(!xbt_swag_size(&(cnst->active_element_set)),"Removing constraint but it still has active elements");
- xbt_assert(!xbt_swag_size(&(cnst->enabled_element_set)),"Removing constraint but it still has enabled elements");
- xbt_assert(!xbt_swag_size(&(cnst->disabled_element_set)),"Removing constraint but it still has disabled elements");
+ xbt_assert(not xbt_swag_size(&(cnst->active_element_set)), "Removing constraint but it still has active elements");
+ xbt_assert(not xbt_swag_size(&(cnst->enabled_element_set)), "Removing constraint but it still has enabled elements");
+ xbt_assert(not xbt_swag_size(&(cnst->disabled_element_set)),
+ "Removing constraint but it still has disabled elements");
remove_constraint(sys, cnst);
lmm_cnst_free(sys, cnst);
}
}
}
- if (!found) {
+ if (not found) {
XBT_DEBUG("cnst %p is not found in var %p", cnst, var);
return;
}
lmm_on_disabled_var(sys,var->cnsts[i].constraint);
value=0;
var->staged_weight=weight;
- xbt_assert(!var->weight);
+ xbt_assert(not var->weight);
}
xbt_assert(var->cnsts_number < var->cnsts_size, "Too much constraints");
} else
xbt_swag_insert_at_tail(elem, &(elem->constraint->disabled_element_set));
- if(!sys->selective_update_active) {
+ if (not sys->selective_update_active) {
make_constraint_active(sys, cnst);
} else if(elem->value>0 || var->weight >0) {
make_constraint_active(sys, cnst);
for (j = 0; j < var->cnsts_number; j++)
lmm_on_disabled_var(sys,var->cnsts[j].constraint);
var->staged_weight=weight;
- xbt_assert(!var->weight);
+ xbt_assert(not var->weight);
}
lmm_increase_concurrency(&var->cnsts[i]);
}
buf = buf + "0) <= " + std::to_string(cnst->bound) + " ('" + std::to_string(cnst->id_int) + "')";
- if (!cnst->sharing_policy) {
+ if (not cnst->sharing_policy) {
buf += " [MAX-Constraint]";
}
XBT_DEBUG("%s", buf.c_str());
buf.clear();
- xbt_assert(!double_positive(sum - cnst->bound, cnst->bound*sg_maxmin_precision),
- "Incorrect value (%f is not smaller than %f): %g", sum, cnst->bound, sum - cnst->bound);
- //if(double_positive(sum - cnst->bound, cnst->bound*sg_maxmin_precision))
- //XBT_ERROR("Incorrect value (%f is not smaller than %f): %g",sum, cnst->bound, sum - cnst->bound);
+ xbt_assert(not double_positive(sum - cnst->bound, cnst->bound * sg_maxmin_precision),
+ "Incorrect value (%f is not smaller than %f): %g", sum, cnst->bound, sum - cnst->bound);
+ // if(double_positive(sum - cnst->bound, cnst->bound*sg_maxmin_precision))
+ // XBT_ERROR("Incorrect value (%f is not smaller than %f): %g",sum, cnst->bound, sum - cnst->bound);
}
XBT_DEBUG("Variables");
var = (lmm_variable_t)_var;
if (var->bound > 0) {
XBT_DEBUG("'%d'(%f) : %f (<=%f)", var->id_int, var->weight, var->value, var->bound);
- xbt_assert(!double_positive(var->value - var->bound, var->bound*sg_maxmin_precision),
- "Incorrect value (%f is not smaller than %f", var->value, var->bound);
+ xbt_assert(not double_positive(var->value - var->bound, var->bound * sg_maxmin_precision),
+ "Incorrect value (%f is not smaller than %f", var->value, var->bound);
} else {
XBT_DEBUG("'%d'(%f) : %f", var->id_int, var->weight, var->value);
}
/* INIT: Collect constraints that actually need to be saturated (i.e remaining and usage are strictly positive)
* into cnst_light_tab. */
cnst->remaining = cnst->bound;
- if (!double_positive(cnst->remaining, cnst->bound*sg_maxmin_precision))
+ if (not double_positive(cnst->remaining, cnst->bound * sg_maxmin_precision))
continue;
cnst->usage = 0;
elem_list = &(cnst->enabled_element_set);
make_elem_active(elem);
simgrid::surf::Action *action = static_cast<simgrid::surf::Action*>(elem->variable->id);
- if (sys->keep_track && !action->is_linked())
+ if (sys->keep_track && not action->is_linked())
sys->keep_track->push_back(*action);
}
}
double_update(&(cnst->remaining), elem->value * var->value, cnst->bound*sg_maxmin_precision);
double_update(&(cnst->usage), elem->value / var->weight, sg_maxmin_precision);
//If the constraint is saturated, remove it from the set of active constraints (light_tab)
- if(!double_positive(cnst->usage,sg_maxmin_precision) ||
- !double_positive(cnst->remaining,cnst->bound*sg_maxmin_precision)) {
+ if (not double_positive(cnst->usage, sg_maxmin_precision) ||
+ not double_positive(cnst->remaining, cnst->bound * sg_maxmin_precision)) {
if (cnst->cnst_light) {
int index = (cnst->cnst_light-cnst_light_tab);
XBT_DEBUG("index: %d \t cnst_light_num: %d \t || usage: %f remaining: %f bound: %f ",
cnst->usage = MAX(cnst->usage, elem->value / elem->variable->weight);
}
//If the constraint is saturated, remove it from the set of active constraints (light_tab)
- if(!double_positive(cnst->usage,sg_maxmin_precision) ||
- !double_positive(cnst->remaining,cnst->bound*sg_maxmin_precision)) {
+ if (not double_positive(cnst->usage, sg_maxmin_precision) ||
+ not double_positive(cnst->remaining, cnst->bound * sg_maxmin_precision)) {
if(cnst->cnst_light) {
int index = (cnst->cnst_light-cnst_light_tab);
XBT_DEBUG("index: %d \t cnst_light_num: %d \t || \t cnst: %p \t cnst->cnst_light: %p "
//This is only an optimization, to avoid looking at more constraints when slack is already zero
//Disable it when debugging to let lmm_concurrency_slack catch nasty things
- if(!slack && !XBT_LOG_ISENABLED(surf_maxmin, xbt_log_priority_debug))
+ if (not slack && not XBT_LOG_ISENABLED(surf_maxmin, xbt_log_priority_debug))
return 0;
if(minslack>slack)
int i;
lmm_element_t elem;
- xbt_assert(!var->staged_weight,"Staged weight should have been cleared");
+ xbt_assert(not var->staged_weight, "Staged weight should have been cleared");
//Disabling the variable, move to var to list tail. Subtility is: here, we need to call lmm_update_modified_set BEFORE
//moving the last element of var.
xbt_swag_remove(var, &(sys->variable_set));
return;
int numelem = xbt_swag_size(&(cnstr->disabled_element_set));
- if(!numelem)
+ if (not numelem)
return;
lmm_element_t elem = (lmm_element_t)xbt_swag_getFirst(&(cnstr->disabled_element_set));
s_lmm_element_t *cnsts = var->cnsts;
int i;
for (i = 0; var->visited != sys->visited_counter && i < var->cnsts_number ; i++) {
- if (cnsts[i].constraint != cnst && !xbt_swag_belongs(cnsts[i].constraint, &sys->modified_constraint_set)) {
+ if (cnsts[i].constraint != cnst && not xbt_swag_belongs(cnsts[i].constraint, &sys->modified_constraint_set)) {
xbt_swag_insert(cnsts[i].constraint, &sys->modified_constraint_set);
lmm_update_modified_set_rec(sys, cnsts[i].constraint);
}
static void lmm_update_modified_set(lmm_system_t sys, lmm_constraint_t cnst)
{
/* nothing to do if selective update isn't active */
- if (sys->selective_update_active && !xbt_swag_belongs(cnst, &sys->modified_constraint_set)) {
+ if (sys->selective_update_active && not xbt_swag_belongs(cnst, &sys->modified_constraint_set)) {
xbt_swag_insert(cnst, &sys->modified_constraint_set);
lmm_update_modified_set_rec(sys, cnst);
}
xbt_swag_foreach(_var, &(sys->variable_set)) {
var= (lmm_variable_t) _var;
- if(!var->cnsts_number)
+ if (not var->cnsts_number)
continue;
elem = &var->cnsts[0];
char *optim = xbt_cfg_get_string("network/optim");
bool select = xbt_cfg_get_boolean("network/maxmin-selective-update");
- if (!strcmp(optim, "Full")) {
+ if (not strcmp(optim, "Full")) {
updateMechanism_ = UM_FULL;
selectiveUpdate_ = select;
- } else if (!strcmp(optim, "Lazy")) {
+ } else if (not strcmp(optim, "Lazy")) {
updateMechanism_ = UM_LAZY;
selectiveUpdate_ = true;
xbt_assert(select || (xbt_cfg_is_default_value("network/maxmin-selective-update")),
action->getLastUpdate(), now - action->getLastUpdate());
}
}
- if (!lmm_get_number_of_cnst_from_var (maxminSystem_, action->getVariable())) {
+ if (not lmm_get_number_of_cnst_from_var(maxminSystem_, action->getVariable())) {
/* There is actually no link used, hence an infinite bandwidth. This happens often when using models like
* vivaldi. In such case, just make sure that the action completes immediately.
*/
XBT_IN("(%s,%s,%g,%g)", src->cname(), dst->cname(), size, rate);
src->routeTo(dst, route, &latency);
- xbt_assert(!route->empty() || latency,
+ xbt_assert(not route->empty() || latency,
"You're trying to send data from %s to %s but there is no connecting path between these two hosts.",
src->cname(), dst->cname());
while ((var = lmm_get_var_from_cnst_safe(model()->getMaxminSystem(), constraint(), &elem, &nextelem, &numelem))) {
NetworkCm02Action *action = static_cast<NetworkCm02Action*>(lmm_variable_id(var));
action->weight_ += delta;
- if (!action->isSuspended())
+ if (not action->isSuspended())
lmm_update_variable_weight(model()->getMaxminSystem(), action->getVariable(), action->weight_);
}
}
XBT_INFO("Flow is limited BYLATENCY, latency of flow is %f", action->latCurrent_);
}
}
- if (!action->isSuspended())
+ if (not action->isSuspended())
lmm_update_variable_weight(model()->getMaxminSystem(), action->getVariable(), action->weight_);
}
}
penalized_bw= ! num_comm_out ? (*it)->init_rate : (*it)->init_rate /penalty;
- if (!double_equals(penalized_bw, rate_before_update, sg_surf_precision)){
+ if (not double_equals(penalized_bw, rate_before_update, sg_surf_precision)) {
XBT_DEBUG("%d->%d action %p penalty updated : bw now %f, before %f , initial rate %f", root->id,(*it)->destination->id,(*it)->action,penalized_bw, (*it)->action->getBound(), (*it)->init_rate );
lmm_update_variable_bound(maxminSystem_, (*it)->action->getVariable(), penalized_bw);
}else{
{
if (strcmp(name,"__loopback__"))
- xbt_assert(!LinkImpl::byName(name), "Link '%s' declared several times in the platform.", name);
+ xbt_assert(not LinkImpl::byName(name), "Link '%s' declared several times in the platform.", name);
latency_.scale = 1;
bandwidth_.scale = 1;
*/
void LinkImpl::destroy()
{
- if (!currentlyDestroying_) {
+ if (not currentlyDestroying_) {
currentlyDestroying_ = true;
s4u::Link::onDestruction(this->piface_);
delete this;
XBT_DEBUG("ns3_next_occuring_event");
//get the first relevant value from the running_actions list
- if (!getRunningActionSet()->size() || now == 0.0)
+ if (not getRunningActionSet()->size() || now == 0.0)
return -1.0;
else
do {
}
}
- while (!xbt_dynar_is_empty(socket_to_destroy)){
+ while (not xbt_dynar_is_empty(socket_to_destroy)) {
xbt_dynar_pop(socket_to_destroy,&ns3Socket);
if (XBT_LOG_ISENABLED(ns3, xbt_log_priority_debug)) {
int NetworkNS3Action::unref()
{
refcount_--;
- if (!refcount_) {
+ if (not refcount_) {
if (action_hook.is_linked())
stateSet_->erase(stateSet_->iterator_to(*this));
XBT_DEBUG ("Removing action %p", this);
ns3::Config::SetDefault ("ns3::TcpSocket::SegmentSize", ns3::UintegerValue (1024)); // 1024-byte packet for easier reading
ns3::Config::SetDefault ("ns3::TcpSocket::DelAckCount", ns3::UintegerValue (1));
- if (!strcmp(TcpProtocol,"default"))
+ if (not strcmp(TcpProtocol, "default"))
return;
- if (!strcmp(TcpProtocol,"Reno")) {
+ if (not strcmp(TcpProtocol, "Reno")) {
XBT_INFO("Switching Tcp protocol to '%s'",TcpProtocol);
ns3::Config::SetDefault ("ns3::TcpL4Protocol::SocketType", ns3::StringValue("ns3::TcpReno"));
return;
}
- if (!strcmp(TcpProtocol,"NewReno")) {
+ if (not strcmp(TcpProtocol, "NewReno")) {
XBT_INFO("Switching Tcp protocol to '%s'",TcpProtocol);
ns3::Config::SetDefault ("ns3::TcpL4Protocol::SocketType", ns3::StringValue("ns3::TcpNewReno"));
return;
}
- if(!strcmp(TcpProtocol,"Tahoe")){
+ if (not strcmp(TcpProtocol, "Tahoe")) {
XBT_INFO("Switching Tcp protocol to '%s'",TcpProtocol);
ns3::Config::SetDefault ("ns3::TcpL4Protocol::SocketType", ns3::StringValue("ns3::TcpTahoe"));
return;
double HostEnergy::getWattMinAt(int pstate)
{
- xbt_assert(!power_range_watts_list.empty(), "No power range properties specified for host %s", host->cname());
+ xbt_assert(not power_range_watts_list.empty(), "No power range properties specified for host %s", host->cname());
return power_range_watts_list[pstate].min;
}
double HostEnergy::getWattMaxAt(int pstate)
{
- xbt_assert(!power_range_watts_list.empty(), "No power range properties specified for host %s", host->cname());
+ xbt_assert(not power_range_watts_list.empty(), "No power range properties specified for host %s", host->cname());
return power_range_watts_list[pstate].max;
}
/** @brief Computes the power consumed by the host according to the current pstate and processor load */
double HostEnergy::getCurrentWattsValue(double cpu_load)
{
- xbt_assert(!power_range_watts_list.empty(), "No power range properties specified for host %s", host->cname());
+ xbt_assert(not power_range_watts_list.empty(), "No power range properties specified for host %s", host->cname());
/* min_power corresponds to the power consumed when only one core is active */
/* max_power is the power consumed at 100% cpu load */
void surf_host_model_init_ptask_L07()
{
XBT_CINFO(xbt_cfg,"Switching to the L07 model to handle parallel tasks.");
- xbt_assert(!surf_cpu_model_pm, "CPU model type already defined");
- xbt_assert(!surf_network_model, "network model type already defined");
+ xbt_assert(not surf_cpu_model_pm, "CPU model type already defined");
+ xbt_assert(not surf_network_model, "network model type already defined");
surf_host_model = new simgrid::surf::HostL07Model();
all_existing_models->push_back(surf_host_model);
int L07Action::unref()
{
refcount_--;
- if (!refcount_) {
+ if (not refcount_) {
if (action_hook.is_linked())
stateSet_->erase(stateSet_->iterator_to(*this));
if (getVariable())
s_sg_platf_host_cbarg_t host;
memset(&host, 0, sizeof(host));
host.id = host_id;
- if ((cluster->properties != nullptr) && (!xbt_dict_is_empty(cluster->properties))) {
+ if ((cluster->properties != nullptr) && (not xbt_dict_is_empty(cluster->properties))) {
xbt_dict_cursor_t cursor=nullptr;
char *key;
char* data;
// Add a router.
XBT_DEBUG(" ");
XBT_DEBUG("<router id=\"%s\"/>", cluster->router_id);
- if (!cluster->router_id || !strcmp(cluster->router_id, "")) {
+ if (not cluster->router_id || not strcmp(cluster->router_id, "")) {
char* newid = bprintf("%s%s_router%s", cluster->prefix, cluster->id, cluster->suffix);
current_as->router_ = sg_platf_new_router(newid, NULL);
free(newid);
void sg_platf_new_storage(sg_platf_storage_cbarg_t storage)
{
- xbt_assert(!xbt_lib_get_or_null(storage_lib, storage->id,ROUTING_STORAGE_LEVEL),
- "Refusing to add a second storage named \"%s\"", storage->id);
+ xbt_assert(not xbt_lib_get_or_null(storage_lib, storage->id, ROUTING_STORAGE_LEVEL),
+ "Refusing to add a second storage named \"%s\"", storage->id);
xbt_assert(storage_types.find(storage->type_id) != storage_types.end(), "No storage type '%s'", storage->type_id);
storage_type_t stype = storage_types.at(storage->type_id);
xbt_lib_set(storage_lib, storage->id, ROUTING_STORAGE_LEVEL, (void *) xbt_strdup(storage->type_id));
// if storage content is not specified use the content of storage_type if any
- if (!strcmp(storage->content, "") && strcmp(stype->content, "")) {
+ if (not strcmp(storage->content, "") && strcmp(stype->content, "")) {
storage->content = stype->content;
XBT_DEBUG("For disk '%s' content is empty, inherit the content (of type %s)", storage->id, stype->type_id);
}
void sg_platf_new_process(sg_platf_process_cbarg_t process)
{
sg_host_t host = sg_host_by_name(process->host);
- if (!host) {
+ if (not host) {
// The requested host does not exist. Do a nice message to the user
std::string msg = std::string("Cannot create process '") + process->function + "': host '" + process->host +
"' does not exist\nExisting hosts: '";
const char* storage_model_name = xbt_cfg_get_string("storage/model");
/* The compound host model is needed when using non-default net/cpu models */
- if ((!xbt_cfg_is_default_value("network/model") || !xbt_cfg_is_default_value("cpu/model")) &&
+ if ((not xbt_cfg_is_default_value("network/model") || not xbt_cfg_is_default_value("cpu/model")) &&
xbt_cfg_is_default_value("host/model")) {
host_model_name = "compound";
xbt_cfg_set_string("host/model", host_model_name);
}
XBT_DEBUG("host model: %s", host_model_name);
- if (!strcmp(host_model_name, "compound")) {
+ if (not strcmp(host_model_name, "compound")) {
xbt_assert(cpu_model_name, "Set a cpu model to use with the 'compound' host model");
xbt_assert(network_model_name, "Set a network model to use with the 'compound' host model");
*/
simgrid::s4u::NetZone* sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS)
{
- if (!surf_parse_models_setup_already_called) {
+ if (not surf_parse_models_setup_already_called) {
/* Initialize the surf models. That must be done after we got all config, and before we need the models.
* That is, after the last <config> tag, if any, and before the first of cluster|peer|AS|trace|trace_connect
*
std::map<std::string, sg_size_t*>* Storage::parseContent(const char* filename)
{
usedSize_ = 0;
- if ((!filename) || (strcmp(filename, "") == 0))
+ if ((not filename) || (strcmp(filename, "") == 0))
return nullptr;
std::map<std::string, sg_size_t*>* parse_content = new std::map<std::string, sg_size_t*>();
*psize = size;
parse_content->insert({tokens.front(), psize});
}
- } while (!fs->eof());
+ } while (not fs->eof());
delete fs;
return parse_content;
}
simgrid::surf::Storage* storage =
static_cast<simgrid::surf::Storage*>(xbt_lib_get_or_null(storage_lib, key, SURF_STORAGE_LEVEL));
simgrid::kernel::routing::NetPoint* host_elm = sg_netpoint_by_name_or_null(storage->attach_);
- if (!host_elm)
+ if (not host_elm)
surf_parse_error("Unable to attach storage %s: host %s does not exist.", storage->cname(), storage->attach_);
}
}
const char* attach)
{
- xbt_assert(!surf_storage_resource_priv(surf_storage_resource_by_name(id)),
- "Storage '%s' declared several times in the platform file", id);
+ xbt_assert(not surf_storage_resource_priv(surf_storage_resource_by_name(id)),
+ "Storage '%s' declared several times in the platform file", id);
storage_type_t storage_type = storage_types.at(type_id);
int StorageN11Action::unref()
{
refcount_--;
- if (!refcount_) {
+ if (not refcount_) {
if (action_hook.is_linked())
stateSet_->erase(stateSet_->iterator_to(*this));
if (getVariable())
std::string buff = path_elm + FILE_DELIM + name;
fs->open(buff.c_str(), std::ifstream::in);
- if (!fs->fail()) {
+ if (not fs->fail()) {
XBT_DEBUG("Found file at %s", buff.c_str());
return fs;
}
unsigned int len = GetCurrentDirectory(MAX_PATH + 1, current_directory);
char root[4] = { 0 };
- if (!len)
+ if (not len)
return nullptr;
strncpy(root, current_directory, 3);
char *name_list = nullptr;
for (i = 0; table[i].name; i++)
- if (!strcmp(name, table[i].name)) {
+ if (not strcmp(name, table[i].name)) {
return i;
}
- if (!table[0].name)
+ if (not table[0].name)
xbt_die("No model is valid! This is a bug.");
name_list = xbt_strdup(table[0].name);
for (i = 1; table[i].name; i++) {
SURF_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,surf_storage_free);
xbt_init(argc, argv);
- if (!all_existing_models)
+ if (not all_existing_models)
all_existing_models = new std::vector<simgrid::surf::Model*>();
- if (!future_evt_set)
+ if (not future_evt_set)
future_evt_set = new simgrid::trace_mgr::future_evt_set();
TRACE_surf_alloc();
lmm_solve(maxminSystem_);
XBT_DEBUG("After share resources, The size of modified actions set is %zd", modifiedSet_->size());
- while(!modifiedSet_->empty()) {
+ while (not modifiedSet_->empty()) {
Action *action = &(modifiedSet_->front());
modifiedSet_->pop_front();
bool max_dur_flag = false;
int Action::unref(){
refcount_--;
- if (!refcount_) {
+ if (not refcount_) {
if (action_hook.is_linked())
stateSet_->erase(stateSet_->iterator_to(*this));
if (getVariable())
xbt_assert(trace_list.find(filename) == trace_list.end(), "Refusing to define trace %s twice", filename);
std::ifstream* f = surf_ifsopen(filename);
- xbt_assert(!f->fail(), "Cannot open file '%s' (path=%s)", filename, (boost::join(surf_path, ":")).c_str());
+ xbt_assert(not f->fail(), "Cannot open file '%s' (path=%s)", filename, (boost::join(surf_path, ":")).c_str());
std::stringstream buffer;
buffer << f->rdbuf();
void surfxml_bufferstack_push(int new_one)
{
- if (!new_one)
+ if (not new_one)
old_buff = surfxml_bufferstack;
else {
surfxml_bufferstack_stack.push_back(surfxml_bufferstack);
void surfxml_bufferstack_pop(int new_one)
{
- if (!new_one)
+ if (not new_one)
surfxml_bufferstack = old_buff;
else {
free(surfxml_bufferstack);
static int after_config_done;
void parse_after_config() {
- if (!after_config_done) {
+ if (not after_config_done) {
TRACE_start();
/* Register classical callbacks */
* Helping functions
*/
void surf_parse_assert(bool cond, const char *fmt, ...) {
- if (!cond ) {
+ if (not cond) {
va_list va;
va_start(va,fmt);
int lineno = surf_parse_lineno;
netzone->setProperty(A_surfxml_prop_id, A_surfxml_prop_value);
}
else{
- if (!current_property_set)
+ if (not current_property_set)
current_property_set = xbt_dict_new_homogeneous(&xbt_free_f); // Maybe, it should raise an error
xbt_dict_set(current_property_set, A_surfxml_prop_id, xbt_strdup(A_surfxml_prop_value), nullptr);
XBT_DEBUG("add prop %s=%s into current property set %p", A_surfxml_prop_id, A_surfxml_prop_value,
}
void STag_surfxml_model___prop(){
- if (!current_model_property_set)
+ if (not current_model_property_set)
current_model_property_set = new std::map<std::string, std::string>();
current_model_property_set->insert(
XBT_VERB("Fire a first command: '%s'", cmd.c_str());
FILE* pipe = popen(cmd.c_str(), "r");
- if (!pipe) {
+ if (not pipe) {
xbt_die("Cannot fork addr2line to display the backtrace");
}
XBT_DEBUG("addr=%s (as string) =%#lx (as number)",
addrs[i].c_str(), addr);
- while (!found) {
+ while (not found) {
long int first;
long int last;
free(maps_name);
addrs[i].clear();
- if (!found) {
+ if (not found) {
XBT_VERB("Problem while reading the maps file. Following backtrace will be mangled.");
XBT_DEBUG("No dynamic. Static symbol: %s", backtrace_syms[i]);
result.push_back(simgrid::xbt::string_printf("?? (%s)", backtrace_syms[i]));
free(p);
XBT_VERB("Fire a new command: '%s'", subcmd);
FILE* subpipe = popen(subcmd, "r");
- if (!subpipe) {
+ if (not subpipe) {
xbt_die("Cannot fork addr2line to display the backtrace");
}
if (fgets(line_func, 1024, subpipe)) {
addrs[i].clear();
/* Mask the bottom of the stack */
- if (!strncmp("main", line_func, strlen("main")) ||
- !strncmp("xbt_thread_context_wrapper", line_func, strlen("xbt_thread_context_wrapper"))
- || !strncmp("smx_ctx_sysv_wrapper", line_func, strlen("smx_ctx_sysv_wrapper")))
+ if (not strncmp("main", line_func, strlen("main")) ||
+ not strncmp("xbt_thread_context_wrapper", line_func, strlen("xbt_thread_context_wrapper")) ||
+ not strncmp("smx_ctx_sysv_wrapper", line_func, strlen("smx_ctx_sysv_wrapper")))
break;
}
pclose(pipe);
*/
void xbt_cfg_set_parse(const char *options)
{
- if (!options || !strlen(options)) { /* nothing to do */
+ if (not options || not strlen(options)) { /* nothing to do */
return;
}
char *optionlist_cpy = xbt_strdup(options);
XBT_DEBUG("List to parse and set:'%s'", options);
char *option = optionlist_cpy;
while (1) { /* breaks in the code */
- if (!option)
+ if (not option)
break;
char *name = option;
int len = strlen(name);
if (name[0] == ' ' || name[0] == '\n' || name[0] == '\t')
continue;
- if (!strlen(name))
+ if (not strlen(name))
break;
char *val = strchr(name, ':');
xbt_test_assert(string_flag == "bar", "Check string flag");
xbt_test_assert(double_flag == 8.0, "Check double flag");
xbt_test_assert(bool_flag1, "Check bool1 flag");
- xbt_test_assert(!bool_flag2, "Check bool2 flag");
+ xbt_test_assert(not bool_flag2, "Check bool2 flag");
xbt_cfg_free(&simgrid_config);
simgrid_config = temp;
if (_xbt_test_suites)
xbt_dynar_foreach(_xbt_test_suites, it_suite, suite)
- if (!strcmp(suite->name, name))
- return suite;
+ if (not strcmp(suite->name, name))
+ return suite;
va_start(ap, fmt);
bufname = bvprintf(fmt, ap);
snprintf(suite_title + 40 - (suite_len + 4) / 2, 81 - (40 - (suite_len + 4) / 2), "[ %s ]", suite->title);
suite_title[40 + (suite_len + 5) / 2] = '=';
- if (!suite->enabled)
+ if (not suite->enabled)
snprintf(suite_title + 70, 11, " DISABLED ");
fprintf(stderr, "\n%s\n", suite_title);
} else {
unit->nb_tests++;
- if (test->failed && !test->expected_failure)
+ if (test->failed && not test->expected_failure)
unit->test_failed++;
- if (!test->failed && test->expected_failure)
+ if (not test->failed && test->expected_failure)
unit->test_failed++;
if (test->expected_failure)
unit->test_expect++;
}
fprintf(stderr, " %s: %s [%s:%d]\n", resname, test->title, file, line);
- if ((test->expected_failure && !test->failed) || (!test->expected_failure && test->failed)) {
+ if ((test->expected_failure && not test->failed) || (not test->expected_failure && test->failed)) {
xbt_dynar_foreach(test->logs, it_log, log) {
file = (log->file != nullptr ? log->file : file);
line = (log->line != 0 ? log->line : line);
} else {
fprintf(stderr, "\n");
}
- } else if (!unit->enabled) {
+ } else if (not unit->enabled) {
fprintf(stderr, " disabled\n"); /* no test were run */
} else if (unit->nb_tests) {
fprintf(stderr, "...... ok\n"); /* successful */
suite->nb_units++;
if (unit->test_failed)
suite->unit_failed++;
- } else if (!unit->enabled) {
+ } else if (not unit->enabled) {
suite->unit_disabled++;
} else {
suite->unit_ignore++;
_xbt_test_nb_suites++;
if (suite->test_failed)
_xbt_test_suite_failed++;
- } else if (!suite->enabled) {
+ } else if (not suite->enabled) {
_xbt_test_suite_disabled++;
} else {
_xbt_test_suite_ignore++;
char suitename[512];
char unitname[512];
- if (!selection || selection[0] == '\0')
+ if (not selection || selection[0] == '\0')
return;
/*printf("Test selection: %s\n", selection); */
/* First apply the selection */
- while (!done) {
+ while (not done) {
int enabling = 1;
char *p = strchr(sel, ',');
}
/* Deal with the specific case of 'all' pseudo serie */
- if (!strcmp("all", suitename)) {
+ if (not strcmp("all", suitename)) {
xbt_assert(unitname[0] == '\0', "The 'all' pseudo-suite does not accept any unit specification\n");
xbt_dynar_foreach(_xbt_test_suites, it_suite, suite) {
for (it = 0; it < xbt_dynar_length(_xbt_test_suites); it++) {
xbt_test_suite_t thissuite =
xbt_dynar_get_as(_xbt_test_suites, it, xbt_test_suite_t);
- if (!strcmp(suitename, thissuite->name)) {
+ if (not strcmp(suitename, thissuite->name)) {
/* Do not disable the whole suite when we just want to disable a child */
if (enabling || (unitname[0] == '\0'))
thissuite->enabled = enabling;
it2_unit < xbt_dynar_length(thissuite->units);
it2_unit++) {
xbt_test_unit_t thisunit = xbt_dynar_get_as(thissuite->units, it2_unit, xbt_test_unit_t);
- if (!strcmp(thisunit->name, unitname)) {
+ if (not strcmp(thisunit->name, unitname)) {
thisunit->enabled = enabling;
break;
}
xbt_dictelm_t current;
xbt_dictelm_t previous = nullptr;
- xbt_assert(!free_ctn, "Cannot set an individual free function in homogeneous dicts.");
+ xbt_assert(not free_ctn, "Cannot set an individual free function in homogeneous dicts.");
XBT_CDEBUG(xbt_dict, "ADD %.*s hash = %u, size = %d, & = %u", key_len, key, hash_code,
dict->table_size, hash_code & dict->table_size);
current = dict->table[hash_code & dict->table_size];
}
}
- if (!dict->table[hash_code & dict->table_size])
+ if (not dict->table[hash_code & dict->table_size])
dict->fill--;
xbt_dictelm_free(dict, current);
*/
int xbt_dict_is_empty(xbt_dict_t dict)
{
- return !dict || (xbt_dict_length(dict) == 0);
+ return not dict || (xbt_dict_length(dict) == 0);
}
/**
printf("Dict %p: %d bucklets, %d used cells (of %d) ", dict, dict->count, dict->fill, dict->table_size);
- if (!dict) {
+ if (not dict) {
printf("\n");
return;
}
xbt_dynar_set(sizes, size, &prevsize);
}
}
- if (!all_sizes)
+ if (not all_sizes)
all_sizes = xbt_dynar_new(sizeof(int), nullptr);
xbt_dynar_foreach(sizes, count, size) {
if (data) {
xbt_test_assert(found, "data do not match expectations: found nullptr while searching for %s", data);
if (found)
- xbt_test_assert(!strcmp(data, found), "data do not match expectations: found %s while searching for %s",
- found, data);
+ xbt_test_assert(not strcmp(data, found), "data do not match expectations: found %s while searching for %s", found,
+ data);
} else {
- xbt_test_assert(!found, "data do not match expectations: found %s while searching for nullptr", found);
+ xbt_test_assert(not found, "data do not match expectations: found %s while searching for nullptr", found);
}
}
int i = 0;
xbt_dict_foreach(head, cursor, key, data) {
- if (!key || !data || strcmp(key, data)) {
+ if (not key || not data || strcmp(key, data)) {
xbt_test_log("Seen #%d: %s->%s", ++i, key, data);
} else {
xbt_test_log("Seen #%d: %s", ++i, key);
}
- xbt_test_assert(!data || !strcmp(key, data), "Key(%s) != value(%s). Aborting", key, data);
+ xbt_test_assert(not data || not strcmp(key, data), "Key(%s) != value(%s). Aborting", key, data);
}
}
xbt_dict_foreach(dict, cursor, key, data) {
effective++;
char* key2 = xbt_dict_get_key(dict, data);
- xbt_assert(!strcmp(key, key2), "The data was registered under %s instead of %s as expected", key2, key);
+ xbt_assert(not strcmp(key, key2), "The data was registered under %s instead of %s as expected", key2, key);
}
xbt_test_assert(effective == length, "Effective length(%d) != %d.", effective, length);
xbt_test_add("Search 123");
char* data = (char*)xbt_dict_get(head, "123");
xbt_test_assert(data);
- xbt_test_assert(!strcmp("123", data));
+ xbt_test_assert(not strcmp("123", data));
search_not_found(head, "Can't be found");
search_not_found(head, "123 Can't be found");
char* data;
xbt_dict_foreach(head, cursor, key, data) {
- if (!key || !data || strcmp(key, data)) {
+ if (not key || not data || strcmp(key, data)) {
xbt_test_log("Seen: %s->%s", key, data);
} else {
xbt_test_log("Seen: %s", key);
}
- if (!strcmp(key, "null"))
+ if (not strcmp(key, "null"))
found = 1;
}
xbt_test_assert(found, "the key 'null', associated to nullptr is not found");
xbt_dict_set(head, key, key, nullptr);
data = (char*) xbt_dict_get(head, key);
- xbt_test_assert(!strcmp(key, data), "Retrieved value (%s) != Injected value (%s)", key, data);
+ xbt_test_assert(not strcmp(key, data), "Retrieved value (%s) != Injected value (%s)", key, data);
count(head, j + 1);
}
for (int j = 0; j < NB_ELM; j++) {
snprintf(key,10, "%d", j);
void* data = xbt_dict_get(head, key);
- xbt_test_assert(!strcmp(key, (char *) data), "with get, key=%s != data=%s", key, (char *) data);
+ xbt_test_assert(not strcmp(key, (char*)data), "with get, key=%s != data=%s", key, (char*)data);
data = xbt_dict_get_ext(head, key, strlen(key));
- xbt_test_assert(!strcmp(key, (char *) data), "with get_ext, key=%s != data=%s", key, (char *) data);
+ xbt_test_assert(not strcmp(key, (char*)data), "with get_ext, key=%s != data=%s", key, (char*)data);
}
}
free(key);
unsigned long offset;
unsigned long cur;
- if (!n)
+ if (not n)
return;
_sanity_check_dynar(dynar);
* \code
* signed int position = -1;
* xbt_dynar_foreach(dynar, iter, elem) {
- * if (!memcmp(elem, searched_element, sizeof(*elem))) {
+ * if (not 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.
*/
unsigned long it;
for (it = 0; it < dynar->used; it++)
- if (!memcmp(_xbt_dynar_elm(dynar, it), elem, dynar->elmsize)) {
+ if (not memcmp(_xbt_dynar_elm(dynar, it), elem, dynar->elmsize)) {
return it;
}
unsigned long it;
for (it = 0; it < dynar->used; it++)
- if (!memcmp(_xbt_dynar_elm(dynar, it), elem, dynar->elmsize)) {
+ if (not memcmp(_xbt_dynar_elm(dynar, it), elem, dynar->elmsize)) {
return it;
}
unsigned long it;
for (it = 0; it < dynar->used; it++)
- if (!memcmp(_xbt_dynar_elm(dynar, it), elem, dynar->elmsize)) {
+ if (not memcmp(_xbt_dynar_elm(dynar, it), elem, dynar->elmsize)) {
return 1;
}
{
int i ;
int size;
- if((!d1) && (!d2))
+ if ((not d1) && (not d2))
return 0;
- if((!d1) || (!d2)) {
+ if ((not d1) || (not d2)) {
XBT_DEBUG("nullptr dynar d1=%p d2=%p",d1,d2);
xbt_dynar_free(&d2);
return 1;
for (int cpt = 0; cpt < NB_ELEM; cpt++) {
snprintf(buf,1023, "%d", cpt);
xbt_dynar_shift(d, &s2);
- xbt_test_assert(!strcmp(buf, s2), "The retrieved value is not the same than the injected one (%s!=%s)", buf, s2);
+ xbt_test_assert(not strcmp(buf, s2), "The retrieved value is not the same than the injected one (%s!=%s)", buf, s2);
free(s2);
}
xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
/* 2. Traverse the dynar with the macro */
xbt_dynar_foreach(d, iter, s1) {
snprintf(buf,1023, "%u", NB_ELEM - iter - 1);
- xbt_test_assert(!strcmp(buf, s1), "The retrieved value is not the same than the injected one (%s!=%s)", buf, s1);
+ xbt_test_assert(not strcmp(buf, s1), "The retrieved value is not the same than the injected one (%s!=%s)", buf, s1);
}
/* 3. Traverse the dynar with the macro */
for (int cpt = 0; cpt < NB_ELEM; cpt++) {
snprintf(buf,1023, "%d", cpt);
xbt_dynar_pop(d, &s2);
- xbt_test_assert(!strcmp(buf, s2), "The retrieved value is not the same than the injected one (%s!=%s)", buf, s2);
+ xbt_test_assert(not strcmp(buf, s2), "The retrieved value is not the same than the injected one (%s!=%s)", buf, s2);
free(s2);
}
/* 4. Free the resources */
for (int cpt = 0; cpt < NB_ELEM / 2; cpt++) {
snprintf(buf,1023, "%d", cpt);
xbt_dynar_shift(d, &s2);
- xbt_test_assert(!strcmp(buf, s2),
- "The retrieved value is not the same than the injected one at the begining (%s!=%s)", buf, s2);
+ xbt_test_assert(not strcmp(buf, s2),
+ "The retrieved value is not the same than the injected one at the begining (%s!=%s)", buf, s2);
free(s2);
}
for (int cpt = (NB_ELEM / 5) - 1; cpt >= 0; cpt--) {
snprintf(buf,1023, "%d", cpt);
xbt_dynar_shift(d, &s2);
- xbt_test_assert(!strcmp(buf, s2),
- "The retrieved value is not the same than the injected one in the middle (%s!=%s)", buf, s2);
+ xbt_test_assert(not strcmp(buf, s2),
+ "The retrieved value is not the same than the injected one in the middle (%s!=%s)", buf, s2);
free(s2);
}
for (int cpt = NB_ELEM / 2; cpt < NB_ELEM; cpt++) {
snprintf(buf,1023, "%d", cpt);
xbt_dynar_shift(d, &s2);
- xbt_test_assert(!strcmp(buf, s2), "The retrieved value is not the same than the injected one at the end (%s!=%s)",
- buf, s2);
+ xbt_test_assert(not strcmp(buf, s2),
+ "The retrieved value is not the same than the injected one at the end (%s!=%s)", buf, s2);
free(s2);
}
xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
for (int cpt = 2 * (NB_ELEM / 5); cpt < 4 * (NB_ELEM / 5); cpt++) {
snprintf(buf,1023, "%d", cpt);
xbt_dynar_remove_at(d, 2 * (NB_ELEM / 5), &s2);
- xbt_test_assert(!strcmp(buf, s2), "Remove a bad value. Got %s, expected %s", s2, buf);
+ xbt_test_assert(not strcmp(buf, s2), "Remove a bad value. Got %s, expected %s", s2, buf);
free(s2);
}
xbt_dynar_free(&d); /* end_of_doxygen */
c = 1;
if (v1 != 5678)
xbt_test_fail("v1 = %d (!= 5678)", v1);
- if (!(ex.category == 1 && ex.value == 2 && !strcmp(ex.what(), "blah")))
+ if (!(ex.category == 1 && ex.value == 2 && not strcmp(ex.what(), "blah")))
xbt_test_fail("unexpected exception contents");
}
- if (!c)
+ if (not c)
xbt_test_fail("xbt_ex_free not executed");
}
#endif /* SIMGRID_TEST */
/* Create space for a new map region in the region's array and copy the */
/* parsed stuff from the temporal memreg variable */
- XBT_DEBUG("Found region for %s", !memreg.pathname.empty() ? memreg.pathname.c_str() : "(null)");
+ XBT_DEBUG("Found region for %s", not memreg.pathname.empty() ? memreg.pathname.c_str() : "(null)");
ret.push_back(std::move(memreg));
}
*/
void xbt_parmap_destroy(xbt_parmap_t parmap)
{
- if (!parmap) {
+ if (not parmap) {
return;
}
do {
std::getline(*fs, *line);
boost::trim(*line);
- } while (!fs->eof() && (line->length() == 0 || line->front() == '#'));
+ } while (not fs->eof() && (line->length() == 0 || line->front() == '#'));
XBT_DEBUG("got from trace: %s", line->c_str());
}
read_and_trim_line(fs, &line);
boost::split(*action, line, boost::is_any_of(" \t"), boost::token_compress_on);
- return !fs->eof();
+ return not fs->eof();
}
static ReplayAction* get_action(char* name)
const char *__char_list = " \t\n\r\x0B";
char white_char[256] = { 1, 0 };
- if (!s)
+ if (not s)
return;
- if (!char_list) {
+ if (not char_list) {
while (*__char_list) {
white_char[(unsigned char) *__char_list++] = 1;
}
const char *__char_list = " \t\n\r\x0B";
char white_char[256] = { 1, 0 };
- if (!s)
+ if (not s)
return;
- if (!char_list) {
+ if (not char_list) {
while (*__char_list) {
white_char[(unsigned char) *__char_list++] = 1;
}
*/
void xbt_str_trim(char *s, const char *char_list)
{
- if (!s)
+ if (not s)
return;
xbt_str_rtrim(s, char_list);
/* check what are the separators */
memset(is_sep, 0, sizeof(is_sep));
- if (!sep) {
+ if (not sep) {
while (*sep_dflt)
is_sep[(unsigned char) *sep_dflt++] = 1;
} else {
if (s[0] == '\0')
return res;
- while (!done) {
+ while (not done) {
char *topush;
- while (!is_sep[(unsigned char) *q]) {
+ while (not is_sep[(unsigned char)*q]) {
q++;
}
if (*q == '\0')
/**
* \brief This functions splits a string after using another string as separator
- * For example A!!B!!C split after !! will return the dynar {A,B,C}
+ * For example Anot not B!not C split after !! will return the dynar {A,B,C}
* \return An array of dynars containing the string tokens
*/
xbt_dynar_t xbt_str_split_str(const char *s, const char *sep)
return res;
}
- while (!done) {
+ while (not done) {
char *to_push;
int v = 0;
// get the start of the first occurrence of the substring
/* do not trim leading spaces: caller responsibility to clean his cruft */
end = beg;
- while (!done) {
+ while (not done) {
switch (*end) {
case '\\':
ctn = 1;
break;
case '\'':
ctn = 1;
- if (!in_double_quote) {
- in_simple_quote = !in_simple_quote;
+ if (not in_double_quote) {
+ in_simple_quote = not in_simple_quote;
memmove(end, end + 1, strlen(end));
} else {
/* simple quote protected by double ones */
break;
case '"':
ctn = 1;
- if (!in_simple_quote) {
- in_double_quote = !in_double_quote;
+ if (not in_simple_quote) {
+ in_double_quote = not in_double_quote;
memmove(end, end + 1, strlen(end));
} else {
/* double quote protected by simple ones */
unsigned int cpt;
char* cursor;
- if (!dyn_len)
+ if (not dyn_len)
return xbt_strdup("");
/* compute the length */
int amount_strings=0;
int len=0;
- if ((!strs) || (!strs[0]))
+ if ((not strs) || (not strs[0]))
return xbt_strdup("");
/* compute the length before malloc */
XBT_TEST_SUITE("xbt_str", "String Handling");
-#define mytest(name, input, expected) \
- xbt_test_add(name); \
- d=xbt_str_split_quoted(input); \
- s=xbt_str_join(d,"XXX"); \
- xbt_test_assert(!strcmp(s,expected),\
- "Input (%s) leads to (%s) instead of (%s)", \
- input,s,expected);\
- free(s); \
- xbt_dynar_free(&d);
+#define mytest(name, input, expected) \
+ xbt_test_add(name); \
+ d = xbt_str_split_quoted(input); \
+ s = xbt_str_join(d, "XXX"); \
+ xbt_test_assert(not strcmp(s, expected), "Input (%s) leads to (%s) instead of (%s)", input, s, expected); \
+ free(s); \
+ xbt_dynar_free(&d);
XBT_TEST_UNIT("xbt_str_split_quoted", test_split_quoted, "test the function xbt_str_split_quoted")
{
xbt_dynar_t d;
mytest("Backslashed quotes + quotes", "'toto \\'tutu' tata", "toto 'tutuXXXtata");
}
-#define mytest_str(name, input, separator, expected) \
- xbt_test_add(name); \
- d=xbt_str_split_str(input, separator); \
- s=xbt_str_join(d,"XXX"); \
- xbt_test_assert(!strcmp(s,expected),\
- "Input (%s) leads to (%s) instead of (%s)", \
- input,s,expected);\
- free(s); \
- xbt_dynar_free(&d);
+#define mytest_str(name, input, separator, expected) \
+ xbt_test_add(name); \
+ d = xbt_str_split_str(input, separator); \
+ s = xbt_str_join(d, "XXX"); \
+ xbt_test_assert(not strcmp(s, expected), "Input (%s) leads to (%s) instead of (%s)", input, s, expected); \
+ free(s); \
+ xbt_dynar_free(&d);
XBT_TEST_UNIT("xbt_str_split_str", test_split_str, "test the function xbt_str_split_str")
{
xbt_assert(res == MSG_OK, "MSG_task_get failed");
XBT_INFO("Handling task \"%s\"", MSG_task_get_name(task));
- if (!strcmp(MSG_task_get_name(task), "finalize")) {
+ if (not strcmp(MSG_task_get_name(task), "finalize")) {
XBT_INFO("Destroying task \"%s\"", task->name);
MSG_task_destroy(task);
break;
}
- if (!strcmp(MSG_task_get_name(task), "cancel")) {
+ if (not strcmp(MSG_task_get_name(task), "cancel")) {
MSG_process_create("worker1", worker_main, task, MSG_host_self());
MSG_process_sleep(0.1);
XBT_INFO("Canceling task \"%s\"", task->name);
XBT_INFO("Task listen works on regular mailboxes");
char* res = static_cast<char*>(simgrid::s4u::this_actor::recv(mailbox));
- xbt_assert(!strcmp("Some data", res), "Data received: %s", res);
+ xbt_assert(not strcmp("Some data", res), "Data received: %s", res);
XBT_INFO("Data successfully received from regular mailbox");
xbt_free(res);
XBT_INFO("Task listen works on asynchronous mailboxes");
res = static_cast<char*>(simgrid::s4u::this_actor::recv(mailbox2));
- xbt_assert(!strcmp("More data", res));
+ xbt_assert(not strcmp("More data", res));
xbt_free(res);
XBT_INFO("Data successfully received from asynchronous mailbox");
{
XBT_INFO("Print the content of the storage element: %s", storage->name());
std::map<std::string, sg_size_t*>* content = storage->content();
- if (!content->empty()) {
+ if (not content->empty()) {
for (auto entry : *content)
XBT_INFO("\t%s size: %llu bytes", entry.first.c_str(), *entry.second);
} else {
XBT_INFO("Server waiting for transfers ...");
while (1) {
char* msg = static_cast<char*>(simgrid::s4u::this_actor::recv(mailbox));
- if (!strcmp(msg, "finalize")) { // Shutdown ...
+ if (not strcmp(msg, "finalize")) { // Shutdown ...
xbt_free(msg);
break;
} else { // Receive file to save
bool parse_ok = true;
for (int i = 1; i < argc; i++) {
if (std::strlen(argv[i]) > 1 && argv[i][0] == '-' && argv[i][1] == '-') {
- if (!std::strcmp(argv[i], "--timings")) {
+ if (not std::strcmp(argv[i], "--timings")) {
*timings = 1;
} else {
parse_ok = false;
if (hosts[i]->coreCount() > 1) {
std::printf(" core=\"%d\"", hosts[i]->coreCount());
}
- if (props && !xbt_dict_is_empty(props)) {
+ if (props && not xbt_dict_is_empty(props)) {
std::printf(">\n");
xbt_dict_foreach (props, cursor, key, data) {
std::printf(" <prop id=\"%s\" value=\"%s\"/>\n", key, data);
std::vector<simgrid::surf::LinkImpl*> route;
simgrid::kernel::routing::NetPoint* netcardDst = host2->pimpl_netpoint;
simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(netcardSrc, netcardDst, &route, nullptr);
- if (!route.empty()) {
+ if (not route.empty()) {
std::printf(" <route src=\"%s\" dst=\"%s\">\n ", host1->cname(), host2->cname());
for (auto link : route)
std::printf("<link_ctn id=\"%s\"/>", link->cname());
l=j;
fprintf(stderr,"(%i):%i/%i ",i,j,k);
lmm_constraint_concurrency_maximum_reset(cnst[i]);
- xbt_assert(!lmm_constraint_concurrency_maximum_get(cnst[i]));
+ xbt_assert(not lmm_constraint_concurrency_maximum_get(cnst[i]));
if(i%10==9)
fprintf(stderr,"\n");
}
}
//what class?
- if(!strcmp(argv[1],"small"))
- testclass=0;
- else if(!strcmp(argv[1],"medium"))
- testclass=1;
- else if(!strcmp(argv[1],"big"))
- testclass=2;
- else if(!strcmp(argv[1],"huge"))
- testclass=3;
+ if (not strcmp(argv[1], "small"))
+ testclass = 0;
+ else if (not strcmp(argv[1], "medium"))
+ testclass = 1;
+ else if (not strcmp(argv[1], "big"))
+ testclass = 2;
+ else if (not strcmp(argv[1], "huge"))
+ testclass = 3;
else {
fprintf(stderr, "Unknown class \"%s\", aborting!\n",argv[1]);
return -2;
} catch(xbt_ex& e) {
gotit = true;
}
- if (!gotit)
+ if (not gotit)
xbt_die("FAIL: A double-free went undetected (for size:%d)",size_of_block(i));
}
} catch(xbt_ex& e) {
gotit = true;
}
- if (!gotit)
+ if (not gotit)
xbt_die("FAIL: A double-free went undetected (for size:%d)",size_of_block(i));
}