[关闭]
@laofang 2016-06-05T13:58:32.000000Z 字数 6645 阅读 2754

系统结构复习

复习


考试题型

题型 分值
选择 10
判断 15
简答 25
应用 25
OpenMP 15
论述 10(SIMD)

第一章 计算机系统结构导论

Created with Raphaël 2.1.2系统分析应用程序系统高级语言计算机汇编语言计算机操作系统机器语言计算机微程序控制硬联逻辑

附: 计算机系统功能模型(洋葱模型)
洋葱模型

第二章 计算机系统结构的合成

Created with Raphaël 2.1.2CPU[M1]通用寄存器[M2]高速缓冲存储器cache[M3]主存(大容量半导体存储器)[...]辅存(磁盘,光盘存储器)[Mn]大容量(海量)存储器(磁带存储器)

: 的每位价格
: 的访问时间
: 的存储容量,
存在如下关系:


每位价格:
访问时间:
存储容量:

第三章 存储系统结构

第四章 流水线结构

第五章 并行处理机

准则 SIMD MIMD
通信工作方式 同步 异步
控制策略 集中控制 集中控制+分散控制
交换方式 线路交换 分组交换
网络拓扑 分为静态动态两种,具体分别用什么没有讲

第六章 多处理机系统

  1. #include <omp.h>
  2. #include <stdio.h>
  3. int main()
  4. {
  5. int nthreads;
  6. int tid;
  7. omp_set_num_threads(8); //设置线程数
  8. //编译制导语句, 按多线程执行, 每个线程有自己的nthreads 和 tid
  9. #pragma omp prarallel private(nthreads,tid)
  10. {
  11. tid = omp_get_thread_num();//当前线程的tid
  12. printf("Hello World from Thread %d \n", tid);
  13. if(tid == 0)
  14. {
  15. nthreads = omp_get_num_threads();//总线程数
  16. printf("Number of threads is %d \n", nthreads);
  17. }
  18. }
  19. }
  1. #include <stdio.h>
  2. #include <omp.h>
  3. #include <time.h>
  4. //两个矩阵相乘的传统方法
  5. void comput(float *A, float *B, float *C){
  6. int x, y;
  7. for(y=0; y<4; y++){
  8. for(x=0; x<4; x++){
  9. C[4*y+x] = A[4*y+0]*B[4*0+x]
  10. +A[4*y+1]*B[4*1+x]
  11. +A[4*y+2]*B[4*2+x]
  12. +A[4*y+3]*B[4*3+x];
  13. }
  14. }
  15. }
  16. int main(){
  17. double duration;//执行时间
  18. clock_t s,f;
  19. int x = 0;
  20. int y = 0;
  21. int n = 0;
  22. int k = 0;
  23. float A[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
  24. float B[] = {0.1f,0.2f,0.3f,0.4f,0.5f,0.6f,0.7f,0.8f,0.9f,0.10f,0.11f,0.12f,0.13f,0.14f,0.15f,0.16f}
  25. float C[16];
  26. //------------------串行计算----------------------------
  27. s = clock();//计时开始
  28. for(n=0; n<1000000; n++){
  29. comput(A,B,C);
  30. }
  31. f = clock();//计时结束
  32. duration = (double)(f-s)/CLOCK_PER_SEC;
  33. printf("s---1,000,000: %f\n",duration);
  34. for(y=0; y<4; y++){
  35. for(x=0; x<4; x++){
  36. printf("%f ",C[y*4+x]);
  37. }
  38. printf("\n");
  39. }
  40. printf("----------------------------------------------\n");
  41. //------------------------------并行执行--------------------
  42. //===== 1. 一条线程 相当于串行 ============================
  43. s = clock();
  44. #pragma omp parallel for
  45. for (n = 0; n<1000000; n++){
  46. comput(A, B, C);
  47. }
  48. f = clock();
  49. duration = (double)(f - s) / CLOCKS_PER_SEC;
  50. printf("p1- 1,000,000 :%f\n", duration);
  51. //===== 1. 两条线程 ============================
  52. s=clock();
  53. #pragma omp parallel for
  54. for (n = 0; n<2; n++){//CPU是核线程的
  55. for (k = 0; k<500000; k++){//每个线程管个循环
  56. comput(A, B, C);
  57. }
  58. }
  59. f = clock();
  60. duration = (double)(f - s) / CLOCKS_PER_SEC;
  61. printf("p2- 1,000,000:%f\n", duration);
  62. //===== 1. 四条线程 ============================
  63. s = clock();
  64. #pragma omp parallel for
  65. for (n = 0; n<4; n++){ //CPU是核线程的
  66. for (k = 0; k<250000; k++){//每个线程管个循环
  67. comput(A, B, C);
  68. }
  69. }
  70. f = clock();
  71. duration = (double)(f - s) / CLOCKS_PER_SEC;
  72. printf("p3- 1,000,000:%f\n", duration);
  73. //-----------------------------------------------------------
  74. for (y = 0; y<4; y++){
  75. for (x = 0; x<4; x++){
  76. printf("%f,", C[y * 4 + x]);
  77. }
  78. printf("\n");
  79. }
  80. return 0;
  81. }

第十一章 现代计算机系统结构的发展

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注