Skip to content

Commit

Permalink
Adition of mapping heuristic based on the work: A Hierarchical Distri…
Browse files Browse the repository at this point in the history
…buted Runtime Resource Management Scheme for NoC-Based Many-Cores
  • Loading branch information
mcruaro committed Jul 16, 2019
1 parent 7b4892a commit 1875089
Show file tree
Hide file tree
Showing 16 changed files with 283 additions and 106 deletions.
3 changes: 3 additions & 0 deletions build_env/bin/memphis-app
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ for app_name in app_list:

print "\nApps" +app_names[1:]+ " generated and compiled successfully!!!\n"

if exit_status != 0:
raise Exception()

sys.exit(exit_status)


Expand Down
3 changes: 3 additions & 0 deletions build_env/bin/memphis-gen
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ except:
#Generates the testcase directory
exit_status = os.system("python "+ MEMPHIS_PATH+"/build_env/scripts/testcase_builder.py "+ INPUT_TESTCASE_FILE_PATH)

if exit_status != 0:
raise Exception()

sys.exit(exit_status)
2 changes: 1 addition & 1 deletion build_env/makes/sim.do
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
vsim -novopt -t ps +notimingchecks hardware/work.test_bench
vsim -novopt -t 10ns +notimingchecks hardware/work.test_bench

do wave.do
onerror {resume}
Expand Down
2 changes: 1 addition & 1 deletion build_env/scripts/kernel_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,4 @@ def generate_memory( yaml_r ):
os.symlink("../../software/kernel_slave.txt", dst_ram_file)


main()
main()
3 changes: 2 additions & 1 deletion build_env/scripts/testcase_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,10 @@ def main():

if exit_status == 0:
print "\n\nMemphis platform generated and compiled successfully at:\n-"+TESTCASE_PATH+"\n"
sys.exit(0)
else:
print "\n*** ERROR: Memphis compilation not completed, process stopped!!!\n"

sys.exit(1)
# ----------------------------------------- FUNCTIONS ---------------------------------------------

