icl-utk-edu / slate

SLATE is a distributed, GPU-accelerated, dense linear algebra library targetting current and upcoming high-performance computing (HPC) systems. It is developed as part of the U.S. Department of Energy Exascale Computing Project (ECP).
https://icl.utk.edu/slate/
BSD 3-Clause "New" or "Revised" License
91 stars 21 forks source link

Fix Options in C and Fortran APIs #152

Closed neil-lindquist closed 9 months ago

neil-lindquist commented 11 months ago

After looking at things, I felt like the best way to implement slate_Options was to make it just a pointer to the C++ options object and provide accessor functions to read/write the various options. The slate_Options_create and slate_Options_destroy functions match the create/destroy functions for slate_Matrix/slate_Pivots/etc.

The options are set as, e.g., slate_Options_set_Lookahead( slate_Options opts, int64_t value ) and get as, e.g., slate_Options_get_Lookahead( slate_Options opts, int64_t defval ). So, normal usage would be

 // Execute on GPU devices with lookahead of 2.
 slate_Options opts = slate_Options_create();
 slate_Options_set_Target( opts, slate_Target_Devices );
 slate_Options_set_Lookahead( opts, 2 );

 slate_multiply_c32( alpha, A, B, beta, C, opts );

 slate_Options_destroy( opts );

To help simplify things, passing NULL as the options gets converted into an empty options array. This helps simplify cases where the defaults are good enough, as in most of our examples:

 // Execute on Host with lookahead of 1.
 slate_multiply_c32( alpha, A, B, beta, C, NULL );

Alternative approaches:

Other improvements

mgates3 commented 9 months ago

I added my fixes, rebased and fixed the merge conflict.

neil-lindquist commented 9 months ago

@mgates3 Thanks for addressing Sebastien's comments. I apparently missed the notification.