Comments (5)
Appears it's not just cores, it's all of sys.info(?!)*
Confirmed same behavior on mojo 2024.7.2521 (a7cec710)
and ubuntu 22.04.4
*Tested 5 of the sys.info calls
from sys.info import *
var workers = num_performance_cores()
var logical = num_logical_cores()
var physical = num_physical_cores()
var SIMD_BIT_WIDTH = simdbitwidth()
var SIMDBITEWIDTH = simdbytewidth()
def main():
print(workers)
print(logical)
print(physical)
print(SIMD_BIT_WIDTH)
print(SIMDBITEWIDTH)
Returns
darin@home:~/Playground/mojo_bug_testing$ mojo 3311_test_extra.mojo
8
16
8
256
32
darin@home:~/Playground/mojo_bug_testing$ mojo build 3311_test_extra.mojo
darin@home:~/Playground/mojo_bug_testing$ ./3311_test_extra
0
0
0
0
0
from mojo.
Aliasing all the above calls does not compile
from sys.info import *
alias workers = num_performance_cores()
alias logical = num_logical_cores()
alias physical = num_physical_cores()
alias SIMD_BIT_WIDTH = simdbitwidth()
alias SIMDBITEWIDTH = simdbytewidth()
def main():
print(workers)
print(logical)
print(physical)
print(SIMD_BIT_WIDTH)
print(SIMDBITEWIDTH)
returns
/__w/modular/modular/open-source/mojo/stdlib/stdlib/builtin/_startup.mojo:113:4: error: call expansion failed
/__w/modular/modular/open-source/mojo/stdlib/stdlib/builtin/_startup.mojo:96:4: note: function instantiation failed
/__w/modular/modular/open-source/mojo/stdlib/stdlib/builtin/_startup.mojo:108:57: note: call expansion failed
/__w/modular/modular/open-source/mojo/stdlib/stdlib/builtin/_startup.mojo:68:4: note: function instantiation failed
/__w/modular/modular/open-source/mojo/stdlib/stdlib/builtin/_startup.mojo:84:18: note: call expansion failed
/__w/modular/modular/open-source/mojo/stdlib/stdlib/builtin/_startup.mojo:105:8: note: function instantiation failed
<unknown>:0: note: failed to compile-time evaluate function call
/__w/modular/modular/open-source/mojo/stdlib/stdlib/sys/info.mojo:709:4: note: failed to interpret function @stdlib::sys::info::num_performance_cores()
/__w/modular/modular/open-source/mojo/stdlib/stdlib/sys/info.mojo:716:76: note: call expansion failed
/__w/modular/modular/open-source/mojo/stdlib/stdlib/sys/ffi.mojo:342:6: note: failed to interpret operation pop.external_call{func: "KGEN_CompilerRT_NumPerformanceCores" : !kgen.string, funcAttrs: ["willreturn"], memory: #llvm.memory_effects<other = none, argMem = none, inaccessibleMem = none>, resAttrs: [{llvm.noundef}]}(#kgen.pack<> : !kgen.pack<[]>)
/__w/modular/modular/open-source/mojo/stdlib/stdlib/sys/info.mojo:716:76: note: call expansion failed
/__w/modular/modular/open-source/mojo/stdlib/stdlib/sys/ffi.mojo:342:6: note: unable to interpret call to unknown external function: KGEN_CompilerRT_NumPerformanceCores
mojo: error: failed to run the pass manager
from mojo.
I can't reproduce this on the current internal build. If you move var workers = num_performance_cores()
into def main
like:
from sys.info import num_performance_cores
def main():
var workers = num_performance_cores()
print(workers)
Does that fix it?
@abduld is a global var
statement undefined behavior at the moment?
from mojo.
I can't reproduce this on the current internal build. If you move
var workers = num_performance_cores()
intodef main
like:from sys.info import num_performance_cores def main(): var workers = num_performance_cores() print(workers)Does that fix it?
@abduld is a global
var
statement undefined behavior at the moment?
Yes, var in scope of main works.
alias workers
in global throws an error on print for variadic statements [expected?]
alias workers
in def main
returns
/__w/modular/modular/open-source/mojo/stdlib/stdlib/builtin/_startup.mojo:113:4: error: call expansion failed
/__w/modular/modular/open-source/mojo/stdlib/stdlib/builtin/_startup.mojo:96:4: note: function instantiation failed
/__w/modular/modular/open-source/mojo/stdlib/stdlib/builtin/_startup.mojo:108:57: note: call expansion failed
/__w/modular/modular/open-source/mojo/stdlib/stdlib/builtin/_startup.mojo:68:4: note: function instantiation failed
/__w/modular/modular/open-source/mojo/stdlib/stdlib/builtin/_startup.mojo:84:18: note: call expansion failed
/__w/modular/modular/open-source/mojo/stdlib/stdlib/builtin/_startup.mojo:105:8: note: function instantiation failed
<unknown>:0: note: failed to compile-time evaluate function call
/__w/modular/modular/open-source/mojo/stdlib/stdlib/sys/info.mojo:709:4: note: failed to interpret function @stdlib::sys::info::num_performance_cores()
/__w/modular/modular/open-source/mojo/stdlib/stdlib/sys/info.mojo:716:76: note: call expansion failed
/__w/modular/modular/open-source/mojo/stdlib/stdlib/sys/ffi.mojo:342:6: note: failed to interpret operation pop.external_call{func: "KGEN_CompilerRT_NumPerformanceCores" : !kgen.string, funcAttrs: ["willreturn"], memory: #llvm.memory_effects<other = none, argMem = none, inaccessibleMem = none>, resAttrs: [{llvm.noundef}]}(#kgen.pack<> : !kgen.pack<[]>)
/__w/modular/modular/open-source/mojo/stdlib/stdlib/sys/info.mojo:716:76: note: call expansion failed
/__w/modular/modular/open-source/mojo/stdlib/stdlib/sys/ffi.mojo:342:6: note: unable to interpret call to unknown external function: KGEN_CompilerRT_NumPerformanceCores
mojo: error: failed to run the pass manager
from mojo.
alias workers in global throws an error on print for variadic statements [expected?]
No that is unexpected and we should fix it
from mojo.
Related Issues (20)
- [Docs] Suggestion: link to python types docs in module | Dict
- [BUG]Mojo doesnt recognise main function HOT 5
- [BUG] Errors with optional recursive struct definitions HOT 1
- [Feature Request] Make `StringRef.find` call `StringSlice.find`
- [BUG] [stdlib] Fix `String.format()` to use explicit byte indexing and not assume `String.__getitem__` indexes directly to byte offset.
- [BUG] Mojo SDK post-install test failures
- [BUG] Mojo SDK post-install test failures
- [BUG] Jupyter Notebook fails to load mojo kernel
- [Feature Request] Add functionality like `@classmethod` to enforce conditional conformance on struct static methods
- [Docs] Mojo URL leads to 404 HOT 3
- [BUG] Type checker is failing to compare two function types HOT 1
- [BUG] `parallelize` should abort if num_workers < 0, currently it has weird behavior HOT 2
- [Modular CLI] mojo-nightly.path missing from modular.cfg post successfull install
- [BUG] Top level `var` segfaults when used from package HOT 5
- [BUG] `print(None)` doesn't work anymore
- [BUG] `0/0 != 1` returns `False` HOT 3
- [BUG] Compiler crash with (indirect) self referential type
- [Feature Request] Add `__name__`
- [BUG] Working LinkedList using pointers, but debug is failing. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mojo.