Skip to content

Commit

Permalink
use def instead of enum for BLASFEO_PROCESSOR_FEATURES
Browse files Browse the repository at this point in the history
  • Loading branch information
giaf committed Dec 13, 2021
1 parent 675a2ab commit a96c518
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
17 changes: 15 additions & 2 deletions auxiliary/blasfeo_processor_features.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
* *
**************************************************************************************************/

#include "../include/blasfeo_processor_features.h"
#include "../include/blasfeo_target.h"
#include <blasfeo_processor_features.h>
#include <blasfeo_target.h>

#if defined(TARGET_X64_INTEL_HASWELL) \
|| defined(TARGET_X64_INTEL_SANDY_BRIDGE) \
Expand All @@ -51,6 +51,19 @@
#endif
#endif

// x86-64 CPU features
#define BLASFEO_PROCESSOR_FEATURE_AVX 0x0001 /// AVX instruction set
#define BLASFEO_PROCESSOR_FEATURE_AVX2 0x0002 /// AVX2 instruction set
#define BLASFEO_PROCESSOR_FEATURE_FMA 0x0004 /// FMA instruction set
#define BLASFEO_PROCESSOR_FEATURE_SSE3 0x0008 /// SSE3 instruction set

// ARM CPU features
#define BLASFEO_PROCESSOR_FEATURE_VFPv3 0x0100 /// VFPv3 instruction set
#define BLASFEO_PROCESSOR_FEATURE_NEON 0x0100 /// NEON instruction set
#define BLASFEO_PROCESSOR_FEATURE_VFPv4 0x0100 /// VFPv4 instruction set
#define BLASFEO_PROCESSOR_FEATURE_NEONv2 0x0100 /// NEONv2 instruction set



void blasfeo_processor_feature_string( int features, char* featureString )
{
Expand Down
28 changes: 14 additions & 14 deletions include/blasfeo_processor_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@
/**
* Flags to indicate the different processor features
*/
enum
{
// x86-64 CPU features
BLASFEO_PROCESSOR_FEATURE_AVX = 0x0001, /// AVX instruction set
BLASFEO_PROCESSOR_FEATURE_AVX2 = 0x0002, /// AVX2 instruction set
BLASFEO_PROCESSOR_FEATURE_FMA = 0x0004, /// FMA instruction set
BLASFEO_PROCESSOR_FEATURE_SSE3 = 0x0008, /// SSE3 instruction set

// ARM CPU features
BLASFEO_PROCESSOR_FEATURE_VFPv3 = 0x0100, /// VFPv3 instruction set
BLASFEO_PROCESSOR_FEATURE_NEON = 0x0100, /// NEON instruction set
BLASFEO_PROCESSOR_FEATURE_VFPv4 = 0x0100, /// VFPv4 instruction set
BLASFEO_PROCESSOR_FEATURE_NEONv2 = 0x0100, /// NEONv2 instruction set
} BLASFEO_PROCESSOR_FEATURES;
//enum
//{
// // x86-64 CPU features
// BLASFEO_PROCESSOR_FEATURE_AVX = 0x0001, /// AVX instruction set
// BLASFEO_PROCESSOR_FEATURE_AVX2 = 0x0002, /// AVX2 instruction set
// BLASFEO_PROCESSOR_FEATURE_FMA = 0x0004, /// FMA instruction set
// BLASFEO_PROCESSOR_FEATURE_SSE3 = 0x0008, /// SSE3 instruction set
//
// // ARM CPU features
// BLASFEO_PROCESSOR_FEATURE_VFPv3 = 0x0100, /// VFPv3 instruction set
// BLASFEO_PROCESSOR_FEATURE_NEON = 0x0100, /// NEON instruction set
// BLASFEO_PROCESSOR_FEATURE_VFPv4 = 0x0100, /// VFPv4 instruction set
// BLASFEO_PROCESSOR_FEATURE_NEONv2 = 0x0100, /// NEONv2 instruction set
//} BLASFEO_PROCESSOR_FEATURES;

/**
* Test the features that this processor provides against what the library was compiled with.
Expand Down

2 comments on commit a96c518

@imciner2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving the feature listing to a define in the C file will break the intended use-case of the first two functions (blasfeo_processor_cpu_features and blasfeo_processor_library_features), since they will give the caller an integer containing the bitmask of the features the processor supports. Without the feature listing in the header file, user-code that wants to use these functions won't be able to understand the returned bitflags easily. In my opinion, it is better to leave them in the header file instead of moving them to the C file.

@giaf
Copy link
Owner Author

@giaf giaf commented on a96c518 Jan 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Ian, I did this change as a fix to an issue with a double-defined BLASFEO_PROCESSOR_FEATURES enum compiler error.
Now I don't remember exactly, but it could have been on windows, possibly in another library including the BLASFEO library.

Please sign in to comment.