|
| 1 | +/*************************************************************************** |
| 2 | +Copyright (c) 2025, The OpenBLAS Project |
| 3 | +All rights reserved. |
| 4 | +
|
| 5 | +Redistribution and use in source and binary forms, with or without |
| 6 | +modification, are permitted provided that the following conditions are |
| 7 | +met: |
| 8 | +
|
| 9 | + 1. Redistributions of source code must retain the above copyright |
| 10 | + notice, this list of conditions and the following disclaimer. |
| 11 | +
|
| 12 | + 2. Redistributions in binary form must reproduce the above copyright |
| 13 | + notice, this list of conditions and the following disclaimer in |
| 14 | + the documentation and/or other materials provided with the |
| 15 | + distribution. |
| 16 | + 3. Neither the name of the OpenBLAS project nor the names of |
| 17 | + its contributors may be used to endorse or promote products |
| 18 | + derived from this software without specific prior written |
| 19 | + permission. |
| 20 | +
|
| 21 | +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 22 | +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 23 | +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 24 | +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 25 | +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 26 | +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 27 | +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 28 | +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 29 | +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE |
| 30 | +USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | +*****************************************************************************/ |
| 32 | + |
| 33 | +#include <stdio.h> |
| 34 | +#include "common.h" |
| 35 | + |
| 36 | +#if defined(DOUBLE) |
| 37 | +#define ERROR_NAME "DLAED3" |
| 38 | +#else |
| 39 | +#define ERROR_NAME "SLAED3" |
| 40 | +#endif |
| 41 | + |
| 42 | +/* ===================================================================== */ |
| 43 | +int NAME(blasint *k, blasint *n, blasint *n1, FLOAT *d, |
| 44 | + FLOAT *q, blasint *ldq, FLOAT *rho, FLOAT *dlamda, |
| 45 | + FLOAT *q2, blasint *indx, blasint *ctot, FLOAT *w, |
| 46 | + FLOAT *s, blasint *Info) |
| 47 | +{ |
| 48 | + blasint kval, nval, qdim, info; |
| 49 | + |
| 50 | + qdim = *ldq; |
| 51 | + kval = *k; |
| 52 | + nval = *n; |
| 53 | + |
| 54 | +/* Test the input parameters. */ |
| 55 | + info = 0; |
| 56 | + if (kval < 0) { |
| 57 | + info = 1; |
| 58 | + } else if (nval < kval) { |
| 59 | + info = 2; |
| 60 | + } else if (qdim < nval || qdim < 1) { |
| 61 | + info = 6; |
| 62 | + } |
| 63 | + if (info) { |
| 64 | + BLASFUNC(xerbla)(ERROR_NAME, &info, sizeof(ERROR_NAME) - 1); |
| 65 | + *Info = - info; |
| 66 | + return 0; |
| 67 | + } |
| 68 | + |
| 69 | +/* Quick return if possible */ |
| 70 | + |
| 71 | + *Info = 0; |
| 72 | + if (kval == 0) return 0; |
| 73 | + |
| 74 | +#ifdef SMP |
| 75 | + int nthreads = num_cpu_avail(4); |
| 76 | + |
| 77 | + if (nthreads == 1) { |
| 78 | +#endif |
| 79 | + LAED3_SINGLE(k, n, n1, d, q, ldq, rho, dlamda, q2, indx, ctot, w, s, Info); |
| 80 | +#ifdef SMP |
| 81 | + } else { |
| 82 | + LAED3_PARALLEL(k, n, n1, d, q, ldq, rho, dlamda, q2, indx, ctot, w, s, Info); |
| 83 | + } |
| 84 | +#endif |
| 85 | + |
| 86 | + return 0; |
| 87 | +} |
0 commit comments