[med-svn] [Git][med-team/bart][upstream] 3 commits: join: append to non-existing file

Martin Uecker gitlab at salsa.debian.org
Tue Aug 27 14:13:25 BST 2019



Martin Uecker pushed to branch upstream at Debian Med / bart


Commits:
3e84c221 by Martin Uecker at 2019-08-25T06:04:27Z
join: append to non-existing file

- - - - -
26225a60 by Martin Uecker at 2019-08-25T06:04:27Z
generalize cuda fft a bit

- - - - -
5efc0a95 by Martin Uecker at 2019-08-25T11:21:21Z
bump version

- - - - -


4 changed files:

- src/join.c
- src/num/fft-cuda.c
- tests/join.mk
- version.txt


Changes:

=====================================
src/join.c
=====================================
@@ -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
=====================================
@@ -1,9 +1,10 @@
 /* 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-2013, 2015 Martin Uecker <uecker at eecs.berkeley.edu>
+ * 2012-2019 Martin Uecker <martin.uecker at 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_plan0(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
=====================================
@@ -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
=====================================
@@ -1 +1 @@
-v0.4.04
+v0.5.00



View it on GitLab: https://salsa.debian.org/med-team/bart/compare/807ac4b269c4c301f804f2744e3b0e97d5544462...5efc0a95bbce5cc274a7c5ec3bb95ea0db6e67be

-- 
View it on GitLab: https://salsa.debian.org/med-team/bart/compare/807ac4b269c4c301f804f2744e3b0e97d5544462...5efc0a95bbce5cc274a7c5ec3bb95ea0db6e67be
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20190827/5088a780/attachment-0001.html>


More information about the debian-med-commit mailing list