Click here to Skip to main content
15,885,216 members
Articles / Multimedia / DirectX

Rendering Text with Direct2D & DirectWrite

Rate me:
Please Sign up or sign in to vote.
4.94/5 (39 votes)
3 Jan 2015CPOL8 min read 105.6K   2.8K   76  
Direct2D, DirectWrite, Windows API, C++, std::shared_ptr and more
#include "stdafx.h"

#include "hnum_pcsp_defs.h"
namespace harlinn
{
    namespace numerics
    {
        namespace SuperLU
        {
            namespace Complex
            {
                void
                pcgstrf_thread_finalize(pcgstrf_threadarg_t *pcgstrf_threadarg, 
			                pxgstrf_shared_t *pxgstrf_shared,
			                SuperMatrix *A, int *perm_r,
			                SuperMatrix *L, SuperMatrix *U
			                )
                {
                /*
                 * -- SuperLU MT routine (version 2.0) --
                 * Lawrence Berkeley National Lab, Univ. of California Berkeley,
                 * and Xerox Palo Alto Research Center.
                 * September 10, 2007
                 *
                 *
                 * Purpose
                 * =======
                 * 
                 * pcgstrf_thread_finalize() performs cleanups after the multithreaded 
                 * factorization pcgstrf_thread(). It sets up the L and U data
                 * structures, and deallocats the storage associated with the structures
                 * pxgstrf_shared and pcgstrf_threadarg.
                 *
                 * Arguments
                 * =========
                 *
                 * pcgstrf_threadarg (input) pcgstrf_threadarg_t*
                 *          The structure contains the parameters to each thread.
                 *
                 * pxgstrf_shared (input) pxgstrf_shared_t*
                 *          The structure contains the shared task queue, the 
                 *          synchronization variables, and the L and U data structures.
                 *
                 * A        (input) SuperMatrix*
                 *	    Original matrix A, permutated by columns, of dimension
                 *          (A->nrow, A->ncol). The type of A can be:
                 *          Stype = NCP; Dtype = _D; Mtype = GE.
                 *
                 * perm_r   (input) int*, dimension A->nrow
                 *          Row permutation vector which defines the permutation matrix Pr,
                 *          perm_r[i] = j means row i of A is in position j in Pr*A.
                 *
                 * L        (output) SuperMatrix*
                 *          The factor L from the factorization Pr*A=L*U; use compressed row 
                 *          subscripts storage for supernodes, i.e., L has type: 
                 *          Stype = SCP, Dtype = _D, Mtype = TRLU.
                 *
                 * U        (output) SuperMatrix*
                 *	    The factor U from the factorization Pr*A*Pc=L*U. Use column-wise
                 *          storage scheme, i.e., U has type:
                 *          Stype = NCP, Dtype = _D, Mtype = TRU.
                 *
                 *
                 */
                    register int nprocs, n, i, iinfo;
                    int       nnzL, nnzU;
                    superlumt_options_t *superlumt_options;
                    GlobalLU_t *Glu;
                    extern ExpHeader *cexpanders;

                    n = A->ncol;
                    superlumt_options = pcgstrf_threadarg->superlumt_options;
                    Glu = pxgstrf_shared->Glu;
                    Glu->supno[n] = Glu->nsuper;

                    countnz(n, pxgstrf_shared->xprune, &nnzL, &nnzU, Glu);
                    fixupL(n, perm_r, Glu);
    
                #ifdef COMPRESS_LUSUP
                    compressSUP(n, pxgstrf_shared->Glu);
                #endif

                    if ( superlumt_options->refact == YES ) {
                        /* L and U structures may have changed due to possibly different
	                   pivoting, although the storage is available. */
                        ((SCPformat *)L->Store)->nnz = nnzL;
	                ((SCPformat *)L->Store)->nsuper = Glu->supno[n];
	                ((NCPformat *)U->Store)->nnz = nnzU;
                    } else {
	                cCreate_SuperNode_Permuted(L, A->nrow, A->ncol, nnzL, Glu->lusup,
				                   Glu->xlusup, Glu->xlusup_end, 
				                   Glu->lsub, Glu->xlsub, Glu->xlsub_end,
				                   Glu->supno, Glu->xsup, Glu->xsup_end,
				                   SLU_SCP, SLU_C, SLU_TRLU);
	                cCreate_CompCol_Permuted(U, A->nrow, A->ncol, nnzU, Glu->ucol,
				                 Glu->usub, Glu->xusub, Glu->xusub_end,
				                 SLU_NCP, SLU_C, SLU_TRU);
                    }

                    /* Combine the INFO returned from individual threads. */
                    iinfo = 0;
                    nprocs = superlumt_options->nprocs;
                    for (i = 0; i < nprocs; ++i) {
                        if ( pcgstrf_threadarg[i].info ) {
	                    if (iinfo) iinfo=SUPERLU_MIN(iinfo, pcgstrf_threadarg[i].info);
	                    else iinfo = pcgstrf_threadarg[i].info;
	                }
                    }
                    *pxgstrf_shared->info = iinfo;

                #if ( DEBUGlevel>=2 )
                    printf("Last nsuper %d\n", Glu->nsuper);
                    QueryQueue(&pxgstrf_shared->taskq);
                    PrintGLGU(n, pxgstrf_shared->xprune, Glu);
                    PrintInt10("perm_r", n, perm_r);
                    PrintInt10("inv_perm_r", n, pxgstrf_shared->inv_perm_r);
                #endif

                    /* Deallocate the storage used by the parallel scheduling algorithm. */
                    ParallelFinalize(pxgstrf_shared);
                    SUPERLU_FREE(pcgstrf_threadarg);
                    SUPERLU_FREE(pxgstrf_shared->inv_perm_r);
                    SUPERLU_FREE(pxgstrf_shared->inv_perm_c);
                    SUPERLU_FREE(pxgstrf_shared->xprune);
                    SUPERLU_FREE(pxgstrf_shared->ispruned);
                    SUPERLU_FREE(cexpanders);
                    cexpanders = 0;

                #if ( DEBUGlevel>=1 )
                    printf("** pcgstrf_thread_finalize() called\n");
                #endif
                }

            };
        };
    };
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect Sea Surveillance AS
Norway Norway
Chief Architect - Sea Surveillance AS.

Specializing in integrated operations and high performance computing solutions.

I’ve been fooling around with computers since the early eighties, I’ve even done work on CP/M and MP/M.

Wrote my first “real” program on a BBC micro model B based on a series in a magazine at that time. It was fun and I got hooked on this thing called programming ...

A few Highlights:

  • High performance application server development
  • Model Driven Architecture and Code generators
  • Real-Time Distributed Solutions
  • C, C++, C#, Java, TSQL, PL/SQL, Delphi, ActionScript, Perl, Rexx
  • Microsoft SQL Server, Oracle RDBMS, IBM DB2, PostGreSQL
  • AMQP, Apache qpid, RabbitMQ, Microsoft Message Queuing, IBM WebSphereMQ, Oracle TuxidoMQ
  • Oracle WebLogic, IBM WebSphere
  • Corba, COM, DCE, WCF
  • AspenTech InfoPlus.21(IP21), OsiSoft PI


More information about what I do for a living can be found at: harlinn.com or LinkedIn

You can contact me at espen@harlinn.no

Comments and Discussions