Exemplo n.º 1
0
static void* __thread_worker(void *thread_input) {

    int my_tid = ((thread_struct*)thread_input)->tid;
    //connect
    functionStruct* localFunction = ((thread_struct*)thread_input)->function;
    void *thread_prepare_out = localFunction->prepare(thread_input,localFunction->prepare_in);   
    printf("this tid = %d\n",my_tid); 

    benchmarkConfig *bc = ((thread_struct*)thread_input)->bc;
    //use the benchmark; 
    benchmarkInfo *benchmark = initBenchmark(bc->totalCount);
    benchmark = loadData(benchmark);
    kvPair *tempPair;
    char *key,*value;
    long long total_start = s_time();

    int i;
    for(i=0;i<bc->totalCount;i++) {
        tempPair = getKvPair(benchmark);
        long long start = us_time();
        localFunction->operation_out = localFunction->operation((void*)tempPair,thread_input,thread_prepare_out);
        long long end = us_time();
        addDuration(benchmark,end-start);
    }

    long long total_end = s_time();
    localFunction->end_out = localFunction->end(thread_input,thread_prepare_out);
    char temp[11] = "pip";
    sprintf(temp+3,"%d",my_tid);
    //after benchmark
    setFileName(benchmark,temp);
    flushResults(benchmark);
    
    return (void*)0;
}
Exemplo n.º 2
0
void software_3x3_filter(const char *input)
{
    filter_params filter;
    Image iImage = IMAGE_INITIALIZER;
    Image oImage = IMAGE_INITIALIZER;
    Benchmark b;
    int val = 0;

    initBenchmark(&b, "Software 3x3 Filter", "");

    filter_Init(&filter, 4, 2, 1, 4);
    ImageRead(input, &iImage);

    startBenchmark(&b);
    val = filter_Execute(&filter, &iImage, &oImage);
    stopBenchmark(&b);

    if(val != 0) {
        fprintf(stderr, "software_3x3_filter: ERROR: Filter failed.\n");
    }

    printBenchmark(&b);
    ImageWrite("software_3x3.tif",&oImage);
    ImageCleanup(&oImage);
    ImageCleanup(&iImage);
}
Exemplo n.º 3
0
void software_hardware_exhaustive(const char *input)
{
#ifdef ZYNQ
    const int nRuns = 500;
    int i = 0;
    hardware_config hard_config;
    filter_params filter;
    Image iImage = IMAGE_INITIALIZER;
    Image oImage = IMAGE_INITIALIZER;
    int val = 0;
    volatile int j = 0;
    Benchmark b_software;
    Benchmark b_hardware;

    initBenchmark(&b_software, "Software 3x3 filter", "");
    initBenchmark(&b_hardware, "Hardware 3x3 filter", "");

    ImageRead(input, &iImage);

    filter_Init(&filter, 4, 2, 1, 4);

    val = hardware_filter_init(&iImage, &hard_config);
    fprintf(stdout, "Running hardware %d times\n", nRuns);
    startBenchmark(&b_hardware);
    for(i = 0; i < nRuns; i++) {
        val = hardware_filter_execute(&hard_config);
    }
    stopBenchmark(&b_hardware);
    val = hardware_filter_cleanup(&iImage, &oImage, &hard_config);
    fprintf(stdout, "Hardware runs complete\n");
    fprintf(stdout, "Runnning software %d times\n", nRuns);
    for(i = 0; i < nRuns; i++) {
        val = filter_Execute(&filter, &iImage, &oImage);
    }
    stopBenchmark(&b_software);
    fprintf(stdout, "Software runs complete\n");

    printBenchmarkAvg(&b_hardware,nRuns);
    printBenchmarkAvg(&b_software,nRuns);

#else
    fprintf(stderr, "Hardware exhaustive run not supported on x86 platform\n");
#endif


}
int run(const std::string& flags)
{
	Date startDate;
	Config conf;
	try
	{
		std::vector<ParsedOption> parsedFlags = getConfig(conf, flags);

		Log::init(conf.verbosity, conf.silent, conf.verboseNumberPrecision);

		Log() << "=======================================================\n";
		Log() << "  Infomap v" << INFOMAP_VERSION << " starts at " << Date() << "\n";
		Log() << "  -> Input network: " << conf.networkFile << "\n";
		Log() << "  -> Output path:   " << conf.outDirectory << "\n";
		if (!parsedFlags.empty()) {
			for (unsigned int i = 0; i < parsedFlags.size(); ++i)
				Log() << (i == 0 ? "  -> Configuration: " : "                    ") << parsedFlags[i] << "\n";
		}
		Log() << "  -> Use " << (conf.isUndirected()? "undirected" : "directed") << " flow and " <<
			(conf.isMemoryNetwork()? "2nd" : "1st") << " order Markov dynamics";
		if (conf.useTeleportation())
			Log() << " with " << (conf.recordedTeleportation ? "recorded" : "unrecorded") << " teleportation to " <<
			(conf.teleportToNodes ? "nodes" : "links");
		Log() << "\n";
		Log() << "=======================================================\n";

		if (conf.benchmark)
			initBenchmark(conf, flags);

		conf.adaptDefaults();

		runInfomap(conf);

	}
	catch (std::exception& e)
	{
		std::cerr << e.what() << std::endl;
		return EXIT_FAILURE;
	}

	ASSERT(NodeBase::nodeCount() == 0); //TODO: Not working with OpenMP
//	if (NodeBase::nodeCount() != 0)
//		Log() << "Warning: " << NodeBase::nodeCount() << " nodes not deleted!\n";


	Log() << "===================================================\n";
	Log() << "  Infomap ends at " << Date() << "\n";
	Log() << "  (Elapsed time: " << (Date() - startDate) << ")\n";
	Log() << "===================================================\n";

	return 0;
}
Exemplo n.º 5
0
int run(int argc, char* argv[])
{
	Date startDate;
	Config conf;
	try
	{
		conf = getConfig(argc, argv);
		if (conf.benchmark)
			initBenchmark(conf, argc, argv);
		if (conf.verbosity == 0)
			conf.verboseNumberPrecision = 4;
		std::cout << std::setprecision(conf.verboseNumberPrecision);
	}
	catch (std::exception& e)
	{
		std::cerr << e.what() << std::endl;
		return 1;
	}

	std::cout << "===========================================\n";
	std::cout << "  Infomap v" << INFOMAP_VERSION << " starts at " << Date() << "\n";
	std::cout << "===========================================\n";

	runInfomap(conf);

	ASSERT(NodeBase::nodeCount() == 0); //TODO: Not working with OpenMP
//	if (NodeBase::nodeCount() != 0)
//		std::cout << "Warning: " << NodeBase::nodeCount() << " nodes not deleted!\n";


	std::cout << "===========================================\n";
	std::cout << "  Infomap ends at " << Date() << "\n";
	std::cout << "  (Elapsed time: " << (Date() - startDate) << ")\n";
	std::cout << "===========================================\n";

//	ElapsedTime t1 = (Date() - startDate);
//	std::cout << "Elapsed time: " << t1 << " (" <<
//			Stopwatch::getElapsedTimeSinceProgramStartInSec() << "s serial)." << std::endl;
	return 0;
}
Exemplo n.º 6
0
void hardware_3x3_filter(const char *input)
{
#ifdef ZYNQ
    Image iImage = IMAGE_INITIALIZER;
    Image oImage = IMAGE_INITIALIZER;
    hardware_config hard_config;
    Benchmark b;
    int val = 0;

    initBenchmark(&b, "Hardware 3x3 Filter", "");
    ImageRead(input, &iImage);
    if(hardware_filter_init(&iImage, &hard_config) != 0) {
        fprintf(stderr, "hardware_3x3_filter: ERROR: Failed to initialize hardware driver\n");
        return;
    }

    startBenchmark(&b);
    val = hardware_filter_execute(&hard_config);
    stopBenchmark(&b);
    if(val != 0) {
        fprintf(stderr, "hardware_3x3_filter: ERROR: Filter failed.\n");
    }

    val = hardware_filter_cleanup(&iImage, &oImage, &hard_config);
    if(val != 0) {
        fprintf(stderr, "hardware_3x3_filter: ERROR: Hardware filter failed to clean up.\n");
    }

    printBenchmark(&b);
    ImageWrite("hardware_3x3.tif",&oImage);
    ImageCleanup(&oImage);
    ImageCleanup(&iImage);
#else
    fprintf(stderr, "Hardware 3x3 filter not supported on x86 platform\n");
#endif

}