BÁO cáo GIỮA kỳ lập trình OpenMP ma trận nhân vector

33 3 0
BÁO cáo GIỮA kỳ lập trình OpenMP ma trận nhân vector

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

  Parallel Computing BÁO CÁO GIỮA KỲ Lập trình OpenMP Giảng viên hướng dẫn: Thầy Đồn Duy Trung Phạm Đình Thơng - 20195923 Lớp Tốn Tin - K64 - học kì 20221   Mục lục I Thực Thực hà hành nh chun ung g Bảng kết   1.1 1.1 Ma trậ rậnn nh nhân ân vec ecto torr   1.22 Tính Tính to tốn án số Fi Fibon bonac acci ci   1.3 1.3 Ma trậ rậnn nh nhân ân ma trậ rậnn   Mã nguồn   2.1 2.1 Ma trậ rậnn nh nhân ân vec ecto torr   2.22 Tính Tính to tốn án số Fi Fibon bonac acci ci   2.3 2.3 Ma trậ rậnn nh nhân ân ma trậ rậnn     13 17 II Thực Thực hành hành nhóm nhóm   Bảng kết   1.1 1.1 Tí Tích ch vô hướ hướng ng hai vect vector or trên Wi Windo ndows ws   1.2 1.2 Tí Tích ch vô hướ hướng ng vect vector or trên Li Linnux   Mã nguồn   2.1 2.1 Mã ngu nguồn ồn trên hệ điều ều hà hành nh Windo Windows ws   2.22 Mã nguồ nguồnn tr ên hệ điều điều hà hành nh Li Linnux ux   IIINhận xét   IV Phâ Phân n ch chia ia nhiệ nhiệm m vụ 32   22 22 22 23 24 24 29 33   Lời mở đầu Mơ hình xử lý song song phát triển mạnh mẽ, giải vấn đề bế tắc mà mơ hình xử lý gặp phải như: vấn đề thời gian thực chương trình, tốc độ xử lý, khả lưu trữ nhớ Dưới báo cáo thực hành OpenMP, bao gồm chương trình: • thực hành cá nhân(Gồm code, bảng kết quả) thực hành nhóm(Gồm code, bảng kết nhận xét) • BAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vector     I    Thự Th ực hà hàn nh ch chun ung g Bảng kết 1.1 1.1 Ma tr trận ận nhân nhân vecto ectorr Sử dụng luồng để thực tính tốn song song ta thu bảng sau: BAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vector BAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vector   Sử dụng luồng để thực tính tốn song song ta thu bảng sau: BAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vector BAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vector   Sử dụng luồng để thực tính tốn song song ta thu bảng sau: 1.2 1.2 Tí Tính nh to tốn án số Fi Fibon bonac acci ci Sử dụng luồng để thực tính tốn song song ta thu bảng sau: BAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vector BAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vector   Sử dụng luồng để thực tính tốn song song ta thu bảng sau: Sử dụng luồng để thực tính toán song song ta thu bảng sau: BAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vector BAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vector   1.3 Ma trận trận nhân nhân ma tr trận ận Sử dụng luồng để thực tính tốn song song ta thu bảng sau: Sử dụng luồng để thực tính tốn song song ta thu bảng sau: BAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vector BAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vector   Sử dụng luồng để thực tính tốn song song ta thu bảng sau: Mã nguồn 2.1 2.1 Ma tr trận ận nhân nhân vecto ectorr #include #include #include #include #include #include using namespac using namespace e std; double LiToDouble(LARGE_IN LiToDouble(LARGE_INTEGER TEGER x) { double dou ble result result = ((double)x.HighPart) ((double)x HighPart) * 4.294967296E9 4.294967296E9 + (double)((x).LowPar (double)((x).LowPart); t); return   result; } double GetTime() { LARGE_INTEGER LARGE_INTE GER lpFrequency, lpFrequency, lpPerfomanceCount; lpPerfomanceCount; QueryPerformanceFrequency(&lpFrequency); QueryPerformanceCounter(&lpPerfomanceCount); return   LiToDouble(lpPerfoman LiToDouble(lpPerfomanceCount) ceCount) / LiToDouble(lpFreque LiToDouble(lpFrequency); ncy); } BAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vector BAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vectorBAO.cao.GIUA.ky.lap.trinh.OpenMP.ma.tran.nhan.vector   // function function   for   simple simple definiti definition on of matrix matrix   and   vector elements void DummyDataInitializa DummyDataInitialization(doubl tion(double* e* pMatrix, double* pVector,   int   Size){ int   i, j; for   (i = 0; i < Size; i++){ pVect pVe ctor[ or[i] i] = 1; for   (j = 0; j < Size; j++) pMatrix[i * Size + j] = i; } } void RandomDataInitializ RandomDataInitialization(doub ation(double le *pMatrix, double *pVector,   int   Size) { Loop op va vari riab able les s int   i, j; // Lo srand(time(NULL)); for   (i = 0; i < Size; i++) { pVector[ pVec tor[i] i] = rand() rand() / (double) (double)(100 (1000); 0); for   (j = 0; j < Size; j++) pMatr pMatrix ix[i [i * Size Size + j] = rand() rand() / (doub (double le)(1 )(1000 000); ); } } void ProcessInitializati ProcessInitialization(double on(double *&pMatrix, double *&pVector,   int   &Size) { // Size Size of initi initial al matri matrix x   and   vector definition definition { "\nCho Chose sen n obj object ects s siz size e = "); printf("\n printf( // scanf( scanf("%d" "%d", , &Siz &Size); e); ci cin n >> Si Size ze; ; if   (Siz (Size e

Ngày đăng: 24/12/2023, 14:08

Tài liệu cùng người dùng

Tài liệu liên quan