Follow up to the previous mail regarding LAPACK code generation.

21 views
Skip to first unread message

kanan talreja

unread,
Mar 22, 2026, 12:30:47 PM (yesterday) Mar 22
to sy...@googlegroups.com
Hi!
I tried implementing the idea I discussed in my previous mail regarding LAPACK code generation for Matrix operations.
Here is the LAPACK code generated for MatrixSolve in C language:

/******************************************************************************
 *                    Code generated with SymPy 1.15.0.dev                    *
 *                                                                            *
 *              See http://www.sympy.org/ for more information.               *
 *                                                                            *
 *                       This file is part of 'project'                       *
 ******************************************************************************/
#include "test.h"
#include <lapacke.h>
#include <math.h>

int f(double *A, double *b) {
   int n = 3;
   int nrhs = 1;
   int ipiv[3];
   int info;

   info = LAPACKE_dgesv(LAPACK_ROW_MAJOR, n, nrhs, A, n, ipiv, b, nrhs);
   return info;

}


The _dgesv() LAPACK call is generated by the _print_MatrixSolve method that I created inside the printing module.
I also created a different CodeGen class, LAPACKCCodeGen, and overrode _preprocessor_statements(), _declare_locals(), routine() and _call_printer() methods.

I am seeking more guidance and feedback for this approach. Is the architecture right? Should LAPACKCCodeGen be a separate class? 
Any feedback or guidance would be appreciated!

Regards,
Kanan
Reply all
Reply to author
Forward
0 new messages