Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
How Approximation Affects Parallelization
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nathanael Sandy
How Approximation Affects Parallelization
Commits
f6e31546
Commit
f6e31546
authored
6 years ago
by
Daniel Maier
Browse files
Options
Downloads
Patches
Plain Diff
fdtd-2d application
parent
a09f0080
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
codes/fdtd-2d/fdtd-2d.c
+170
-0
170 additions, 0 deletions
codes/fdtd-2d/fdtd-2d.c
codes/fdtd-2d/fdtd-2d.h
+86
-0
86 additions, 0 deletions
codes/fdtd-2d/fdtd-2d.h
with
256 additions
and
0 deletions
codes/fdtd-2d/fdtd-2d.c
0 → 100644
+
170
−
0
View file @
f6e31546
/**
* This version is stamped on May 10, 2016
*
* Contact:
* Louis-Noel Pouchet <pouchet.ohio-state.edu>
* Tomofumi Yuki <tomofumi.yuki.fr>
*
* Web address: http://polybench.sourceforge.net
*/
/* fdtd-2d.c: this file is part of PolyBench/C */
#include
<stdio.h>
#include
<unistd.h>
#include
<string.h>
#include
<math.h>
/* Include polybench common header. */
#include
<polybench.h>
/* Include benchmark-specific header. */
#include
"fdtd-2d.h"
/* Array initialization. */
static
void
init_array
(
int
tmax
,
int
nx
,
int
ny
,
DATA_TYPE
POLYBENCH_2D
(
ex
,
NX
,
NY
,
nx
,
ny
),
DATA_TYPE
POLYBENCH_2D
(
ey
,
NX
,
NY
,
nx
,
ny
),
DATA_TYPE
POLYBENCH_2D
(
hz
,
NX
,
NY
,
nx
,
ny
),
DATA_TYPE
POLYBENCH_1D
(
_fict_
,
TMAX
,
tmax
))
{
int
i
,
j
;
for
(
i
=
0
;
i
<
tmax
;
i
++
)
_fict_
[
i
]
=
(
DATA_TYPE
)
i
;
for
(
i
=
0
;
i
<
nx
;
i
++
)
for
(
j
=
0
;
j
<
ny
;
j
++
)
{
ex
[
i
][
j
]
=
((
DATA_TYPE
)
i
*
(
j
+
1
))
/
nx
;
ey
[
i
][
j
]
=
((
DATA_TYPE
)
i
*
(
j
+
2
))
/
ny
;
hz
[
i
][
j
]
=
((
DATA_TYPE
)
i
*
(
j
+
3
))
/
nx
;
}
}
/* DCE code. Must scan the entire live-out data.
Can be used also to check the correctness of the output. */
static
void
print_array
(
int
nx
,
int
ny
,
DATA_TYPE
POLYBENCH_2D
(
ex
,
NX
,
NY
,
nx
,
ny
),
DATA_TYPE
POLYBENCH_2D
(
ey
,
NX
,
NY
,
nx
,
ny
),
DATA_TYPE
POLYBENCH_2D
(
hz
,
NX
,
NY
,
nx
,
ny
))
{
int
i
,
j
;
POLYBENCH_DUMP_START
;
POLYBENCH_DUMP_BEGIN
(
"ex"
);
for
(
i
=
0
;
i
<
nx
;
i
++
)
for
(
j
=
0
;
j
<
ny
;
j
++
)
{
if
((
i
*
nx
+
j
)
%
20
==
0
)
fprintf
(
POLYBENCH_DUMP_TARGET
,
"
\n
"
);
fprintf
(
POLYBENCH_DUMP_TARGET
,
DATA_PRINTF_MODIFIER
,
ex
[
i
][
j
]);
}
POLYBENCH_DUMP_END
(
"ex"
);
POLYBENCH_DUMP_FINISH
;
POLYBENCH_DUMP_BEGIN
(
"ey"
);
for
(
i
=
0
;
i
<
nx
;
i
++
)
for
(
j
=
0
;
j
<
ny
;
j
++
)
{
if
((
i
*
nx
+
j
)
%
20
==
0
)
fprintf
(
POLYBENCH_DUMP_TARGET
,
"
\n
"
);
fprintf
(
POLYBENCH_DUMP_TARGET
,
DATA_PRINTF_MODIFIER
,
ey
[
i
][
j
]);
}
POLYBENCH_DUMP_END
(
"ey"
);
POLYBENCH_DUMP_BEGIN
(
"hz"
);
for
(
i
=
0
;
i
<
nx
;
i
++
)
for
(
j
=
0
;
j
<
ny
;
j
++
)
{
if
((
i
*
nx
+
j
)
%
20
==
0
)
fprintf
(
POLYBENCH_DUMP_TARGET
,
"
\n
"
);
fprintf
(
POLYBENCH_DUMP_TARGET
,
DATA_PRINTF_MODIFIER
,
hz
[
i
][
j
]);
}
POLYBENCH_DUMP_END
(
"hz"
);
}
/* Main computational kernel. The whole function will be timed,
including the call and return. */
static
void
kernel_fdtd_2d
(
int
tmax
,
int
nx
,
int
ny
,
DATA_TYPE
POLYBENCH_2D
(
ex
,
NX
,
NY
,
nx
,
ny
),
DATA_TYPE
POLYBENCH_2D
(
ey
,
NX
,
NY
,
nx
,
ny
),
DATA_TYPE
POLYBENCH_2D
(
hz
,
NX
,
NY
,
nx
,
ny
),
DATA_TYPE
POLYBENCH_1D
(
_fict_
,
TMAX
,
tmax
))
{
int
t
,
i
,
j
;
#pragma scop
for
(
t
=
0
;
t
<
_PB_TMAX
;
t
++
)
{
for
(
j
=
0
;
j
<
_PB_NY
;
j
++
)
ey
[
0
][
j
]
=
_fict_
[
t
];
for
(
i
=
1
;
i
<
_PB_NX
;
i
++
)
for
(
j
=
0
;
j
<
_PB_NY
;
j
++
)
ey
[
i
][
j
]
=
ey
[
i
][
j
]
-
SCALAR_VAL
(
0
.
5
)
*
(
hz
[
i
][
j
]
-
hz
[
i
-
1
][
j
]);
for
(
i
=
0
;
i
<
_PB_NX
;
i
++
)
for
(
j
=
1
;
j
<
_PB_NY
;
j
++
)
ex
[
i
][
j
]
=
ex
[
i
][
j
]
-
SCALAR_VAL
(
0
.
5
)
*
(
hz
[
i
][
j
]
-
hz
[
i
][
j
-
1
]);
for
(
i
=
0
;
i
<
_PB_NX
-
1
;
i
++
)
for
(
j
=
0
;
j
<
_PB_NY
-
1
;
j
++
)
hz
[
i
][
j
]
=
hz
[
i
][
j
]
-
SCALAR_VAL
(
0
.
7
)
*
(
ex
[
i
][
j
+
1
]
-
ex
[
i
][
j
]
+
ey
[
i
+
1
][
j
]
-
ey
[
i
][
j
]);
}
#pragma endscop
}
int
main
(
int
argc
,
char
**
argv
)
{
/* Retrieve problem size. */
int
tmax
=
TMAX
;
int
nx
=
NX
;
int
ny
=
NY
;
/* Variable declaration/allocation. */
POLYBENCH_2D_ARRAY_DECL
(
ex
,
DATA_TYPE
,
NX
,
NY
,
nx
,
ny
);
POLYBENCH_2D_ARRAY_DECL
(
ey
,
DATA_TYPE
,
NX
,
NY
,
nx
,
ny
);
POLYBENCH_2D_ARRAY_DECL
(
hz
,
DATA_TYPE
,
NX
,
NY
,
nx
,
ny
);
POLYBENCH_1D_ARRAY_DECL
(
_fict_
,
DATA_TYPE
,
TMAX
,
tmax
);
/* Initialize array(s). */
init_array
(
tmax
,
nx
,
ny
,
POLYBENCH_ARRAY
(
ex
),
POLYBENCH_ARRAY
(
ey
),
POLYBENCH_ARRAY
(
hz
),
POLYBENCH_ARRAY
(
_fict_
));
/* Start timer. */
polybench_start_instruments
;
/* Run kernel. */
kernel_fdtd_2d
(
tmax
,
nx
,
ny
,
POLYBENCH_ARRAY
(
ex
),
POLYBENCH_ARRAY
(
ey
),
POLYBENCH_ARRAY
(
hz
),
POLYBENCH_ARRAY
(
_fict_
));
/* Stop and print timer. */
polybench_stop_instruments
;
polybench_print_instruments
;
/* Prevent dead-code elimination. All live-out data must be printed
by the function call in argument. */
polybench_prevent_dce
(
print_array
(
nx
,
ny
,
POLYBENCH_ARRAY
(
ex
),
POLYBENCH_ARRAY
(
ey
),
POLYBENCH_ARRAY
(
hz
)));
/* Be clean. */
POLYBENCH_FREE_ARRAY
(
ex
);
POLYBENCH_FREE_ARRAY
(
ey
);
POLYBENCH_FREE_ARRAY
(
hz
);
POLYBENCH_FREE_ARRAY
(
_fict_
);
return
0
;
}
This diff is collapsed.
Click to expand it.
codes/fdtd-2d/fdtd-2d.h
0 → 100644
+
86
−
0
View file @
f6e31546
/**
* This version is stamped on May 10, 2016
*
* Contact:
* Louis-Noel Pouchet <pouchet.ohio-state.edu>
* Tomofumi Yuki <tomofumi.yuki.fr>
*
* Web address: http://polybench.sourceforge.net
*/
#ifndef _FDTD_2D_H
# define _FDTD_2D_H
/* Default to LARGE_DATASET. */
# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET)
# define LARGE_DATASET
# endif
# if !defined(TMAX) && !defined(NX) && !defined(NY)
/* Define sample dataset sizes. */
# ifdef MINI_DATASET
# define TMAX 20
# define NX 20
# define NY 30
# endif
# ifdef SMALL_DATASET
# define TMAX 40
# define NX 60
# define NY 80
# endif
# ifdef MEDIUM_DATASET
# define TMAX 100
# define NX 200
# define NY 240
# endif
# ifdef LARGE_DATASET
# define TMAX 500
# define NX 1000
# define NY 1200
# endif
# ifdef EXTRALARGE_DATASET
# define TMAX 1000
# define NX 2000
# define NY 2600
# endif
#endif
/* !(TMAX NX NY) */
# define _PB_TMAX POLYBENCH_LOOP_BOUND(TMAX,tmax)
# define _PB_NX POLYBENCH_LOOP_BOUND(NX,nx)
# define _PB_NY POLYBENCH_LOOP_BOUND(NY,ny)
/* Default data type */
# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE)
# define DATA_TYPE_IS_DOUBLE
# endif
#ifdef DATA_TYPE_IS_INT
# define DATA_TYPE int
# define DATA_PRINTF_MODIFIER "%d "
#endif
#ifdef DATA_TYPE_IS_FLOAT
# define DATA_TYPE float
# define DATA_PRINTF_MODIFIER "%0.2f "
# define SCALAR_VAL(x) x##f
# define SQRT_FUN(x) sqrtf(x)
# define EXP_FUN(x) expf(x)
# define POW_FUN(x,y) powf(x,y)
# endif
#ifdef DATA_TYPE_IS_DOUBLE
# define DATA_TYPE double
# define DATA_PRINTF_MODIFIER "%0.2lf "
# define SCALAR_VAL(x) x
# define SQRT_FUN(x) sqrt(x)
# define EXP_FUN(x) exp(x)
# define POW_FUN(x,y) pow(x,y)
# endif
#endif
/* !_FDTD_2D_H */
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment