forked from modular/modular
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmandelbrot.py
More file actions
executable file
·29 lines (24 loc) · 1.15 KB
/
mandelbrot.py
File metadata and controls
executable file
·29 lines (24 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# ===----------------------------------------------------------------------=== #
# Copyright (c) 2025, Modular Inc. All rights reserved.
#
# Licensed under the Apache License v2.0 with LLVM Exceptions:
# https://llvm.org/LICENSE.txt
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ===----------------------------------------------------------------------=== #
import os
import sys
# The Mojo importer module will handle compilation of the Mojo files.
import max.mojo.importer # noqa: F401
current_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, current_dir)
# Importing our Mojo module, defined in the `mandelbrot_mojo.mojo` file.
import mandelbrot_mojo # type: ignore
if __name__ == "__main__":
# Run the Mandelbrot set calculation on GPU, in Mojo, and get back the ASCII art results.
ascii_mandelbrot = mandelbrot_mojo.run_mandelbrot(100)
print(ascii_mandelbrot)