Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Update to SuiteSparse:GraphBLAS 8.0.0#456

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
eriknw merged 45 commits intopython-graphblas:mainfromeriknw:v8.0.0
Jul 5, 2023

Conversation

@eriknw
Copy link
Member

@eriknweriknw commentedMay 21, 2023
edited
Loading

This begins updating to SuiteSparse:GraphBLAS 8.0.0, which added the JIT and contexts. Currently, this PR adds support for context and updates the configurations. We still need to support the JIT.

See release log here:https://github.com/DrTimothyAldenDavis/GraphBLAS/releases/tag/v8.0.0

Contexts

There are two types of contexts: global, and thread-local.

  • The global context can be viewed and modified atgb.global_context.
  • Local contexts can be created bygb.ss.Context().
    • Local contexts can also be used as context managers, such aswith gb.ss.Context(nthreads=4):.
    • Contexts also havec.engage() andc.disengage() methods that are used by__enter__ and__exit__.

Local contexts do not stack. The inner context replaces the outer context here:

withContext(nthreads=8):# nthreads is 8withContext(nthreads=4):# nthreads is 4# Now nthreads is default (not 8!)

I don't know if we want to try to keep track of the stack ourselves. Perhaps if/when somebody needs such a workflow.

The other tricky thing with contexts is thatnthreads andchunks were removed as descriptor options. This is awkward for us, since I like the syntax ofexpr.new(nthreads=8) andC(nthreads=8) << expr and would like to keep it (and not add incompatible changes). So, I kept it. If any context option is used in**opts (which is typically for the descriptor), then we either update the current context that the user explicitly engaged, or we create a new context whose lifetime matches the descriptor lifetime. This ought to work well enough in practice, but I'm not fond of relying on__del__ to disengage the context. I would prefer if e.g.nthreads was still part of the descriptor.

Configs

Two changes happened with configuration in SuiteSparse:GraphBLAS:

  • nthreads andchunks were removed (they're now handled by context
  • many JIT options were added

We have some choices for how we can handle these.

First, the global config can have all configurations and global contexts:

>>>gb.ss.configGlobalConfig({'bitmap_switch': [0.03999999910593033,0.05000000074505806,0.05999999865889549,0.07999999821186066,0.10000000149011612,0.20000000298023224,0.30000001192092896,0.4000000059604645],'burble':False,'chunk':65536.0,'format':'by_row','gpu_id':-1,'hyper_switch':0.0625,'jit_c_cmake_libs':'m;dl;/home/erik/miniconda3/envs/sspg/x86_64-conda-linux-gnu/lib/libgomp.so;/home/erik/miniconda3/envs/sspg/x86_64-conda-linux-gnu/sysroot/usr/lib/libpthread.so','jit_c_compiler_flags':' -Wundef  -std=c11 -lm -Wno-pragmas  -fexcess-precision=fast  -fcx-limited-range  -fno-math-errno  -fwrapv  -O3 -DNDEBUG -fopenmp  -fPIC ','jit_c_compiler_name':'/home/erik/miniconda3/envs/sspg/bin/cc','jit_c_control':'on','jit_c_libraries':' -lm -ldl /home/erik/miniconda3/envs/sspg/x86_64-conda-linux-gnu/lib/libgomp.so /home/erik/miniconda3/envs/sspg/x86_64-conda-linux-gnu/sysroot/usr/lib/libpthread.so','jit_c_linker_flags':' -shared ','jit_c_preface':'','jit_cache_path':'/home/erik/.SuiteSparse/GrB8.0.0','jit_error_log':'','jit_use_cmake':False,'memory_pool': [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],'nthreads':8,'print_1based':False})

Second, we can have a newglobal_context object:

>>>gb.ss.global_contextGlobalContext({'chunk':65536.0,'gpu_id':-1,'nthreads':8})

Third, we can have a newjit orjitconfig object:

>>>gb.ss.jitJitConfig({'c_cmake_libs':'m;dl;/home/erik/miniconda3/envs/sspg/x86_64-conda-linux-gnu/lib/libgomp.so;/home/erik/miniconda3/envs/sspg/x86_64-conda-linux-gnu/sysroot/usr/lib/libpthread.so','c_compiler_flags':' -Wundef  -std=c11 -lm -Wno-pragmas  -fexcess-precision=fast  -fcx-limited-range  -fno-math-errno  -fwrapv  -O3 -DNDEBUG -fopenmp  -fPIC ','c_compiler_name':'/home/erik/miniconda3/envs/sspg/bin/cc','c_control':'on','c_libraries':' -lm -ldl /home/erik/miniconda3/envs/sspg/x86_64-conda-linux-gnu/lib/libgomp.so /home/erik/miniconda3/envs/sspg/x86_64-conda-linux-gnu/sysroot/usr/lib/libpthread.so','c_linker_flags':' -shared ','c_preface':'','cache_path':'/home/erik/.SuiteSparse/GrB8.0.0','error_log':'','use_cmake':False})

So, if we wantglobal_context and/orjit/jitconfig objects, we could remove one/both of them from the global config, which simplifies the global config considerably. For example, here's the global config without the JIT options:

GlobalConfig({'bitmap_switch': [0.03999999910593033,0.05000000074505806,0.05999999865889549,0.07999999821186066,0.10000000149011612,0.20000000298023224,0.30000001192092896,0.4000000059604645],'burble':False,'chunk':65536.0,'format':'by_row','gpu_id':-1,'hyper_switch':0.0625,'memory_pool': [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],'nthreads':8,'print_1based':False})

If wealso removed the global context items from the global config, we get:

GlobalConfig({'bitmap_switch': [0.03999999910593033,0.05000000074505806,0.05999999865889549,0.07999999821186066,0.10000000149011612,0.20000000298023224,0.30000001192092896,0.4000000059604645],'burble':False,'format':'by_row','hyper_switch':0.0625,'memory_pool': [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],'print_1based':False})

@jim22k@SultanOrazbayev how would you like to organize the global configuration and global context? It's helpful to expose the global context so users can doglobal_contect.engage() to reset the context. I also like keepingnthreads in the global config (which gets and sets via the global context). So, my main question I'm struggling with is whether to split out the jit config.

Finally, we don't yet support getting or setting functions such as malloc, free, print, and flush (the third change in 8.0.0).

JIT

Coming soon!

@coveralls
Copy link

coveralls commentedMay 21, 2023
edited
Loading

Coverage Status

coverage: 99.44% (-0.4%) from 99.806%
when pulling8ec612f on eriknw:v8.0.0
intof0e0324 on python-graphblas:main.

@eriknw
Copy link
MemberAuthor

Alright, I think we should consider how we want contexts to behave and not rely on default behavior. For example, I think it would be nice to be able to layer contexts:

withContext(nthreads=4):# nthreads is 4withContext(chunk=0.5):# nthreads is still 4 (new behavior!)        ...# nthreads is still 4 (new behavior!)

@eriknw
Copy link
MemberAuthor

I updated contexts to chain and stack by default as illustrated in my previous comment.

Descriptor-like context values (such asexpr.new(nthreads=4)) createnew context objects derived from the current active context, and they "disengage" when they go out of scope so they can now apply to GraphBLAS functions that don't have descriptors. I think everything should more-or-less behave exactly as expected/desired in all plausible usage (but it's probably possible to get contexts in a weird state if one tries, really, really hard to do so).

I/we still need to document and test descriptors, and work on the JIT. If anybody wants to continue to work or play with this PR, ping me on discord or slack.

@eriknw
Copy link
MemberAuthor

In response to this comment,DrTimothyAldenDavis/GraphBLAS#218 (comment), I wonder whether it would be better for us to have a single context per thread that we update (it sounds like engaging a context in a thread may be required for kernel fusion in the future, and engagingmany contexts in a thread may wreak havoc on this). This would mean thatContext objects that would get used on a regular basis are pure Python that don't create/freeGxB_Context objects, but modify the thread-local context. I'm glad we learned of this now. I'd like to think on it a bit.

@eriknw
Copy link
MemberAuthor

JIT tests are now passing in CI for Linux and Windows! 🎉

SultanOrazbayev reacted with hooray emoji

jit_ffi=FFI()


defregister_new(name,jit_c_definition,*,np_type=None):
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Should we remove thename argument here? It's required to be the same name as the typedef, and I bet we could determine the name fromjit_c_definition.

__call__=TypedUserUnaryOp.__call__


defregister_new(name,jit_c_definition,input_type,ret_type):
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Similarly, should we get the name, input type, and return type from the C definition here?

Alternatively, shouldname not be required to match the name used in the C definition?

Should we call this function something else, such asgb.unary.ss.register_jit?

Also, should we consider addingregister_anonymous or allowing it to be anonymous?

@eriknw
Copy link
MemberAuthor

This is going in!

We still need to add some tests and documentaion, so SuiteSparse 8 is not yet "officially" supported. The metadata only allows SuiteSparse 7. This also gives us more time to review and refine the JIT.

Feel free to add review comments to this PR even after it's merged.

@eriknw
Copy link
MemberAuthor

btw, the JIT is working for CI for all OSes with bothpython-suitesparse-graphblas wheels and GraphBLAS from conda-forgeexcept for Window wheels (I don't know why).

@eriknweriknw merged commitf14cbac intopython-graphblas:mainJul 5, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@eriknw@coveralls

[8]ページ先頭

©2009-2025 Movatter.jp