Skip to content

Commit

Permalink
Add CPU feature helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmoses committed Jul 3, 2023
1 parent ce1b420 commit ed1e3f5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/jl_exported_funcs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@
XX(jl_get_binding_or_error) \
XX(jl_get_binding_wr) \
XX(jl_get_cpu_name) \
XX(jl_get_cpu_features) \
XX(jl_get_current_task) \
XX(jl_get_default_sysimg_path) \
XX(jl_get_excstack) \
Expand Down
2 changes: 2 additions & 0 deletions src/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ jl_image_t jl_init_processor_pkgimg(void *hdl);

// Return the name of the host CPU as a julia string.
JL_DLLEXPORT jl_value_t *jl_get_cpu_name(void);
// Return the features of the host CPU as a julia string.
JL_DLLEXPORT jl_value_t *jl_get_cpu_features(void);
// Dump the name and feature set of the host CPU
// For debugging only
JL_DLLEXPORT void jl_dump_host_cpu(void);
Expand Down
5 changes: 5 additions & 0 deletions src/processor_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1802,6 +1802,11 @@ JL_DLLEXPORT jl_value_t *jl_get_cpu_name(void)
return jl_cstr_to_string(host_cpu_name().c_str());
}

JL_DLLEXPORT jl_value_t *jl_get_cpu_features(void)
{
return jl_cstr_to_string(jl_get_cpu_features_llvm().c_str());
}

jl_image_t jl_init_processor_sysimg(void *hdl)
{
if (!jit_targets.empty())
Expand Down
5 changes: 5 additions & 0 deletions src/processor_fallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ JL_DLLEXPORT jl_value_t *jl_get_cpu_name(void)
return jl_cstr_to_string(host_cpu_name().c_str());
}

JL_DLLEXPORT jl_value_t *jl_get_cpu_features(void)
{
return jl_cstr_to_string(jl_get_cpu_features_llvm().c_str());
}

JL_DLLEXPORT void jl_dump_host_cpu(void)
{
jl_safe_printf("CPU: %s\n", host_cpu_name().c_str());
Expand Down
5 changes: 5 additions & 0 deletions src/processor_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,11 @@ JL_DLLEXPORT jl_value_t *jl_get_cpu_name(void)
return jl_cstr_to_string(host_cpu_name().c_str());
}

JL_DLLEXPORT jl_value_t *jl_get_cpu_features(void)
{
return jl_cstr_to_string(jl_get_cpu_features_llvm().c_str());
}

jl_image_t jl_init_processor_sysimg(void *hdl)
{
if (!jit_targets.empty())
Expand Down

0 comments on commit ed1e3f5

Please sign in to comment.