Exemple #1
0
	void cScreenShot::getCurrentCount()
	{
		TCHAR fileDir[MAX_PATH];
		_stprintf(fileDir, _T("%s\\*%s"), cScreenShot::directoryName.c_str(), cScreenShot::getExpName());

		m_count = 0;
		WIN32_FIND_DATA fd;
		HANDLE hff = FindFirstFile(fileDir, &fd);
		if (hff != INVALID_HANDLE_VALUE)
		{
			bool is = true;
			while (is)
			{
				if (fd.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY)
				{
					int count = calculCount(fd.cFileName);
					if (count > m_count)
						m_count = count;
				}

				if (FindNextFile(hff, &fd) == FALSE)
					break;
			}
		}

		m_count += 1;

		if (hff != INVALID_HANDLE_VALUE)
			FindClose(hff);
	}
Exemple #2
0
int main (int argc, char**argv)
{
	int i, j, k, l, count;
	int * A, * B, * C, * A1, * B1, *C1, * tmpB;
	int dest, src;

	// Initialisation du monde
	initialiseMonde(argc, argv);

	square_block = taille_block * taille_block;

	//Allocations des matrices
	A  = (int*) malloc(sizeof(int) * (square_block));
	B  = (int*) malloc(sizeof(int) * (square_block));
	C  = (int*) malloc(sizeof(int) * (square_block));
	A1 = (int*) malloc(sizeof(int) * (square_block));
	B1 = (int*) malloc(sizeof(int) * (square_block));
	C1 = (int*) malloc(sizeof(int) * (square_block));

	if(rank == 0)
	{
		/*Debut du timer*/
		if (getTimeDebut())
		{
			MPI_Finalize();
			exit(1);
		}
	}

	//Initialisation de la matrice de résultat
	for (i = 0; i < square_block; i++)
	{
		C[i] = 0;
	}

	//Génération des matrices
	count = calculCount(coords, taille_block, sqrt(size));
	#pragma omp for schedule(dynamic,2)
		for (k = 0; k < taille_block; ++k)
		{
			for (l = 0; l < taille_block; ++l)
			{
				A[(k * taille_block) + l]  = count++;
				B[(k * taille_block) + l]  = count++;
			}
			count += 2 * (taille_matrice - taille_block);
		}

	for (i = 0; i < racine; i++)
	{
		if ((coords[0] + i) % racine == rankRow)
		{
			MPI_Bcast(A, square_block, MPI_INT, (coords[0] + i) % racine, COMM_ROWS);
			multiplication_mat(A, B, C1, taille_block);
		}
		else
		{
			MPI_Bcast(A1, square_block, MPI_INT, (coords[0] + i) % racine, COMM_ROWS);
			multiplication_mat(A1, B, C1, taille_block);
			//Reception
		}
		additionMatrice(C, C1, square_block);

		if(rankCol == 0)
			dest = racine - 1;
		else
			dest = rankCol - 1;

		src = (rankCol + 1) % racine;

		if(rankCol % 2 == 0)
		{
			MPI_Send(B,  square_block, MPI_INT, dest, 0, COMM_COLS);
			MPI_Recv(B1, square_block, MPI_INT, src,  0, COMM_COLS, MPI_STATUS_IGNORE);
		}
		else
		{
			MPI_Recv(B1, square_block, MPI_INT, src,  0, COMM_COLS, MPI_STATUS_IGNORE);
			MPI_Send(B,  square_block, MPI_INT, dest, 0, COMM_COLS);
		}

		// Copie de B1 dans B
		tmpB = B;
		B = B1;
		B1 = tmpB;
	}

	MPI_Barrier(MPI_COMM_WORLD);
	if(rank == 0)
	{
		/*Debut du timer*/
		if (getTimeFin())
		{
			MPI_Finalize();
			exit(1);
		}

		printTimeRes();
	}

	// for(i = 0; i < size; i++)
	// {
	// 	MPI_Barrier(COMM_CART);
	// 	if (i == rank)
	// 	{
	// 		affiche_mat(C, taille_block);
	// 	}
	// }

	free(A);
	free(B);
	free(C);
	free(A1);
	free(B1);
	free(C1);
	MPI_Finalize();

	return 0;
}