-
Notifications
You must be signed in to change notification settings - Fork 428
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
BINDINGS/GO/PERF: Implement flag.Value for UcsMemoryType #10312
base: master
Are you sure you want to change the base?
BINDINGS/GO/PERF: Implement flag.Value for UcsMemoryType #10312
Conversation
bindings/go/src/ucx/memory.go
Outdated
switch strings.ToLower(value) { | ||
case "host": *mt = UCS_MEMORY_TYPE_HOST | ||
case "cuda": *mt = UCS_MEMORY_TYPE_CUDA | ||
default: return errors.New("memory type can be host or cuda") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can either be
bindings/go/src/ucx/memory.go
Outdated
@@ -67,3 +72,12 @@ func (m *UcpMemory) Close() error { | |||
|
|||
return nil | |||
} | |||
|
|||
func (mt *UcsMemoryType) Set (value string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it mean that ucx go bindings set memory type by string instead of value?
IMO string->Value logic should be in perftest, not in go bindings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in golang interface can't be implemented on type from other package, though may created wrapper for mem type in perftest
on the other hand value -> string logic already implemented in go bindings,
ucx/bindings/go/src/ucx/ucs_constants.go
Line 33 in 7195d04
func (m UcsMemoryType) String() string { |
bindings/go/src/ucx/ucs_constants.h
Outdated
static inline const char* ucxgo_get_ucs_mem_type_name(ucs_memory_type_t idx) { | ||
return ucs_memory_type_names[idx]; | ||
} | ||
|
||
static inline ssize_t ucxgo_parse_ucs_mem_type_name(void* value) { | ||
ssize_t idx = ucs_string_find_in_list((const char *)value, ucs_memory_type_names, 0); | ||
free(value); | ||
return idx; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do these functions have to be inline?
What?
Implement
flag.Value
interface forucx.UcsMemoryType
and useflag.Var
function to set-m
argument.Why?
For enums,
flag.Value
/flag.Var
is the better choice because it promotes good software design principles like type safety, reusability, and clean separation of concerns.