-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
76 lines (61 loc) · 1.49 KB
/
Copy pathmain.cpp
File metadata and controls
76 lines (61 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "mainwindow.h"
#include <QApplication>
#include <omp.h>
#include <QDebug>
#include <iostream>
#define TRUE 1
#define FALSE 0
void aa()
{
int n = 4;
int *a, **b;
#ifdef _OPENMP
(void) omp_set_dynamic(FALSE);
if (omp_get_dynamic()) { printf("Warning: dynamic adjustment of threads has been set\n"); }
(void)omp_set_num_threads(4);
#endif
if ((a = (int *)malloc(n * sizeof(int))) == NULL) {
perror("array a"); exit(-1);
}
if ((b = (int **)malloc(n * sizeof(int *))) == NULL) {
perror("array b"); exit(-1);
}
else {
for (int i = 0; i < n; i++)
if ((b[i] = (int *)malloc(n * sizeof(int))) == NULL)
{
perror("array b"); exit(-1);
}
}
#pragma omp parallel shared(n,a,b)
{
#pragma omp for
for (int i = 0; i < n; i++)
{
a[i] = i + 1;
#pragma omp parallel
for (int j = 0; j < n; j++)
b[i][j] = a[i];
}
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
printf("b[%d][%d] = %d ", i, j, b[i][j]);
printf("\n");
}
}
//test
//extern "C" void getDeviceInfo();
//extern "C" void addWithCuda(int *c, const int *a, const int *b, unsigned int size);
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
// getDeviceInfo();
// std::cout.flush();
QFont font("Microsoft YaHei", 10);
a.setFont(font);
MainWindow w;
w.show();
return a.exec();
}