Skip to content

Commit

Permalink
drill unit_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bbodin committed Mar 7, 2024
1 parent 6409698 commit 4100014
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 111 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ benchmark : sdf.log csdf.log csdf_sized.log

ubuntu_test:
@echo "###########"" ENTER IN $@ : $^ #####################"
docker build -f tools/docker/DockerFile.u18 -t bbodin/kiter-u18 ./
docker build -f tools/docker/DockerFile.ubuntu -t bbodin/kiter-ubuntu ./

test: ./Release/bin/kiter
@echo "###########"" ENTER IN $@ : $^ #####################"
Expand Down
2 changes: 1 addition & 1 deletion src/libkiter/algorithms/mapping/moduloMapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <algorithms/mappings.h>

void algorithms::mapping::moduloMapping (models::Dataflow* const dataflow, parameters_list_t params) {

dataflow->reset_computation();
VERBOSE_INFO("moduloMapping");
for (auto t : dataflow->vertices()) {
if (params.find(dataflow->getVertexName(t)) != params.end()) {
Expand Down
2 changes: 1 addition & 1 deletion src/libkiter/algorithms/mapping/randomMapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void algorithms::mapping::randomMapping (models::Dataflow* const dataflow, para
VERBOSE_INFO("randomMapping");

VERBOSE_ASSERT(dataflow->getNoC().size() > 0, "The dataflow must have a NoC associated to it to be mapped.");

dataflow->reset_computation();
for (auto t : dataflow->vertices()) {
if (params.find(dataflow->getVertexName(t)) != params.end()) {
dataflow->setMapping(t, commons::fromString<node_id_t> (params[dataflow->getVertexName(t)]));
Expand Down
7 changes: 7 additions & 0 deletions src/libkiter/algorithms/symbolic_execution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ void algorithms::symbolic_execution_with_packets (models::Dataflow* const graph,

while (total > 0) {

bool no_execution = true;

for (Vertex t : graph->vertices()) {

ARRAY_INDEX vId = graph->getVertexId(t);
Expand Down Expand Up @@ -187,6 +189,11 @@ void algorithms::symbolic_execution_with_packets (models::Dataflow* const graph,

}

if (no_execution) {
VERBOSE_ERROR("Should never happen");
break;
}

}

VERBOSE_INFO("End of symbolic execution.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <models/Dataflow.h>

void algorithms::transformation::remove_reentrancy (models::Dataflow* const dataflow, parameters_list_t params) {

dataflow->reset_computation();
if (params.find("taskname") != params.end()) {
auto names = commons::split<std::string>(params["taskname"], ',');
for (auto name : names) {
Expand Down
1 change: 1 addition & 0 deletions tests/DsePeriodicTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ BOOST_AUTO_TEST_CASE( random_speriodic_test )
VERBOSE_INFO("generate graph " << i << " with " << buf_num);

models::Dataflow *g = generate_random_graph(i, buf_num, MAX_PHASE_COUNT, 2, 1);
g->reset_computation();
graphs.push_back(g);
}

Expand Down
31 changes: 0 additions & 31 deletions tests/MappingTest.cpp

This file was deleted.

82 changes: 38 additions & 44 deletions tests/SchedulingsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "algorithms/schedulings.h"
#include <models/Dataflow.h>
#include <commons/KiterRegistry.h>
#include "algorithms/mappings.h"
#include "printers/printers.h"

BOOST_FIXTURE_TEST_SUITE( schedulings_test, WITH_SAMPLE)

Expand All @@ -17,64 +19,45 @@ BOOST_FIXTURE_TEST_SUITE( schedulings_test, WITH_SAMPLE)

#define MAX_PHASE_COUNT 1

void randomTest(std::function<void(models::Dataflow*, parameters_list_t)> fun) {
parameters_list_t params = parameters_list_t();
std::vector<models::Dataflow *> gen_dataset () {
std::vector<models::Dataflow *> graphs;


VERBOSE_INFO("Generating Graphs");
for (int i = 10; i <= 300; i += 50) {
for (int i = 3; i <= 10; i += 1) {

int buf_num = std::rand() % (i / 2) + i;

VERBOSE_INFO("generate graph " << i << " with " << buf_num);

models::Dataflow *g = generate_random_graph(i, buf_num, MAX_PHASE_COUNT, 2, 1);
VERBOSE_ASSERT(computeRepetitionVector(g), "Inconsistent");
graphs.push_back(g);
}
return graphs;
}

void randomTest(std::function<void(models::Dataflow*, parameters_list_t)> fun) {
parameters_list_t params = parameters_list_t();
auto graphs = gen_dataset();
for(auto graph : graphs) {

fun(graph, params);
}
}

void randomTest(std::function<void(models::Dataflow*)> fun) {
std::vector<models::Dataflow *> graphs;

VERBOSE_INFO("Generating Graphs");
for (int i = 10; i <= 300; i += 50) {

int buf_num = std::rand() % (i / 2) + i;

VERBOSE_INFO("generate graph " << i << " with " << buf_num);

models::Dataflow *g = generate_random_graph(i, buf_num, MAX_PHASE_COUNT, 2, 1);
graphs.push_back(g);
}
auto graphs = gen_dataset();

for(auto graph : graphs) {

fun(graph);
}
}

BOOST_AUTO_TEST_CASE(KPeriodic_taskNoCbufferless, * boost::unit_test::disabled()){
BOOST_REQUIRE(pipeline_sample);
//TODO: function unimplemented
BOOST_TEST(false);
// VERBOSE_INFO("Sample test");
// sampleTest(algorithms::scheduling::KPeriodic_taskNoCbufferless, pipeline_sample);
// VERBOSE_INFO("Random test");
// randomTest(algorithms::scheduling::KPeriodic_taskNoCbufferless);
}


BOOST_AUTO_TEST_CASE( BufferlessNoCScheduling) {
BOOST_REQUIRE(pipeline_sample);
VERBOSE_INFO("Sample test");
sampleTest(algorithms::BufferlessNoCScheduling, pipeline_sample);
VERBOSE_INFO("Random test");
randomTest(algorithms::BufferlessNoCScheduling);
}

BOOST_AUTO_TEST_CASE( OnePeriodicScheduling_LP) {
BOOST_REQUIRE(pipeline_sample);
VERBOSE_INFO("Sample test");
Expand Down Expand Up @@ -158,15 +141,7 @@ BOOST_FIXTURE_TEST_SUITE( schedulings_test, WITH_SAMPLE)
}


BOOST_AUTO_TEST_CASE(So4Scheduling, * boost::unit_test::disabled()) {
BOOST_REQUIRE(pipeline_sample);
parameters_list_t params = parameters_list_t();

VERBOSE_INFO("Sample test");
//TODO: not sure why this segfaults
BOOST_TEST(false);
// algorithms::scheduling::So4Scheduling(pipeline_sample, params);
}

BOOST_AUTO_TEST_CASE(CSDF_KPeriodicScheduling) {
BOOST_REQUIRE(pipeline_sample);
Expand All @@ -182,6 +157,7 @@ BOOST_FIXTURE_TEST_SUITE( schedulings_test, WITH_SAMPLE)

BOOST_AUTO_TEST_CASE(generateKPeriodicVector) {
BOOST_REQUIRE(pipeline_sample);
computeRepetitionVector(pipeline_sample);
algorithms::scheduling::generateKPeriodicVector(pipeline_sample, 1);
}

Expand All @@ -197,9 +173,9 @@ BOOST_FIXTURE_TEST_SUITE( schedulings_test, WITH_SAMPLE)
Vertex b = pipeline_sample->getVertexById(2);
Vertex c = pipeline_sample->getVertexById(3);
periodicity_vector_t kvector;
kvector[a] = 0;
kvector[b] = 0;
kvector[c] = 0;
kvector[a] = 1;
kvector[b] = 1;
kvector[c] = 1;
algorithms::scheduling::bufferless_scheduling(pipeline_sample, kvector);
}

Expand All @@ -223,14 +199,32 @@ BOOST_FIXTURE_TEST_SUITE( schedulings_test, WITH_SAMPLE)

BOOST_AUTO_TEST_CASE(ModelASAPScheduling, * boost::unit_test::disabled()) {
BOOST_REQUIRE(pipeline_sample);
//TOOD unimplemented
//TODO: unimplemented
// algorithms::scheduling::ASAPScheduling(pipeline_sample);
}

BOOST_AUTO_TEST_CASE(ModelSo4Scheduling, * boost::unit_test::disabled()) {
BOOST_REQUIRE(pipeline_sample);
//TOOD unimplemented
//TODO: unimplemented
// algorithms::scheduling::So4Scheduling(pipeline_sample);
}


BOOST_AUTO_TEST_CASE( BufferlessNoCScheduling) {
BOOST_REQUIRE(pipeline_sample);
VERBOSE_INFO("Sample test");
//TODO: function unimplemented
// sampleTest(algorithms::BufferlessNoCScheduling, pipeline_sample);
}

BOOST_AUTO_TEST_CASE(KPeriodic_taskNoCbufferless, * boost::unit_test::disabled()){
BOOST_REQUIRE(pipeline_sample);
//TODO: function unimplemented

// VERBOSE_INFO("Sample test");
// sampleTest(algorithms::scheduling::KPeriodic_taskNoCbufferless, pipeline_sample);
// VERBOSE_INFO("Random test");
// randomTest(algorithms::scheduling::KPeriodic_taskNoCbufferless);
}

BOOST_AUTO_TEST_SUITE_END()
4 changes: 1 addition & 3 deletions tests/SymbolicExTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ BOOST_FIXTURE_TEST_SUITE(symbolic_ex_test, WITH_SAMPLE)
{
parameters_list_t params;
BOOST_REQUIRE(pipeline_sample);
BOOST_TEST(false);
//TODO: infinite loop
//algorithms::symbolic_execution_with_packets(pipeline_sample, params);
algorithms::symbolic_execution_with_packets(pipeline_sample, params); // TODO: Bug found here.
}

BOOST_AUTO_TEST_CASE(sample_symbolic_execution_test)
Expand Down
5 changes: 4 additions & 1 deletion tests/helpers/test_classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ class WITH_SAMPLE {
pipeline_sample->setNoC(noc);
cycle_sample->setNoC(noc);
mult_scc_sample->setNoC(noc);

// // TODO: This should have been a good idea, but the reset_computation, computeRepetitionVector ...
// computeRepetitionVector(pipeline_sample);
// computeRepetitionVector(cycle_sample);
// computeRepetitionVector(mult_scc_sample);
BOOST_TEST_MESSAGE( "WITH_SAMPLE Setup Done" );
}
~WITH_SAMPLE () {
Expand Down
14 changes: 0 additions & 14 deletions tools/docker/DockerFile.u16

This file was deleted.

14 changes: 0 additions & 14 deletions tools/docker/DockerFile.u18

This file was deleted.

15 changes: 15 additions & 0 deletions tools/docker/DockerFile.ubuntu
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM ubuntu:noble



################################### PACKAGE INSTALL ##########################
RUN apt-get update && apt-get install --no-install-recommends -y git make cmake gcc g++ libboost-all-dev libxml2-dev libglpk-dev glpk-utils && apt-get clean && rm -rf /var/lib/apt/lists/*
################################################################################

RUN mkdir /kiter/
COPY . /kiter/
WORKDIR /kiter/
RUN make clean
RUN make release
RUN make unit_test

0 comments on commit 4100014

Please sign in to comment.