Commit a80ccddc authored by rgomes22's avatar rgomes22

migrated local resource manager to Global Resource Manager responsible for several nodes

parent b86ee33c
......@@ -55,4 +55,6 @@
<factorypathentry kind="VARJAR" id="M2_REPO/com/ibm/wala/com.ibm.wala.cast.java.ecj/1.5.0/com.ibm.wala.cast.java.ecj-1.5.0.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/eclipse/jdt/org.eclipse.jdt.core/3.10.0/org.eclipse.jdt.core-3.10.0.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/json/json/20190722/json-20190722.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/rabbitmq/amqp-client/5.10.0/amqp-client-5.10.0.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/slf4j/slf4j-api/1.7.30/slf4j-api-1.7.30.jar" enabled="true" runInBatchMode="false"/>
</factorypath>
Go to /dataclay directory and initialize dataclay
(Start dataClay)
$ ./start_dataclay.sh
(Register model located in `model` folder into started dataClay instance)
$ ./register_model.sh
(Get stubs of your registered model)
$ ./get_stubs.sh
Go to /app directory
Change the StubsClasspath in cfgfiles/session.propeties to the correct path were the stubs generated by ./get_stubs.sh were created
To be able to compile the app outside a container, install the stubs in the local maven repository
$ ./install_mvn_stubs.sh
Finnaly, run the demo which includes Time and Energy requirements
$ ./run_nfrtool.sh
\ No newline at end of file
#!/bin/bash
# Needed when this script is executed by NFRTool.java
cd fake_worker
# fakeworker1 N=500000
# fakeworker2 N=50000
# fakeworker3 N=5000
sed -i 's/500000/50000/' fakeworker.c
gcc fakeworker.c -o fakeworker2
sed -i 's/50000/5000/' fakeworker.c
gcc fakeworker.c -o fakeworker3
sed -i 's/5000/500000/' fakeworker.c
gcc fakeworker.c -o fakeworker1
# fakeworker4 NUM_THREADS 6
# fakeworker5 NUM_THREADS 4
# fakeworker6 NUM_THREADS 2
sed -i 's/6/4/' fakethreadworker.c
gcc fakethreadworker.c -o fakeworker5 -lpthread
sed -i 's/4/2/' fakethreadworker.c
gcc fakethreadworker.c -o fakeworker6 -lpthread
sed -i 's/2/6/' fakethreadworker.c
gcc fakethreadworker.c -o fakeworker4 -lpthread
// fakeworker4 NUM_THREADS 6
// fakeworker5 NUM_THREADS 4
// fakeworker6 NUM_THREADS 2
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
......
// fakeworker1 n=500000
// fakeworker2 n=50000
// fakeworker3 n=5000
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define N 500000
int main()
{
for (;;)
{
int n = 500000, i;
int i;
unsigned long long fact = 1;
for (i = 1; i <= n; ++i)
for (i = 1; i <= N; i++)
{
fact *= i;
}
......
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
pthread_t tid[4];
void *function(void *var)
{
pthread_t id = pthread_self();
for(;;){
int n=500000, i;
unsigned long long fact = 1;
for (i = 1; i <= n; ++i) {
fact *= i;
}
//printf("%lu\n",id);
usleep(1);
}
}
int main()
{
int i;
for (i = 0; i < 4; i++)
{
pthread_create(&(tid[i]), NULL, &function, NULL);
}
for (i = 0; i < 4; i++)
{
pthread_join((tid[i]), NULL);
}
return 0;
}
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="jpa" name="JPA">
<configuration>
<setting name="validation-enabled" value="true" />
<datasource-mapping />
<naming-strategy-map />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: es.bsc.compss:nfrtool-dataclay-stubs:2.0" level="project" />
<orderEntry type="library" name="Maven: es.bsc.dataclay:dataclay:2.1" level="project" />
<orderEntry type="library" name="Maven: javax.annotation:javax.annotation-api:1.3.2" level="project" />
<orderEntry type="library" name="Maven: io.grpc:grpc-netty-shaded:1.25.0" level="project" />
<orderEntry type="library" name="Maven: io.grpc:grpc-core:1.25.0" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.5" level="project" />
<orderEntry type="library" name="Maven: com.google.android:annotations:4.1.1.4" level="project" />
<orderEntry type="library" name="Maven: io.perfmark:perfmark-api:0.19.0" level="project" />
<orderEntry type="library" name="Maven: io.opencensus:opencensus-api:0.21.0" level="project" />
<orderEntry type="library" name="Maven: io.opencensus:opencensus-contrib-grpc-metrics:0.21.0" level="project" />
<orderEntry type="library" name="Maven: io.grpc:grpc-protobuf:1.25.0" level="project" />
<orderEntry type="library" name="Maven: io.grpc:grpc-api:1.25.0" level="project" />
<orderEntry type="library" name="Maven: io.grpc:grpc-context:1.25.0" level="project" />
<orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.3.3" level="project" />
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
<orderEntry type="library" name="Maven: org.codehaus.mojo:animal-sniffer-annotations:1.17" level="project" />
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:3.10.0" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:28.1-android" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:failureaccess:1.0.1" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava" level="project" />
<orderEntry type="library" name="Maven: org.checkerframework:checker-compat-qual:2.5.5" level="project" />
<orderEntry type="library" name="Maven: com.google.j2objc:j2objc-annotations:1.3" level="project" />
<orderEntry type="library" name="Maven: com.google.api.grpc:proto-google-common-protos:1.12.0" level="project" />
<orderEntry type="library" name="Maven: io.grpc:grpc-protobuf-lite:1.25.0" level="project" />
<orderEntry type="library" name="Maven: io.grpc:grpc-stub:1.25.0" level="project" />
<orderEntry type="library" name="Maven: org.postgresql:postgresql:9.4.1212" level="project" />
<orderEntry type="library" name="Maven: org.ow2.asm:asm:7.2" level="project" />
<orderEntry type="library" name="Maven: org.ow2.asm:asm-commons:7.2" level="project" />
<orderEntry type="library" name="Maven: org.ow2.asm:asm-analysis:7.2" level="project" />
<orderEntry type="library" name="Maven: org.ow2.asm:asm-tree:7.2" level="project" />
<orderEntry type="library" name="Maven: org.ow2.asm:asm-util:7.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.11.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-core:2.11.0" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.10.0" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.10.0" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.10.0" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.5" level="project" />
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.25" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-dbcp2:2.1.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-pool2:2.4.2" level="project" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />
<orderEntry type="library" name="Maven: org.xerial:sqlite-jdbc:3.21.0.1" level="project" />
<orderEntry type="library" name="Maven: javax.persistence:javax.persistence-api:2.2" level="project" />
<orderEntry type="library" name="Maven: org.aspectj:aspectjrt:1.9.4" level="project" />
<orderEntry type="library" name="Maven: org.aspectj:aspectjtools:1.9.4" level="project" />
<orderEntry type="library" name="Maven: es.bsc.dataclay:extrae:3.6.1" level="project" />
<orderEntry type="library" name="Maven: org.reflections:reflections:0.9.11" level="project" />
<orderEntry type="library" name="Maven: org.javassist:javassist:3.21.0-GA" level="project" />
<orderEntry type="library" name="Maven: com.ibm.wala:com.ibm.wala.shrike:1.5.0" level="project" />
<orderEntry type="library" name="Maven: com.ibm.wala:com.ibm.wala.core:1.5.0" level="project" />
<orderEntry type="library" name="Maven: com.ibm.wala:com.ibm.wala.cast:1.5.0" level="project" />
<orderEntry type="library" name="Maven: com.ibm.wala:com.ibm.wala.cast.java:1.5.0" level="project" />
<orderEntry type="library" name="Maven: com.ibm.wala:com.ibm.wala.util:1.5.0" level="project" />
<orderEntry type="library" name="Maven: com.ibm.wala:com.ibm.wala.cast.java.ecj:1.5.0" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.jdt:org.eclipse.jdt.core:3.10.0" level="project" />
<orderEntry type="library" name="Maven: org.json:json:20190722" level="project" />
</component>
</module>
\ No newline at end of file
......@@ -11,6 +11,7 @@
<maven.compiler.target>8</maven.compiler.target>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.release>8</maven.compiler.release>
<amqp-client.version>5.10.0</amqp-client.version>
</properties>
<dependencies>
<dependency>
......@@ -23,6 +24,16 @@
<artifactId>dataclay</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20190722</version>
</dependency>
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
<version>${amqp-client.version}</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
......@@ -64,6 +75,22 @@
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
......
This diff is collapsed.
No preview for this file type
This diff is collapsed.
This diff is collapsed.
No preview for this file type
......@@ -18,16 +18,19 @@
#include <signal.h>
#define PERIOD 1 // Period of metrics measurement
#define NUM_EVENTS 7 // Number of metrics measured
#define NUM_EVENTS 10 // Number of metrics measured
enum
{
MISS = 0, //branch-misses
CYCLES = 1, //cpu-cycles
INSTRU = 2, //instructions
CS = 3, //context-switches
CLOCK = 4, //cpu-clock
MIGRATIONS = 5, //migrations
TASK = 6 //task-clock
TOTAL = 0, //branch-instructions
MISS = 1, //branch-misses
CYCLES = 2, //cpu-cycles
BUS = 3, //bus-cycles
REF = 4, //ref-cycles
INSTRU = 5, //instructions
CS = 6, //context-switches
CLOCK = 7, //cpu-clock
MIGRATIONS = 8, //migrations
TASK = 9 //task-clock
};
struct read_format
......@@ -103,6 +106,8 @@ int force_use_script = 0;
void handle_junk_files(int sig);
void *sendMetricsToServerScript(void *pos);
int inet_pton(int af, const char *src, void *dst);
int main(int argc, char **argv)
{
int ret = EXIT_FAILURE;
......@@ -226,7 +231,6 @@ int main(int argc, char **argv)
int n = write(sock_cli, update, strlen(update));
if (n < 0)
perror("ERROR! Writing to server!!!\n");
//printf("Finished my compare job!!\n");
memset(&buffer, 0, sizeof buffer);
}
......@@ -469,27 +473,30 @@ static int setup_cntr(int *const fd, uint64_t type, uint64_t event, int pid, int
*fd = _perf_event_open(&perf_attr, pid, -1, leader, 0);
if (*fd < 0)
{
perror("ERROR! _perf_event_open failed!");
printf("ERROR %d ",*fd);
perror("ERROR! _perf_event_open failed! ");
}
return (*fd < 0);
}
int countingEvents(int *counters_fd, int pid)
{
printf("PID %d\n",pid);
int ret;
ret = EXIT_FAILURE;
// Counters Hardware Type
//setup_cntr(&counters_fd[TOTAL], PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_INSTRUCTIONS, pid, -1);
setup_cntr(&counters_fd[MISS], PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_MISSES, pid, -1);
setup_cntr(&counters_fd[CYCLES], PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES, pid, counters_fd[MISS]);
// setup_cntr(&counters_fd[BUS], PERF_TYPE_HARDWARE, PERF_COUNT_HW_BUS_CYCLES, pid, counters_fd[TOTAL]);
// setup_cntr(&counters_fd[REF], PERF_TYPE_HARDWARE, PERF_COUNT_HW_REF_CPU_CYCLES, pid, counters_fd[TOTAL]);
setup_cntr(&counters_fd[INSTRU], PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS, pid, counters_fd[MISS]);
setup_cntr(&counters_fd[TOTAL], PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_INSTRUCTIONS, pid, -1);
setup_cntr(&counters_fd[MISS], PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_MISSES, pid, counters_fd[TOTAL]);
setup_cntr(&counters_fd[CYCLES], PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES, pid, counters_fd[TOTAL]);
setup_cntr(&counters_fd[BUS], PERF_TYPE_HARDWARE, PERF_COUNT_HW_BUS_CYCLES, pid, counters_fd[TOTAL]);
setup_cntr(&counters_fd[REF], PERF_TYPE_HARDWARE, PERF_COUNT_HW_REF_CPU_CYCLES, pid, counters_fd[TOTAL]);
setup_cntr(&counters_fd[INSTRU], PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS, pid, counters_fd[TOTAL]);
// Counters Software Type
setup_cntr(&counters_fd[CS], PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CONTEXT_SWITCHES, pid, counters_fd[MISS]);
setup_cntr(&counters_fd[CLOCK], PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_CLOCK, pid, counters_fd[MISS]);
setup_cntr(&counters_fd[MIGRATIONS], PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_MIGRATIONS, pid, counters_fd[MISS]);
setup_cntr(&counters_fd[TASK], PERF_TYPE_SOFTWARE, PERF_COUNT_SW_TASK_CLOCK, pid, counters_fd[MISS]);
setup_cntr(&counters_fd[CS], PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CONTEXT_SWITCHES, pid, counters_fd[TOTAL]);
setup_cntr(&counters_fd[CLOCK], PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_CLOCK, pid, counters_fd[TOTAL]);
setup_cntr(&counters_fd[MIGRATIONS], PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_MIGRATIONS, pid, counters_fd[TOTAL]);
setup_cntr(&counters_fd[TASK], PERF_TYPE_SOFTWARE, PERF_COUNT_SW_TASK_CLOCK, pid, counters_fd[TOTAL]);
ret = EXIT_SUCCESS;
return ret;
......@@ -536,38 +543,39 @@ void *sendMetricsToServer(void *pos)
// Start monitoring
do
{
if (ioctl(counters_fd[MISS], PERF_EVENT_IOC_RESET, PERF_IOC_FLAG_GROUP))
perror("ioctl(PERF_EVENT_IOC_RESET");
printf("after err %d\n",counters_fd[TOTAL]);
if (ioctl(counters_fd[TOTAL], PERF_EVENT_IOC_RESET, PERF_IOC_FLAG_GROUP))
perror("1- ioctl(PERF_EVENT_IOC_RESET");
if (ioctl(counters_fd[MISS], PERF_EVENT_IOC_ENABLE, PERF_IOC_FLAG_GROUP))
perror("ioctl(PERF_EVENT_IOC_ENABLE");
if (ioctl(counters_fd[TOTAL], PERF_EVENT_IOC_ENABLE, PERF_IOC_FLAG_GROUP))
perror("2- ioctl(PERF_EVENT_IOC_ENABLE");
sleep(PERIOD);
if (ioctl(counters_fd[MISS], PERF_EVENT_IOC_DISABLE, PERF_IOC_FLAG_GROUP))
perror("ioctl(PERF_EVENT_IOC_DISABLE");
if (ioctl(counters_fd[TOTAL], PERF_EVENT_IOC_DISABLE, PERF_IOC_FLAG_GROUP))
perror("3- ioctl(PERF_EVENT_IOC_DISABLE");
read(counters_fd[MISS], &result, sizeof(struct read_format));
read(counters_fd[TOTAL], &result, sizeof(struct read_format));
if (arr_pid[arr_pos].ppid != 0)
{
sem_wait(&proc[arr_pos_proc].thr_mutex);
if (arr_pid[arr_pos].bufferSent == 1)
{
for (int k = MISS; k <= TASK; k++)
for (int k = TOTAL; k <= TASK; k++)
{
proc[arr_pos_proc].metrics.value[k] = result.value[k];
}
}
sem_post(&proc[arr_pos_proc].thr_mutex);
// Barrier needed to make sure that metrics values ​​are "cleaned" with the new metrics values ​​of the thread that sends the buffer
// Barrier needed to make sure that metrics values ​​are "cleaned" with the new metrics values ​​of the thread that sends the buffer
pthread_barrier_wait(&proc[arr_pos_proc].barrier);
if (arr_pid[arr_pos].bufferSent == 0)
{
sem_wait(&proc[arr_pos_proc].thr_mutex);
for (int k = MISS; k <= TASK; k++)
for (int k = TOTAL; k <= TASK; k++)
{
proc[arr_pos_proc].metrics.value[k] += result.value[k];
}
......@@ -587,11 +595,10 @@ void *sendMetricsToServer(void *pos)
{
if (arr_pid[arr_pos].ppid == 0)
{
sprintf(buffer, "{pid:%d,branch-misses:%lu,cpu-cycles:%zu,intructions:%zu,context-switches:%zu,cpu-clock:%.4f,task-clock:%.4f,migrations:%zu}\n",
//sprintf(buffer, "{pid:%d,branch-misses:%lu,branch-total:%zu,cpu-cycles:%zu,bus-cycles:%zu,ref-cycles:%zu,intructions:%zu,context-switches:%zu,cpu-clock:%.4f,task-clock:%.4f,migrations:%zu}\n",
sprintf(buffer, "{pid:%d,branch-misses:%lu,branch-total:%zu,cpu-cycles:%zu,bus-cycles:%zu,ref-cycles:%zu,intructions:%zu,context-switches:%zu,cpu-clock:%.4f,task-clock:%.4f,migrations:%zu}\n",
arr_pid[arr_pos].pid,
result.value[MISS], //result.value[TOTAL],
result.value[CYCLES], //result.value[BUS], result.value[REF],
result.value[MISS], result.value[TOTAL],
result.value[CYCLES], result.value[BUS], result.value[REF],
result.value[INSTRU],
result.value[CS],
result.value[CLOCK] / 1000000000.0 / PERIOD, result.value[TASK] / 1000000000.0 / PERIOD,
......@@ -600,16 +607,15 @@ void *sendMetricsToServer(void *pos)
}
else
{
sprintf(buffer, "{pid:%d,branch-misses:%lu,cpu-cycles:%zu,intructions:%zu,context-switches:%zu,cpu-clock:%.4f,task-clock:%.4f,migrations:%zu}\n",
//sprintf(buffer, "{pid:%d,branch-misses:%lu,branch-total:%zu,cpu-cycles:%zu,bus-cycles:%zu,ref-cycles:%zu,intructions:%zu,context-switches:%zu,cpu-clock:%.4f,task-clock:%.4f,migrations:%zu}\n",
sprintf(buffer, "{pid:%d,branch-misses:%lu,branch-total:%zu,cpu-cycles:%zu,bus-cycles:%zu,ref-cycles:%zu,intructions:%zu,context-switches:%zu,cpu-clock:%.4f,task-clock:%.4f,migrations:%zu}\n",
//sprintf(buffer, "{pid:%d,branch-misses:%lu,branch-total:%zu,bra-missed-prc:%zu,cpu-cycles:%zu,bus-cycles:%zu,ref-cycles:%zu,intructions:%zu,ins-per-cycle:%zu,context-switches:%zu,cpu-clock:%.4f,task-clock:%.4f,migrations:%zu}\n",
arr_pid[arr_pos].ppid,
proc[arr_pos_proc].metrics.value[MISS],
//proc[arr_pos_proc].metrics.value[TOTAL],
proc[arr_pos_proc].metrics.value[TOTAL],
//proc[arr_pos_proc].metrics.value[MISS] / proc[arr_pos_proc].metrics.value[TOTAL],
proc[arr_pos_proc].metrics.value[CYCLES],
// proc[arr_pos_proc].metrics.value[BUS],
// proc[arr_pos_proc].metrics.value[REF],
proc[arr_pos_proc].metrics.value[BUS],
proc[arr_pos_proc].metrics.value[REF],
proc[arr_pos_proc].metrics.value[INSTRU],
//proc[arr_pos_proc].metrics.value[INSTRU] / proc[arr_pos_proc].metrics.value[CYCLES],
proc[arr_pos_proc].metrics.value[CS],
......@@ -686,4 +692,4 @@ void *sendMetricsToServerScript(void *pos)
// [1] Power and Performance Software Analysis and Optimization Jim Kukunas (Chapter 8)
/* The vast majority of events are nonarchitectural, that is, their behavior can vary from
one processor architecture to the next. */
one processor architecture to the next. */
\ No newline at end of file
This diff is collapsed.
#!/bin/bash
# Needed when this script is executed by TimeMonitor.java and EnergyMonitor.java
cd probes
gcc probeEnergyAGX.c -o probeEnergyAGX -lpthread
gcc probeTimeAGX.c -o probeTimeAGX -lpthread
#!/bin/bash
# Needed when this script is executed by TimeMonitor.java and EnergyMonitor.java
#cd probes
#if [ $USER = "ricardo" ]
#then
gcc probeEn.c -o probeEnergy -lpthread
#else
# gcc probeEnergy.c -o probeEnergy -lpthread
#fi
gcc probeTime.c -o probeTime -lpthread
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
CFLAGS = -DNV_IS_LDK=1
TARGET = tegrastats
SRC = main.c
$(TARGET): $(SRC)
$(CC) $(CFLAGS) -o $@ $^
clean:
$(RM) $(TARGET)
.PHONY: clean
This diff is collapsed.
#!/bin/bash
mvn clean package
java -jar target/nfrtool-demo-2.1.jar testApp --mode demo --ip 127.0.0.1
current_arch=`uname -m`
if [ $current_arch = "aarch64" ];
then
java -jar target/nfrtool-demo-2.1.jar testApp --mode demo --ip 127.0.0.1 --agx
else
java -jar target/nfrtool-demo-2.1.jar testApp --mode demo --ip 127.0.0.1
fi
......@@ -17,6 +17,7 @@
package app;
public class ActivationWorkersManager implements Runnable {
private ResourceManager rm;
......@@ -56,7 +57,7 @@ public class ActivationWorkersManager implements Runnable {
activeWorkers.isHistoryUpdated(); // which also means that all metrics are filled
float actualCPUUsage = activeWorkers.getTotalCPUUsage();
if(actualCPUUsage < cpuReactivationThreshold){
if(actualCPUUsage < cpuReactivationThreshold && !activeWorkers.hasNan()){
System.out.printf("Current CPU usage of Node is %.2f. Let's activate another Worker.\n",actualCPUUsage);
if(activeWorkers.reactivateWorker("time")){
rm.updateActiveWorkersEverywhere();
......@@ -65,6 +66,7 @@ public class ActivationWorkersManager implements Runnable {
}
}
}
}
}
......@@ -26,7 +26,6 @@ import java.util.concurrent.ConcurrentHashMap;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONException;
import es.bsc.compss.nfr.model.Worker;
......@@ -90,6 +89,28 @@ public class ActiveWorkersMap {
return null;
}
public JSONObject getViolationMessage(String dimension) {
int workerPid = getFirstActiveWorkerPid();
Worker w = getWorkerByPid(workerPid);
// FIXME: Find better way
String nodeIP = "localhost";
if(!w.getNode().getIpEth().equals("") || w.getNode().getIpEth() != null){
nodeIP = w.getNode().getIpEth();
} else if(!w.getNode().getIpLte().equals("") || w.getNode().getIpLte() != null){
nodeIP = w.getNode().getIpLte();
} else if(!w.getNode().getIpWifi().equals("") || w.getNode().getIpWifi() != null){
nodeIP = w.getNode().getIpWifi();
}
String appUuid = w.getApplication().getUuid();
JSONObject obj = new JSONObject();
obj.put("dimension",dimension);
obj.put("nodeIP",nodeIP);
obj.put("COMPSsAppUuid",appUuid);
return obj;
}
public void put(int workerPid, JSONObject metrics) {
try{
// Control the length of the history array (5 seconds = 5 metrics records)
......@@ -129,7 +150,7 @@ public class ActiveWorkersMap {
if (allWorkersSize() > 0) {
Map<Integer,Worker> inactiveWorkers = new HashMap<>();
for (Worker w : workerList) {
if(!w.isActive() && !(w.getDeactivationReasons().contains("security") || w.getDeactivationReasons().contains("communication"))){
if(!w.isActive() && (!(w.getDeactivationReasons().contains("security") || w.getDeactivationReasons().contains("communication")))){
inactiveWorkers.put(w.getPid(),w);
}
}
......@@ -158,8 +179,9 @@ public class ActiveWorkersMap {
// if(inactiveWorkers.get(workerPidToActivate).getDeactivationReason().contains(dimension) ||
// inactiveWorkers.get(workerPidToActivate).getDeactivationReason().contains("security")) {
inactiveWorkers.get(workerPidToActivate).setActive(true);
inactiveWorkers.get(workerPidToActivate).setComputingUnits(COMPUTING_UNITS);
inactiveWorkers.get(workerPidToActivate).setActive(true);
inactiveWorkers.get(workerPidToActivate).setComputingUnits(COMPUTING_UNITS);
inactiveWorkers.get(workerPidToActivate).setDeactivationReasons(new ArrayList<>());
//}
// int workerPidToActivate = inactiveWorkers.get(0).getPid();
......@@ -182,6 +204,7 @@ public class ActiveWorkersMap {
return false;
}
public int getMinCPUUsageWorkerPid() {
int minCPUUsageWorkerPid = getFirstActiveWorkerPid();
float minCPUUsage = getWorkerCPUUsage(minCPUUsageWorkerPid);
......@@ -195,10 +218,19 @@ public class ActiveWorkersMap {
return minCPUUsageWorkerPid;
}
public boolean hasNan(){
float sum = 0;
for (JSONObject metrics : activeWorkerMetrics.values()) {
// TODO Edit this when new metrics become relevant
if((metrics.isNull("task-clock") || !metrics.has("task-clock"))|| !((!metrics.isNull("pkg") || metrics.has("pkg"))||(!metrics.isNull("SOCpower") || metrics.has("SOCpower")))) return true;
}
return false;
}
public float getTotalCPUUsage() {
//waitingToUpdateEnergy();
float sum = 0;
for (JSONObject metrics : activeWorkerMetrics.values()) {
for (JSONObject metrics : activeWorkerMetrics.values()) {
sum += metrics.getFloat("task-clock");
}
return sum;
......@@ -348,5 +380,4 @@ public class ActiveWorkersMap {
public Map<Integer, JSONArray> getActiveWorkersHistory() {
return activeWorkersMetricsHistory;
}
}
......@@ -42,17 +42,12 @@ public class DataclayWritingManager implements Runnable {
public void run() {
while (!Thread.interrupted()) {
try {
Thread.sleep(monitoringPeriod);
} catch (InterruptedException e) {
System.out.println("Thread " + Thread.currentThread().getName() + " was interrupted. Aborting...");
break;
}
// Check for activated Workers
if (activeWorkers.size() == 0) {
activeWorkers.waitForWorkersActivation();
continue;
continue;
}
activeWorkers.isHistoryUpdated();
......@@ -66,35 +61,38 @@ public class DataclayWritingManager implements Runnable {
float sumPowerUsage = 0.0f;
int lengthHistory = metricsHistory.length();
for (int i = 0; i < metricsHistory.length(); i++) {
JSONObject metrics = metricsHistory.getJSONObject(i);
if (metrics.isEmpty() || (!metrics.has("task-clock")) || (!metrics.has("power"))) {
lengthHistory--;
continue;
if(lengthHistory > 0){
for (int i = 0; i < metricsHistory.length(); i++) {
JSONObject metrics = metricsHistory.getJSONObject(i);
if (metrics.isEmpty() || (!metrics.has("task-clock")) || (!metrics.has("power"))) {
lengthHistory--;
continue;
}
sumCpuUsage += metrics.getFloat("task-clock");
sumPowerUsage += metrics.getFloat("power");
}
sumCpuUsage += metrics.getFloat("task-clock");
sumPowerUsage += metrics.getFloat("power");
}
float meanCpuUsage = sumCpuUsage / lengthHistory;
float meanPowerUsage = sumPowerUsage / lengthHistory;
if(Float.isNaN(meanCpuUsage) || Float.isNaN(meanPowerUsage)) {
System.out.println("!!WARNING!! NaN values!");
continue;
}
for (Worker w : workerList) {
if (w.getPid() == workerPid) {
w.setCpuUsage(meanCpuUsage);
w.setEnergyUsage(meanPowerUsage);
System.out.printf(
"[dataClay]\tWorker %d writes on dataClay its average CPU and Energy usage\t|%.2f| |%.2f|\n",
w.getPid(), w.getCpuUsage(), w.getEnergyUsage());
break;
if(lengthHistory > 0){
float meanCpuUsage = sumCpuUsage / lengthHistory;
float meanPowerUsage = sumPowerUsage / lengthHistory;
for (Worker w : workerList) {
if (w.getPid() == workerPid) {
w.setCpuUsage(meanCpuUsage);
w.setEnergyUsage(meanPowerUsage);
System.out.printf("[dataClay]\tWorker %d writes on dataClay its average CPU and Energy usage\t|%.2f| |%.2f|\n", w.getPid(), w.getCpuUsage(), w.getEnergyUsage());
break;
}
}
}
}
}
try {
Thread.sleep(monitoringPeriod);
} catch (InterruptedException e) {
System.out.println("Thread " + Thread.currentThread().getName() + " was interrupted. Aborting...");
break;