Querying Host Target Info to find if the Target Triple of the Compiler is nvptx64-nvidia-cuda using APIs from sys.info (from info Module of sys Package) in Mojo Programming Language

Shriram Sivanandhan
2 min readSep 13, 2024

--

Mojo Programming Language combines the usability of Python with the performance of C, C++ and Rust. Mojo Programming Language utilizes next-generation compiler technologies with features like caching, multithreading and cloud distribution technologies. Further, Auto-Tuning and compile-time Metaprogramming features allows to write code for several hardware. The advantages of Mojo Programming Language are Usability & Programmability, best performance, Interoperability and Extensibility.

As we saw Interoperability of Mojo Programming Language with Python Ecosystem to use Matplotlib Python Visualization Library, Pandas Python Data Analysis and Manipulation Library, NumPy (Fundamental Package for Scientific Computing in Python) Library, SciPy Python Library in Mojo Programming Language and various concepts and implementations regarding Mojo Programming Language in previous Articles/Blogs. In this Article/Blog, we are going to see Querying Host Target Info to find if the Target Triple of the Compiler is nvptx64-nvidia-cuda using APIs from sys.info (from info Module of sys Package) in Mojo Programming Language.

Since the older JupyterLab-based Mojo Playground is deprecated, in this Blog, Programming in Mojo is done using the new Mojo Playground.

Querying Host Target Info to find if the Target Triple of the Compiler is nvptx64-nvidia-cuda using APIs from sys.info (from info Module of sys Package) in Mojo Programming Language:

We are going to use APIs from sys.info (from info Module of sys Package) in Mojo Programming Language. In Mojo Programming Language, sys.info implements the methods to query host target info.

Printing if the Target Triple of the Compiler is nvptx64-nvidia-cuda or not using triple_is_nvidia_cuda() function from sys.info (from info Module of sys Package) in Mojo Programming Language
Printing if the Target Triple of the Compiler is nvptx64-nvidia-cuda or not using triple_is_nvidia_cuda() function from sys.info (from info Module of sys Package) in Mojo Programming Language (New Mojo Playground)

Thankyou for reading this blog on Querying Host Target Info to find if the Target Triple of the Compiler is nvptx64-nvidia-cuda using APIs from sys.info (from info Module of sys Package) in Mojo Programming Language. Programming in Mojo and Mojo Programming concepts will be discussed further.

Reference:

https://docs.modular.com/mojo/manual/

https://docs.modular.com/mojo/manual/basics/

https://docs.modular.com/mojo/stdlib/sys/info

--

--