示例#1
0
void
likwid_markerstopregion_(char* regionTag, int* len)
{
    char* tmp = (char*) malloc(((*len)+1) * sizeof(char));
    strncpy(tmp, regionTag, (*len));
    tmp[(*len)] = 0;
    likwid_markerStopRegion( tmp );
	free(tmp);
}
示例#2
0
likwid_markerstopregion_(char* regionTag, int len)
{
    char* tmp = (char*) malloc((len+1) * sizeof(char));
    strncpy(tmp, regionTag, len * sizeof(char) );

    for (int i=(len-1); len > 0; len--)
    {
        if (tmp[i] != ' ') {
            tmp[i+1] = 0;
            break;
        }
    }

    likwid_markerStopRegion( tmp );
    free(tmp);
}
示例#3
0
int main(int argc, char **argv) {
	///******************************************************
	///********************** INPUT *************************
	///******************************************************
	if (argc != 4) {
		std::cout << "Invalid number of arguments!" << std::endl;
		std::cout << "./compare A.out B.out" << std::endl;
		exit(EXIT_FAILURE);
	}

	//matrix dimensions
	int dimM = 0;
	int dimN = 0;
	int dimO = 0;

	//get dimensions
	std::ifstream	fIn(argv[1]);
	if (!fIn) {
		std::cout << "Error opening file: " << argv[1] << std::endl;
		exit(EXIT_FAILURE);
	}

	if(!(fIn >> dimM >> dimN))
	{
		std::cout << "Error in reading matrix entries!" << std::endl;
		exit(EXIT_FAILURE);
	}
	fIn.close();

	fIn.open(argv[2]);
	if (!fIn) {
		std::cout << "Error opening file: " << argv[2] << std::endl;
		exit(EXIT_FAILURE);
	}

	if(!(fIn >> dimN >> dimO))
	{
		std::cout << "Error in reading matrix entries!" << std::endl;
		exit(EXIT_FAILURE);
	}

	fIn.close();

	//calculate minimal matrix size
	//all matrices are padded with 0s to this size
	//should be power of 2 for efficient block division
	//dirty hack...
	LD = 64;
	if (LD<dimM) LD = dimM;
	if (LD<dimN) LD = dimN;
	if (LD<dimO) LD = dimO;

	LD--;
	LD |= LD >> 1;
	LD |= LD >> 2;
	LD |= LD >> 4;
	LD |= LD >> 8;
	LD |= LD >> 16;
	LD++;

	//add useless padding
	LD += PADDING;

	double* a = (double*) aligned_alloc(ALIGNMENT, sizeof(double) * LD * LD);
	double* b = (double*) aligned_alloc(ALIGNMENT, sizeof(double) * LD * LD);
	double* c = (double*) aligned_alloc(ALIGNMENT, sizeof(double) * LD * LD);

	Matrix	A = loadMatrix(argv[1], &a[0]);
	Matrix	B = loadMatrix(argv[2], &b[0]);
	Matrix	C(&c[0], nullptr, A.getDimM(), B.getDimN(), 0, 0);

	///******************************************************
	///********************** CALCULATION *******************
	///******************************************************
	double time = 0;
	
#ifdef USE_LIKWID
	likwid_markerInit();
	likwid_markerStartRegion("dummy");
#endif

	siwir::Timer	timer;

	MMM(A, B, C);

	time = timer.elapsed();
	std::cout << dimM << "\t" << dimN << "\t" << dimO << "\t" << time << std::endl;

#ifdef USE_LIKWID
	likwid_markerStopRegion("dummy");
	likwid_markerClose();
#endif

	///******************************************************
	///********************** OUTPUT ************************
	///******************************************************

	saveMatrix(argv[3], C);

	free(a);
	free(b);
	free(c);
};