Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions src/solvers/td3.ml
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,9 @@ module WP =

start_event ();

(* reluctantly unchanged return nodes to additionally query for postsolving to get warnings, etc. *)
let reluctant_vs: S.Var.t list ref = ref [] in

if GobConfig.get_bool "incremental.load" then (
let c = S.increment.changes in
List.(Printf.printf "change_info = { unchanged = %d; changed = %d; added = %d; removed = %d }\n" (length c.unchanged) (length c.changed) (length c.added) (length c.removed));
Expand Down Expand Up @@ -737,7 +740,7 @@ module WP =
print_endline "Removing data for changed and removed functions...";
let delete_marked s = HM.iter (fun k _ -> HM.remove s k) marked_for_deletion in
delete_marked rho;
delete_marked infl;
delete_marked infl; (* TODO: delete from inner sets? *)
delete_marked wpoint;

(* destabilize_with_side doesn't have all infl to follow anymore, so should somewhat work with reluctant *)
Expand Down Expand Up @@ -826,8 +829,15 @@ module WP =
);

delete_marked stable;
delete_marked side_dep;
delete_marked side_infl;
delete_marked side_dep; (* TODO: delete from inner sets? *)
delete_marked side_infl; (* TODO: delete from inner sets? *)

(* delete from incremental postsolving/warning structures to remove spurious warnings *)
delete_marked superstable;
delete_marked var_messages;
delete_marked rho_write;
HM.iter (fun x w -> delete_marked w) rho_write;

print_data data "Data after clean-up";

(* TODO: reluctant doesn't call destabilize on removed functions or old copies of modified functions (e.g. after removing write), so those globals don't get restarted *)
Expand All @@ -845,6 +855,10 @@ module WP =
destabilize x;
HM.replace stable x ()
)
else (
print_endline "Destabilization not required...";
reluctant_vs := x :: !reluctant_vs
)
) old_ret;

print_endline "Final solve..."
Expand Down Expand Up @@ -1101,7 +1115,7 @@ module WP =

let module Post = PostSolver.MakeIncrList (MakeIncrListArg) in

Post.post st vs rho;
Post.post st (!reluctant_vs @ vs) rho;

print_data data "Data after postsolve";

Expand Down
23 changes: 23 additions & 0 deletions tests/incremental/13-restart-write/06-mutex-simple-reluctant.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <pthread.h>
#include <stdio.h>

int myglobal;
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER;

void *t_fun(void *arg) {
pthread_mutex_lock(&mutex1);
myglobal=myglobal+1; // RACE!
pthread_mutex_unlock(&mutex1);
return NULL;
}

int main(void) {
pthread_t id;
pthread_create(&id, NULL, t_fun, NULL);
pthread_mutex_lock(&mutex2);
myglobal=myglobal+1; // RACE!
pthread_mutex_unlock(&mutex2);
pthread_join (id, NULL);
return 0;
}
12 changes: 12 additions & 0 deletions tests/incremental/13-restart-write/06-mutex-simple-reluctant.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"incremental": {
"restart": {
"sided": {
"enabled": false
}
},
"reluctant": {
"on": true
}
}
}
24 changes: 24 additions & 0 deletions tests/incremental/13-restart-write/06-mutex-simple-reluctant.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--- tests/incremental/13-restart-write/06-mutex-simple-reluctant.c
+++ tests/incremental/13-restart-write/06-mutex-simple-reluctant.c
@@ -7,7 +7,7 @@ pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER;

void *t_fun(void *arg) {
pthread_mutex_lock(&mutex1);
- myglobal=myglobal+1; // RACE!
+ myglobal=myglobal+1; // NORACE
pthread_mutex_unlock(&mutex1);
return NULL;
}
@@ -15,9 +15,9 @@ void *t_fun(void *arg) {
int main(void) {
pthread_t id;
pthread_create(&id, NULL, t_fun, NULL);
- pthread_mutex_lock(&mutex2);
- myglobal=myglobal+1; // RACE!
- pthread_mutex_unlock(&mutex2);
+ pthread_mutex_lock(&mutex1);
+ myglobal=myglobal+1; // NORACE
+ pthread_mutex_unlock(&mutex1);
pthread_join (id, NULL);
return 0;
}
23 changes: 23 additions & 0 deletions tests/incremental/13-restart-write/07-mutex-simple-reluctant2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <pthread.h>
#include <stdio.h>

int myglobal;
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER;

void *t_fun(void *arg) {
pthread_mutex_lock(&mutex1);
myglobal=myglobal+1; // RACE!
pthread_mutex_unlock(&mutex1);
return NULL;
}

int main(void) {
pthread_t id;
pthread_create(&id, NULL, t_fun, NULL);
pthread_mutex_lock(&mutex2);
myglobal=myglobal+1; // RACE!
pthread_mutex_unlock(&mutex2);
pthread_join (id, NULL);
return 0;
}
12 changes: 12 additions & 0 deletions tests/incremental/13-restart-write/07-mutex-simple-reluctant2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"incremental": {
"restart": {
"sided": {
"enabled": false
}
},
"reluctant": {
"on": true
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- tests/incremental/13-restart-write/07-mutex-simple-reluctant2.c
+++ tests/incremental/13-restart-write/07-mutex-simple-reluctant2.c
@@ -7,7 +7,7 @@ pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER;

void *t_fun(void *arg) {
pthread_mutex_lock(&mutex1);
- myglobal=myglobal+1; // RACE!
+ myglobal=myglobal+2; // RACE!
pthread_mutex_unlock(&mutex1);
return NULL;
}
22 changes: 22 additions & 0 deletions tests/incremental/13-restart-write/08-mutex-simple-reluctant3.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <pthread.h>
#include <stdio.h>

int myglobal;
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER;

void *t_fun(void *arg) {
pthread_mutex_lock(&mutex1);
pthread_mutex_unlock(&mutex1);
return NULL;
}

int main(void) {
pthread_t id;
pthread_create(&id, NULL, t_fun, NULL);
pthread_mutex_lock(&mutex2);
myglobal=myglobal+1; // NORACE
pthread_mutex_unlock(&mutex2);
pthread_join (id, NULL);
return 0;
}
12 changes: 12 additions & 0 deletions tests/incremental/13-restart-write/08-mutex-simple-reluctant3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"incremental": {
"restart": {
"sided": {
"enabled": false
}
},
"reluctant": {
"on": true
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--- tests/incremental/13-restart-write/08-mutex-simple-reluctant3.c
+++ tests/incremental/13-restart-write/08-mutex-simple-reluctant3.c
@@ -7,6 +7,7 @@ pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER;

void *t_fun(void *arg) {
pthread_mutex_lock(&mutex1);
+ myglobal=myglobal+1; // RACE!
pthread_mutex_unlock(&mutex1);
return NULL;
}
@@ -15,7 +16,7 @@ int main(void) {
pthread_t id;
pthread_create(&id, NULL, t_fun, NULL);
pthread_mutex_lock(&mutex2);
- myglobal=myglobal+1; // NORACE
+ myglobal=myglobal+1; // RACE!
pthread_mutex_unlock(&mutex2);
pthread_join (id, NULL);
return 0;