Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libclfft
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
einsteinathome
libclfft
Commits
ca8932cf
Commit
ca8932cf
authored
14 years ago
by
Oliver Bock
Browse files
Options
Downloads
Patches
Plain Diff
Turning Apple-specific code into OS-independent implementation (tests pending)
parent
c7ad9ac5
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
example/Makefile
+1
-0
1 addition, 0 deletions
example/Makefile
example/main.cpp
+22
-9
22 additions, 9 deletions
example/main.cpp
example/procs.h
+53
-0
53 additions, 0 deletions
example/procs.h
include/clFFT.h
+7
-3
7 additions, 3 deletions
include/clFFT.h
with
83 additions
and
12 deletions
example/Makefile
+
1
−
0
View file @
ca8932cf
...
...
@@ -11,6 +11,7 @@ OS = $(shell uname -s)
ARCH
=
$(
shell
uname
-m
)
ifeq
($(OS), Darwin)
LDFLAGS
+=
-framework
OpenCL
LDFLAGS
+=
-framework
Accelerate
else
LDFLAGS
+=
-L
$(
ATISTREAMSDKROOT
)
/lib/
$(
ARCH
)
LDFLAGS
+=
-lOpenCL
...
...
This diff is collapsed.
Click to expand it.
example/main.cpp
+
22
−
9
View file @
ca8932cf
...
...
@@ -50,10 +50,14 @@
#include
<math.h>
#include
<stdio.h>
#include
<stdlib.h>
#i
nclude
<OpenCL/opencl.h>
#include
"clFFT
.h
"
#i
fdef __APPLE__
#include
<OpenCL/cl
.h
>
#include
<mach/mach_time.h>
#include
<Accelerate/Accelerate.h>
#else
#include
<CL/cl.h>
#endif
#include
<clFFT.h>
#include
"procs.h"
#include
<sys/types.h>
#include
<sys/stat.h>
...
...
@@ -87,6 +91,7 @@ cl_command_queue queue;
typedef
unsigned
long
long
ulong
;
#ifdef __APPLE__
double
subtractTimes
(
uint64_t
endTime
,
uint64_t
startTime
)
{
uint64_t
difference
=
endTime
-
startTime
;
...
...
@@ -104,7 +109,9 @@ double subtractTimes( uint64_t endTime, uint64_t startTime )
return
conversion
*
(
double
)
difference
;
}
#endif
#ifdef __APPLE__
void
computeReferenceF
(
clFFT_SplitComplex
*
out
,
clFFT_Dim3
n
,
unsigned
int
batchSize
,
clFFT_Dimension
dim
,
clFFT_Direction
dir
)
{
...
...
@@ -214,7 +221,9 @@ void computeReferenceF(clFFT_SplitComplex *out, clFFT_Dim3 n,
vDSP_destroy_fftsetup
(
plan_vdsp
);
}
#endif
#ifdef __APPLE__
void
computeReferenceD
(
clFFT_SplitComplexDouble
*
out
,
clFFT_Dim3
n
,
unsigned
int
batchSize
,
clFFT_Dimension
dim
,
clFFT_Direction
dir
)
{
...
...
@@ -324,6 +333,7 @@ void computeReferenceD(clFFT_SplitComplexDouble *out, clFFT_Dim3 n,
vDSP_destroy_fftsetupD
(
plan_vdsp
);
}
#endif
double
complexNormSq
(
clFFT_ComplexDouble
a
)
{
...
...
@@ -551,11 +561,13 @@ int runTest(clFFT_Dim3 n, int batchSize, clFFT_Direction dir, clFFT_Dimension di
goto
cleanup
;
}
#ifdef __APPLE__
t1
=
mach_absolute_time
();
t
=
subtractTimes
(
t1
,
t0
);
char
temp
[
100
];
sprintf
(
temp
,
"GFlops achieved for n = (%d, %d, %d), batchsize = %d"
,
n
.
x
,
n
.
y
,
n
.
z
,
batchSize
);
log_perf
(
gflops
/
(
float
)
t
,
1
,
"GFlops/s"
,
"%s"
,
temp
);
#endif
if
(
dataFormat
==
clFFT_SplitComplexFormat
)
{
...
...
@@ -573,6 +585,7 @@ int runTest(clFFT_Dim3 n, int batchSize, clFFT_Direction dir, clFFT_Dimension di
goto
cleanup
;
}
#ifdef __APPLE__
computeReferenceD
(
&
data_oref
,
n
,
batchSize
,
dim
,
dir
);
double
diff_avg
,
diff_max
,
diff_min
;
...
...
@@ -597,6 +610,7 @@ int runTest(clFFT_Dim3 n, int batchSize, clFFT_Direction dir, clFFT_Dimension di
free
(
result_split
.
real
);
free
(
result_split
.
imag
);
}
#endif
cleanup
:
clFFT_DestroyPlan
(
plan
);
...
...
@@ -726,7 +740,7 @@ int main (int argc, char * const argv[]) {
}
device_id
=
NULL
;
/*
unsigned
int
i
;
for
(
i
=
0
;
i
<
num_devices
;
i
++
)
{
...
...
@@ -763,8 +777,7 @@ int main (int argc, char * const argv[]) {
test_finish
();
return
-
1
;
}
*/
device_id
=
device_ids
[
1
];
context
=
clCreateContext
(
0
,
1
,
&
device_id
,
NULL
,
NULL
,
&
err
);
if
(
!
context
||
err
)
{
...
...
This diff is collapsed.
Click to expand it.
example/procs.h
0 → 100644
+
53
−
0
View file @
ca8932cf
//
// File: procs.h
//
// Version: <1.0>
//
// Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. ("Apple")
// in consideration of your agreement to the following terms, and your use,
// installation, modification or redistribution of this Apple software
// constitutes acceptance of these terms. If you do not agree with these
// terms, please do not use, install, modify or redistribute this Apple
// software.
//
// In consideration of your agreement to abide by the following terms, and
// subject to these terms, Apple grants you a personal, non - exclusive
// license, under Apple's copyrights in this original Apple software ( the
// "Apple Software" ), to use, reproduce, modify and redistribute the Apple
// Software, with or without modifications, in source and / or binary forms;
// provided that if you redistribute the Apple Software in its entirety and
// without modifications, you must retain this notice and the following text
// and disclaimers in all such redistributions of the Apple Software. Neither
// the name, trademarks, service marks or logos of Apple Inc. may be used to
// endorse or promote products derived from the Apple Software without specific
// prior written permission from Apple. Except as expressly stated in this
// notice, no other rights or licenses, express or implied, are granted by
// Apple herein, including but not limited to any patent rights that may be
// infringed by your derivative works or by other works in which the Apple
// Software may be incorporated.
//
// The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
// WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
// WARRANTIES OF NON - INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A
// PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION
// ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
//
// IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
// CONSEQUENTIAL DAMAGES ( INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION ) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION
// AND / OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER
// UNDER THEORY OF CONTRACT, TORT ( INCLUDING NEGLIGENCE ), STRICT LIABILITY OR
// OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright ( C ) 2008 Apple Inc. All Rights Reserved.
//
////////////////////////////////////////////////////////////////////////////////////////////////////
#define test_start()
#define log_perf(_number, _higherBetter, _numType, _format, ...) printf("Performance Number " _format " (in %s, %s): %g\n",##__VA_ARGS__, _numType, _higherBetter?"higher is better":"lower is better" , _number)
#define log_info printf
#define log_error printf
#define test_finish()
This diff is collapsed.
Click to expand it.
include/clFFT.h
+
7
−
3
View file @
ca8932cf
...
...
@@ -49,13 +49,17 @@
#ifndef __CLFFT_H
#define __CLFFT_H
#include
<stdio.h>
#ifdef __APPLE__
#include
<OpenCL/cl.h>
#else
#include
<CL/cl.h>
#endif
#ifdef __cplusplus
extern
"C"
{
#endif
#include
<OpenCL/opencl.h>
#include
<stdio.h>
// XForm type
typedef
enum
{
...
...
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