def copy_scripts(memphis_path, testcase_path):
Expand Down
8 changes: 4 additions & 4 deletions hardware/sc/pe/dmni/dmni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ void dmni::receive(){
switch (SR.read()) {
case HEADER:
intr_counter_temp = intr_counter_temp + 1;
if(address_router == 0){
/*if(address_router == 0){
cout<<"Master receiving msg "<<endl;
}
}*/
is_header[last.read()] = 1;
SR.write(PAYLOAD);
break;
Expand Down Expand Up @@ -252,9 +252,9 @@ void dmni::send(){
send_size_2.write(size_2.read());
send_active.write(1);
DMNI_Send.write(LOAD);
if(address_router == 0){
/*if(address_router == 0){
cout<<"Master sending msg "<<endl;
}
}*/
}
break;

Expand Down
11 changes: 6 additions & 5 deletions hardware/sc/peripherals/app_injector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ void app_injector::task_allocation_loader(){
packet[ptr_index++] = code_size; //Code size
ptr_index = ptr_index + 2; //Jumps to the end of ServiceHeader

cout << "Loading task ID " << id << " to PE " << (allocated_proc >> 8) << "x" << (allocated_proc & 0xFF) << endl;
//Assembles txt
for(unsigned int i=0; i<code_size; i++){
getline (repo_file,line);
Expand Down Expand Up @@ -342,14 +343,14 @@ void app_injector::receive_packet(){

case HEADER:

if (rx.read() == 1)
if (rx.read() == 1 && sig_credit_out.read() == 1)
EA_receive_packet = PAYLOAD_SIZE;

break;

case PAYLOAD_SIZE:

if (rx.read() == 1){
if (rx.read() == 1 && sig_credit_out.read() == 1){
payload_size = data_in.read();
flit_counter = 2;
EA_receive_packet = SERVICE;
Expand All @@ -358,7 +359,7 @@ void app_injector::receive_packet(){
break;
case SERVICE:

if (rx.read() == 1){
if (rx.read() == 1 && sig_credit_out.read() == 1){
if (data_in.read() == APP_REQ_ACK)
EA_receive_packet = RECEIVE_APP_ACK;
else if (data_in.read() == APP_ALLOCATION_REQUEST)
Expand All @@ -369,7 +370,7 @@ void app_injector::receive_packet(){

case RECEIVE_APP_ACK: //APP_REQ_ACK:

if (rx.read() == 1){
if (rx.read() == 1 && sig_credit_out.read() == 1){

if(flit_counter == 4){ //Reads app_ID flit from ServiceHeader

Expand All @@ -393,7 +394,7 @@ void app_injector::receive_packet(){

case RECEIVE_APP_ALLOCATION:

if (rx.read() == 1){
if (rx.read() == 1 && sig_credit_out.read() == 1){

if (flit_counter == 9){// Gets task number from flit 9

Expand Down
12 changes: 6 additions & 6 deletions hardware/vhdl/pe/dmni/dmni.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ begin
case( SR ) is
when HEADER =>
intr_counter_temp <= intr_counter_temp + 1;
assert address_router = x"0000"
report "Master receiving msg"
severity note;
--assert address_router = x"0000"
-- report "Master receiving msg"
--severity note;
is_header(CONV_INTEGER(last)) <= '1';
SR <= PAYLOAD;
when PAYLOAD =>
Expand Down Expand Up @@ -289,9 +289,9 @@ begin
send_size_2 <= size_2;
send_active_2 <= '1';
DMNI_Send <= LOAD;
assert address_router = x"0000"
report "Master sending msg"
severity note;
--assert address_router = x"0000"
-- report "Master sending msg"
--severity note;
end if ;

when LOAD =>
Expand Down
29 changes: 12 additions & 17 deletions software/kernel/master/kernel_master.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void send_task_release(Application * app){

app->tasks[i].status = TASK_RUNNING;

putsv("\n -> send TASK_RELEASE to task ", p->task_ID);
putsv("-> send TASK_RELEASE to task ", p->task_ID);
//puts(" in proc "); puts(itoh(p->header)); puts("\n----\n");
}

Expand Down Expand Up @@ -243,7 +243,7 @@ void request_application(Application *app){
unsigned int task_info[app->tasks_number*4];
int index_counter;

puts("\nRequest APP\n");
//puts("\nRequest APP\n");

pending_app_to_map--;

Expand Down Expand Up @@ -358,14 +358,14 @@ void handle_packet() {

case TASK_ALLOCATED:

putsv("\n -> TASK ALLOCATED from task ", p.task_ID);
putsv("-> TASK ALLOCATED from task ", p.task_ID);
app_id = p.task_ID >> 8;

app = get_application_ptr(app_id);

allocated_tasks = set_task_allocated(app, p.task_ID);

putsv("Allocated tasks: ", allocated_tasks);
//putsv("Allocated tasks: ", allocated_tasks);

if (allocated_tasks == app->tasks_number){

Expand Down Expand Up @@ -407,19 +407,18 @@ void handle_packet() {
index_counter++; //Skips address
index_counter++; //Skips size

puts("New task mapping report: "); puts(itoa(task_id)); puts(" mapped at proc ");
puts(itoh(allocated_proc)); puts("\n");

/*These lines above mantain the cluster resource control at a global master perspective*/
master_addr = get_master_address(allocated_proc);

puts("Task ID "); puts(itoa(task_id)); puts(" mapped at proc "); puts(itoh(allocated_proc)); puts(" and cluster "); puts(itoh(master_addr)); puts("\n");

//net_address is equal to global master address, it is necessary to verifies if is master because the master controls the cluster resources by gte insertion of new tasks request
if (master_addr != net_address){

//Reuse of the variable master_addr to store the cluster ID
master_addr = get_cluster_ID(master_addr >> 8, master_addr & 0xFF);

putsv("New resource allocated to cluster ", master_addr);
//putsv("New resource allocated to cluster ", master_addr);
allocate_cluster_resource(master_addr, 1);
}

Expand Down Expand Up @@ -512,7 +511,7 @@ void handle_packet() {
//If 0 then there is no application to be allocated, otherwise, stores the number of application tasks and cluster ID
waiting_app_allocation = p.app_task_number << 16 | master_addr;

puts("-----> NEW_APP_REQ from app injector. Task number is "); puts(itoa(p.app_task_number)); putsv(". App mapped at cluster ", p.cluster_ID);
puts("\n-----> NEW_APP_REQ from app injector. Task number is "); puts(itoa(p.app_task_number)); putsv(". App mapped at cluster ", p.cluster_ID);

break;

Expand Down Expand Up @@ -616,20 +615,16 @@ void handle_new_app(int app_ID, volatile unsigned int *ref_address, unsigned int
//Cuidado com app_descriptor_size muito grande, pode estourar a memoria
unsigned int app_descriptor[app_descriptor_size];

puts("programming DMNI\n");

DMNI_read_data( (unsigned int) app_descriptor, app_descriptor_size);

ref_address = app_descriptor;

puts("DNNI reading complete\n");

//Creates a new app by reading from ref_address
application = read_and_create_application(app_ID, ref_address);

pending_app_to_map++;

mapping_completed = application_mapping(clusterID, application->app_ID);
mapping_completed = application_mapping(application->app_ID);

if (mapping_completed){

Expand Down Expand Up @@ -658,13 +653,13 @@ void handle_app_request(){
num_app_tasks = waiting_app_allocation >> 16;

if (num_app_tasks > total_mpsoc_resources){
puts("Cluster full\n");
//puts("Cluster full\n");
return;
}

cluster_static = waiting_app_allocation & 0xFFFF;

puts("\nNew app req handled! - cluster mapping is ");
puts("\nHandled new app with cluster mapping ");

if (cluster_static >= CLUSTER_NUMBER){

Expand All @@ -679,7 +674,7 @@ void handle_app_request(){

waiting_app_allocation = 0;

putsv("\nApplication ID: ", app_id_counter);
putsv("Application ID: ", app_id_counter);

//putsv("Global Master reserve application: ", num_app_tasks);
//putsv("total_mpsoc_resources ", total_mpsoc_resources);
Expand Down
5 changes: 4 additions & 1 deletion software/kernel/slave/kernel_slave.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,13 @@ void send_task_real_time_change(TCB * tcb_ptr){
send_packet(p, 0, 0);
}

/** Assembles and sends a SLACK_TIME_REPORT packet to the master kernel
/** Assembles and sends a SLACK_TIME_REPORT packet to the master kernel. ATTENTION: currently
* slack time report to manager is disabled because only disturbs the debuggability of the system
*/
void send_slack_time_report(){

return; //Remove this line to restore the slack time report send to manager

ServiceHeader * p = get_service_header_slot();

p->header = cluster_master_address;
Expand Down
20 changes: 20 additions & 0 deletions software/modules/applications.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,26 @@ Application * get_next_pending_app(){
return older_app;
}

/** Create a list of initial PEs. A initial PE is the one that task ID 0 of each app is mapped
* \return Void
* \param initial_list array pointer which cointas the list of initial PE addresses
* \param size variable pointer that stores the size of the list
*/
void get_initial_pe_list(int * initial_list, int * size){

*size = 0;

for(int i=0; i<MAX_CLUSTER_APP; i++){

if (applications[i].status == RUNNING){
initial_list[*size] = applications[i].tasks[0].allocated_proc;
//Puts("Task id 0 from app "); Puts(itoa(applications[i].app_ID)); Puts(" mapped at ");
//Puts(itoh(initial_list[*size])); Puts("\n");
*size = *size + 1;
}
}
}

/** Set a task status as allocated and verifies the number of allocated task for the application
* \param app Application pointer of the task
* \param task_id ID of the allocated task
Expand Down
2 changes: 2 additions & 0 deletions software/modules/applications.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ void set_task_migrated(int, int);

unsigned int get_app_id_counter();

void get_initial_pe_list(int *, int *);

Application * read_and_create_application(unsigned int, volatile unsigned int *);

void remove_application(int);
Expand Down
2 changes: 1 addition & 1 deletion software/modules/processors.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Processor * search_processor(int proc_address){
}
}

putsv("ERROR: Processor not found ", proc_address);
puts("ERROR: Processor not found "); puts(itoh(proc_address)); puts("\n");
while(1);
return 0;
}
Expand Down
35 changes: 27 additions & 8 deletions software/modules/reclustering.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ void reclustering_setup(int c_id){

#if RECLUSTERING_DEBUG
putsv("CLuster id: ", clusterID);
putsv("starting_x_cluster_size: ", starting_x_cluster_size);
putsv("starting_y_cluster_size: ", starting_y_cluster_size);
#endif

reclustering.active = 0;
Expand All @@ -71,20 +73,33 @@ int is_reclustering_NOT_active(){
*/
void send_loan_proc_request(int address, int taskID){

ServiceHeader *p = get_service_header_slot();
ServiceHeader *p;
Application * app_ptr;
int initial_proc;

app_ptr = get_application_ptr(taskID >> 8);

if (app_ptr->tasks[0].allocated_proc == -1){
initial_proc = (cluster_info[clusterID].master_x << 8) | cluster_info[clusterID].master_y;
} else {
initial_proc = app_ptr->tasks[0].allocated_proc;
}


p = get_service_header_slot();

p->header = address;

p->service = LOAN_PROCESSOR_REQUEST;

p->task_ID = taskID;

p->allocated_processor = (cluster_info[clusterID].master_x << 8) | cluster_info[clusterID].master_y;
p->allocated_processor = initial_proc;

send_packet(p, 0, 0);

#if RECLUSTERING_DEBUG
puts("-> send loan proc REQUEST para proc "); puts(itoh(address)); putsv(" task id ", taskID);
puts("-> send loan proc REQUEST para proc "); puts(itoh(address)); puts(" task id "); puts(itoa(taskID)); puts(" initial proc "); puts(itoh(initial_proc)); puts("\n");
#endif

}
Expand Down Expand Up @@ -211,7 +226,7 @@ void handle_reclustering(ServiceHeader * p){

int mapped_proc;
Application *app;
int hops;
int hops, ref_x, ref_y, curr_x, curr_y;

switch(p->service){

Expand All @@ -228,13 +243,17 @@ void handle_reclustering(ServiceHeader * p){
} else {

//Procura pelo processador mais proximo do processador requisitnate
mapped_proc = map_task(p->task_ID);
mapped_proc = reclustering_map(p->allocated_processor);

ref_x = (p->allocated_processor >> 8);
ref_y = (p->allocated_processor & 0xFF);
curr_x = (mapped_proc >> 8);
curr_y = (mapped_proc & 0xFF);

hops = (p->allocated_processor >> 8) + (mapped_proc >> 8);
hops += (p->allocated_processor & 0xFF) + (mapped_proc & 0xFF);
hops = (abs(ref_x - curr_x) + abs(ref_y - curr_y));

#if RECLUSTERING_DEBUG
puts("Alocou proc "); puts(itoh(mapped_proc)); puts("\n");
puts("Alocou proc "); puts(itoh(mapped_proc)); putsv(" hops ", hops); puts("\n");
#endif

send_loan_proc_delivery(p->source_PE, p->task_ID, mapped_proc, hops);
Expand Down
Loading

0 comments on commit 1875089

Please sign in to comment.