Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
HPC
hello-world
Commits
2beeb9bb
Commit
2beeb9bb
authored
Sep 30, 2017
by
Alejandro E. Rendon
Browse files
Change malloc
parent
be4c1088
Changes
1
Hide whitespace changes
Inline
Side-by-side
OpenMP/vec_add.cpp
View file @
2beeb9bb
...
...
@@ -23,7 +23,7 @@ void add(int *a, int *b, int *c, int n) {
}
void
addOmp
(
int
*
a
,
int
*
b
,
int
*
c
,
int
n
)
{
#pragma omp parallel for
#pragma omp parallel for
for
(
int
i
=
0
;
i
<
n
;
i
++
)
c
[
i
]
=
a
[
i
]
+
b
[
i
];
}
...
...
@@ -36,9 +36,9 @@ int main(int argc, char const *argv[]) {
int
*
a
,
*
b
,
*
c
;
double
begin
,
end
;
a
=
(
int
*
)
malloc
(
vec_size
*
sizeof
(
int
))
;
b
=
(
int
*
)
malloc
(
vec_size
*
sizeof
(
int
))
;
c
=
(
int
*
)
malloc
(
vec_size
*
sizeof
(
int
))
;
a
=
new
int
[
vec_size
]
;
b
=
new
int
[
vec_size
]
;
c
=
new
int
[
vec_size
]
;
fillVec
(
a
,
vec_size
,
10
);
fillVec
(
b
,
vec_size
,
10
);
...
...
@@ -58,9 +58,9 @@ int main(int argc, char const *argv[]) {
//print("c = ", c, vec_size);
fre
e
(
a
);
fre
e
(
b
);
fre
e
(
c
);
delet
e
(
a
);
delet
e
(
b
);
delet
e
(
c
);
}
return
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment