Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Puzzles about using FLASH_LU_piv #91

Open
FuncJ opened this issue Feb 22, 2023 · 4 comments
Open

Puzzles about using FLASH_LU_piv #91

FuncJ opened this issue Feb 22, 2023 · 4 comments

Comments

@FuncJ
Copy link

FuncJ commented Feb 22, 2023

Hi, I want to utilize the function 'FLASH_lu_piv' to perform a LU factorization. But I have met a NULL pointer error. This error could be my mistake for misunderstanding the usage of the function.

  • Configuration
./configure --enable-dynamic-build --enable-external-lapack-for-subproblems --enable-external-lapack-interfaces --enable-multithreading=openmp --enable-supermatrix --enable-cblas-interfaces --enable-portable-timer 
  • Code samples
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <unistd.h>
#include <FLAME.h>

int main( void )
{
    // matrix parameters: A, column major
    int N;
    // test parameters
    int N_START, N_END, INC, REPEAT;

    printf("[INPUT]: input N_START, N_END, INC, REPEAT\n");
    if(scanf("%d %d %d %d", &N_START, &N_END, &INC, &REPEAT) == 4){
        printf("[TRUE]: true parameters for scanf\n");
    }
    else{
        fprintf(stderr, "[ERROR]: false parameters for scanf\n");
        exit(EXIT_FAILURE);
    }

    // Initialize libflame.
    FLA_Init();

    // N, REPEAT
    N = N_START;
    while (N <= N_END){
        for(int re_count = 0; re_count < REPEAT; ++ re_count){
                dim_t blocksize = 40, depth = 1;

                FLA_Obj IPIV;
                FLA_Obj_create( FLA_INT, N, 1, 0, 0, &IPIV);

                FLA_Obj A, A_FLASH;
                FLA_Obj_create( FLA_DOUBLE, N, N, 0, 0, &A );
                FLA_Random_matrix( A );

                int info;
                FLASH_Obj_create_hier_copy_of_flat(A, depth, &blocksize, &A_FLASH);
                info = FLASH_LU_piv(A_FLASH, IPIV);

                FLASH_Obj_free( &A_FLASH ); FLA_Obj_free( &IPIV );
            }
        N += INC;
    }
    
    FLA_Finalize();

    return 0;
}
  • build
gcc -o flame.x flame.c -I /home/xx/lib/libflame/include/ /home/xx/project/libflame/lib/x86_64-unknown-linux-gnu/libflame.a /home/xx/lib/openblas/lib/libopenblas.a -fopenmp -lpthread -lm
  • Error Information
    image
@iotamudelta
Copy link
Collaborator

If you are using the FLASH interface to libflame, you're probably better off using FLASH_LU_incpiv(). It provides a pivoted LU decomposition more suitable to an algorithms-by-blocks approach like SuperMatrix/FLASH.

There's an example for its use to be found here: src/lapack/dec/lu/incpiv/front/flamec/test/flash_sm

@FuncJ
Copy link
Author

FuncJ commented Feb 23, 2023

Thanks, I'll try it. What can I do to utilize the function 'FLASH_LU_piv' correctly?

@FuncJ FuncJ changed the title Puzzles about using FLASH_lu_piv Puzzles about using FLASH_LU_piv Feb 23, 2023
@iotamudelta
Copy link
Collaborator

See starting here:

FLASH_LU_incpiv_create_hier_matrices( A, 1, &nb_flash, nb_alg,
in the test case quoted above. AFAIK the use of the helper functions for creation of hierarchical matrices is strongly advised.

@FuncJ
Copy link
Author

FuncJ commented Feb 25, 2023

Thanks, It is my fault for misunderstanding the function 'FLASH_LU_piv' usage. Not only the matrix 'A_FLASH' should be a hierarchical object, but also the matrix 'IPIV'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants