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

69 19 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 hành chung II Thực hành nhóm IIINhận xét IV Phân chia nhiệm vụ Bảảnng kếết quuả 1.1 1.2 1.3 Mã ngguuồồn 2.1 2.2 2.3 Bảảnng kếết quuả 1.1 1.2 Mã ngguuồồn 2.1 2.2 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) I Th ực hàn h chu ng Bảảnng kếết quuả 1.1 Ma trận nhân vecectotor 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: Sử dụng luồng để thực tính tốn song song ta thu bảng sau: 1.2 Tính tốn số Fibonacci Sử dụng luồng để thực tính tốn song song ta thu bảng sau: double* pResult; / Resulult vector for vector-vector multiplication int Sizeze, p; // Sizes of initial matrix and vector double Start, Finish, Serial_Duration, Parallel_Duration, Parallel_Duration1; double Efficiency; printf("Serial matrix-vector program\n"); multiplication ProcessInitialization(pVector1, Start = GetTime(); SerialResultCalculation(pVector1, pVector2, pResult, Size); Finish = GetTime(); Serial_Duration = Finish-Start; printf("Serial result: %f \n", pVector2, Size); *pResult); Matrixvector multiplication parallel #pragma omp parallel num_threads(4) p = omp_get_num_threads(); Start = GetTime(); ParallelResultCalculation(pVector1, pVector2, pResult, Size); Finish = GetTime(); / Parallel_Duration printf("Parallel = Finish-Start; result: %f", *pResult); 27 pResult, / TestResult(pVector1, pVector2, pResult, Size); Printing the time spent by matrix-vector multiplication Efficiency = Serial_Duration / (Parallel_Duration * p); printf("\n Time of execution serial :%f\n", Serial_Duration); printf("\n Time of execution parallel :%f\n", Parallel_Duration); printf("\n\nEfficiency of execution: %f%\n", Efficiency * 100); / printf("\n Time of execution parallel1 :%f\n", Parallel_Duration1); / Computational process termination ProcessTermination(pVector1, pVector2, return 0; } / pResult); 28 2.2 Mã nguồn hệ điều hành Linux #include #include #include #include #include #include using namespace std; void DummyDataInitialization(double* pVector1, double* pVector2, int Size) { int i , j ; for (i=0; i

Ngày đăng: 05/12/2022, 06:22

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

  • Đang cập nhật ...

Tài liệu liên quan