aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'sci-mathematics/petsc/files/petsc-3.3-fix-complex-threads.patch')
-rw-r--r--sci-mathematics/petsc/files/petsc-3.3-fix-complex-threads.patch62
1 files changed, 62 insertions, 0 deletions
diff --git a/sci-mathematics/petsc/files/petsc-3.3-fix-complex-threads.patch b/sci-mathematics/petsc/files/petsc-3.3-fix-complex-threads.patch
new file mode 100644
index 000000000..ae41bab66
--- /dev/null
+++ b/sci-mathematics/petsc/files/petsc-3.3-fix-complex-threads.patch
@@ -0,0 +1,62 @@
+As reported by disperato
+at https://github.com/gentoo-science/sci/issues/47
+compilation fails if complex scalars are used together with
+threads support.
+This fix to VecNorm_SeqPThread(...) was inspired by the
+implementation of VecNorm_Seq(...) in src/vec/vec/impls/seq/bvec2.c
+
+Index: petsc-3.3-p5/src/vec/vec/impls/seq/seqpthread/vecpthread.c
+===================================================================
+--- a/src/vec/vec/impls/seq/seqpthread/vecpthread.c
++++ b/src/vec/vec/impls/seq/seqpthread/vecpthread.c
+@@ -589,17 +589,33 @@ PetscErrorCode VecNorm_SeqPThread(...)
+ }
+ ierr = PetscThreadsRunKernel(VecNorm_Kernel,(void**)vec_pdata,tmap->nthreads,tmap->affinity);
+ /* collect results */
+- *z = (PetscReal)vec_kerneldatap[0].result;
++#if defined(PETSC_USE_COMPLEX)
++ *z = PetscRealPart(vec_kerneldatap[0].result);
++#else
++ *z = (PetscReal)vec_kerneldatap[0].result;
++#endif
+ if(type == NORM_1) {
+ for(i=1; i<tmap->nthreads; i++) {
+- *z += (PetscReal)vec_kerneldatap[i].result;
++#if defined(PETSC_USE_COMPLEX)
++ *z += PetscRealPart(vec_kerneldatap[i].result);
++#else
++ *z += (PetscReal)vec_kerneldatap[i].result;
++#endif
+ }
+ ierr = PetscLogFlops(PetscMax(xin->map->n-1.0+tmap->nthreads-1,0.0));CHKERRQ(ierr);
+ }
+ else if(type == NORM_2 || type == NORM_FROBENIUS) {
+- *z = (PetscReal)vec_kerneldatap[0].result;
++#if defined(PETSC_USE_COMPLEX)
++ *z = PetscRealPart(vec_kerneldatap[0].result);
++#else
++ *z = (PetscReal)vec_kerneldatap[0].result;
++#endif
+ for(i=1; i<tmap->nthreads; i++) {
+- *z += (PetscReal)vec_kerneldatap[i].result;
++#if defined(PETSC_USE_COMPLEX)
++ *z += PetscRealPart(vec_kerneldatap[i].result);
++#else
++ *z += (PetscReal)vec_kerneldatap[i].result;
++#endif
+ }
+ *z = PetscSqrtReal(*z);
+ ierr = PetscLogFlops(PetscMax(2.0*xin->map->n-1+tmap->nthreads-1,0.0));CHKERRQ(ierr);
+@@ -607,7 +623,11 @@
+ else {
+ PetscReal maxv = 0.0,tmp;
+ for(i=0; i<tmap->nthreads; i++) {
+- tmp = (PetscReal)vec_kerneldatap[i].result;
++#if defined(PETSC_USE_COMPLEX)
++ tmp = PetscRealPart(vec_kerneldatap[i].result);
++#else
++ tmp = (PetscReal)vec_kerneldatap[i].result;
++#endif
+ if(tmp>maxv) {
+ maxv = tmp;
+ }