Skip to content
GitLab
Explore
Sign in
Register
Commits on Source (3)
join: append to non-existing file
· 3e84c221
Martin Uecker
authored
Aug 23, 2019
3e84c221
generalize cuda fft a bit
· 26225a60
Martin Uecker
authored
Jul 30, 2019
26225a60
bump version
· 5efc0a95
Martin Uecker
authored
Aug 25, 2019
5efc0a95
Hide whitespace changes
Inline
Side-by-side
src/join.c
View file @
5efc0a95
...
...
@@ -11,6 +11,7 @@
#include
<stdbool.h>
#include
<complex.h>
#include
<string.h>
#include
<unistd.h>
#include
"num/multind.h"
#include
"num/init.h"
...
...
@@ -61,7 +62,28 @@ int main_join(int argc, char* argv[])
count
+=
1
;
// FIXME: check for cfl file
assert
(
count
>
1
);
int
len
=
strlen
(
argv
[
argc
-
1
]);
char
buf
[
len
+
5
];
strcpy
(
buf
,
argv
[
argc
-
1
]);
strcat
(
buf
,
".cfl"
);
if
(
-
1
==
access
(
buf
,
F_OK
))
{
// make sure we do not have any other file format
strcpy
(
buf
,
argv
[
argc
-
1
]);
strcat
(
buf
,
".coo"
);
assert
(
-
1
==
access
(
buf
,
F_OK
));
strcpy
(
buf
,
argv
[
argc
-
1
]);
strcat
(
buf
,
".ra"
);
assert
(
-
1
==
access
(
buf
,
F_OK
));
count
--
;
append
=
false
;
}
}
long
in_dims
[
count
][
N
];
...
...
src/num/fft-cuda.c
View file @
5efc0a95
/* Copyright 2013, 2015. The Regents of the University of California.
* Copyright 2019. Martin Uecker.
* All rights reserved. Use of this source code is governed by
* a BSD-style license which can be found in the LICENSE file.
*
* Authors:
* 2012-201
3, 2015
Martin Uecker <
uecker@eecs.berkeley.edu
>
* 2012-201
9
Martin Uecker <
martin.uecker@med.uni-goettingen.de
>
*
*
* Internal interface to the CUFFT library used in fft.c.
...
...
@@ -30,6 +31,7 @@
struct
fft_cuda_plan_s
{
cufftHandle
cufft
;
struct
fft_cuda_plan_s
*
chain
;
bool
backwards
;
...
...
@@ -49,7 +51,7 @@ struct iovec {
struct
fft_cuda_plan_s
*
fft_cuda_plan
(
unsigned
int
D
,
const
long
dimensions
[
D
],
unsigned
long
flags
,
const
long
ostrides
[
D
],
const
long
istrides
[
D
],
bool
backwards
)
static
struct
fft_cuda_plan_s
*
fft_cuda_plan
0
(
unsigned
int
D
,
const
long
dimensions
[
D
],
unsigned
long
flags
,
const
long
ostrides
[
D
],
const
long
istrides
[
D
],
bool
backwards
)
{
PTR_ALLOC
(
struct
fft_cuda_plan_s
,
plan
);
unsigned
int
N
=
D
;
...
...
@@ -58,6 +60,7 @@ struct fft_cuda_plan_s* fft_cuda_plan(unsigned int D, const long dimensions[D],
plan
->
odist
=
0
;
plan
->
idist
=
0
;
plan
->
backwards
=
backwards
;
plan
->
chain
=
NULL
;
struct
iovec
dims
[
N
];
struct
iovec
hmdims
[
N
];
...
...
@@ -107,8 +110,8 @@ struct fft_cuda_plan_s* fft_cuda_plan(unsigned int D, const long dimensions[D],
for
(
unsigned
int
i
=
0
;
i
<
k
;
i
++
)
{
assert
(
dims
[
i
].
is
==
lis
);
assert
(
dims
[
i
].
os
==
los
);
//
assert(dims[i].is == lis);
//
assert(dims[i].os == los);
cudims
[
k
-
1
-
i
]
=
dims
[
i
].
n
;
cuiemb
[
k
-
1
-
i
]
=
dims
[
i
].
n
;
...
...
@@ -183,9 +186,42 @@ errout:
}
struct
fft_cuda_plan_s
*
fft_cuda_plan
(
unsigned
int
D
,
const
long
dimensions
[
D
],
unsigned
long
flags
,
const
long
ostrides
[
D
],
const
long
istrides
[
D
],
bool
backwards
)
{
struct
fft_cuda_plan_s
*
plan
=
fft_cuda_plan0
(
D
,
dimensions
,
flags
,
ostrides
,
istrides
,
backwards
);
if
(
NULL
!=
plan
)
return
plan
;
int
lsb
=
ffs
(
flags
)
-
1
;
if
(
flags
&
lsb
)
{
// FIXME: this couldbe better...
struct
fft_cuda_plan_s
*
plan
=
fft_cuda_plan0
(
D
,
dimensions
,
lsb
,
ostrides
,
istrides
,
backwards
);
if
(
NULL
==
plan
)
return
NULL
;
plan
->
chain
=
fft_cuda_plan
(
D
,
dimensions
,
MD_CLEAR
(
flags
,
lsb
),
ostrides
,
ostrides
,
backwards
);
if
(
NULL
==
plan
->
chain
)
{
fft_cuda_free_plan
(
plan
);
return
NULL
;
}
return
plan
;
}
return
NULL
;
}
void
fft_cuda_free_plan
(
struct
fft_cuda_plan_s
*
cuplan
)
{
if
(
NULL
!=
cuplan
->
chain
)
fft_cuda_free_plan
(
cuplan
->
chain
);
cufftDestroy
(
cuplan
->
cufft
);
xfree
(
cuplan
);
}
...
...
@@ -207,7 +243,9 @@ void fft_cuda_exec(struct fft_cuda_plan_s* cuplan, complex float* dst, const com
(
!
cuplan
->
backwards
)
?
CUFFT_FORWARD
:
CUFFT_INVERSE
)))
error
(
"CUFFT: %d
\n
"
,
err
);
}
}
if
(
NULL
!=
cuplan
->
chain
)
fft_cuda_exec
(
cuplan
->
chain
,
dst
,
dst
);
}
#endif
tests/join.mk
View file @
5efc0a95
...
...
@@ -15,10 +15,21 @@ tests/test-join-append: ones zeros join nrmse
$(
TOOLDIR
)
/zeros 3 6 7 1 z
;
\
$(
TOOLDIR
)
/join 2 o z o j
;
\
$(
TOOLDIR
)
/join
-a
2 z o o
;
\
$(
TOOLDIR
)
/nrmse
-t
0.00001
o j
;
\
$(
TOOLDIR
)
/nrmse
-t
0.00001
j o
;
\
rm
*
.cfl
;
rm
*
.hdr
;
cd
..
;
rmdir
$(
TESTS_TMP
)
touch
$@
TESTS
+=
tests/test-join tests/test-join-append
tests/test-join-append-one
:
ones zeros join nrmse
set
-e
;
mkdir
$(
TESTS_TMP
)
;
cd
$(
TESTS_TMP
)
;
\
$(
TOOLDIR
)
/ones 3 6 7 1 o
;
\
$(
TOOLDIR
)
/zeros 3 6 7 1 z
;
\
$(
TOOLDIR
)
/join 2 o z j
;
\
$(
TOOLDIR
)
/join
-a
2 o z x
;
\
$(
TOOLDIR
)
/nrmse
-t
0.00001 j x
;
\
rm
*
.cfl
;
rm
*
.hdr
;
cd
..
;
rmdir
$(
TESTS_TMP
)
touch
$@
TESTS
+=
tests/test-join tests/test-join-append tests/test-join-append-one
version.txt
View file @
5efc0a95
v0.
4
.0
4
v0.
5
.0
0