Project: mojo_scalar
Here’s a completely unrelated, new project I started and finished today. It started with my post yesterday (link) after which I learned more about the open point of ‘SIMD not conforming to equatable and comparable’ [C. Lattner]. As I looked at the SIMD code to understand the problem, I saw that I could probably create a module that would work. More importantly for this thread, I saw an opportunity to use Augment Code to develop a solution from scratch. I used ‘agent’ mode on automatic, meaning that Augment Code created source files, test files, and documentation without stopping for me to approve critical steps. It also ran tests, made changes to the test and source files, and committed all changes to the Github repo automatically, without my intervention. Initially, Augment Code prompted me to manually create the repo on Guthub which I did. [Human taking direction from AI. ]
One source of complexity/noise was that I asked Augment Code to make this project a git submodule of another project, so there was a bunch of commits related to this and subsequent import changes to get everything to play nicely together with that other project.
For the curious, here’s a link to the repo containing the result of this journey. Github: mojo_scalar
8:17 AM Initial prompt
Referring to file simd.mojo in the modular repo, create a new file in this project named scalar.mojo
. In this new file, create a new struct Scalar
for all of the DType types defined by alias using alias Scalar = SIMD[_, size=1]
. In struct Scalar
, instance variable value
should be of a SIMD type as defined in file simd.mojo
. Create a new trait, trait TSIMD
, which includes the traits included in struct SIMD
. The new struct Scalar
should include trait SIMD
plus traits EqualityComparable
and Comparable
. In Scalar, all methods required by the traits included in TSIMD should call the SIMD methods of the variable value
and return the corresponding values as-is.
Operator dunders: For the methods which correspond to traits EqualityComparable
and Comparable
, create new methods in struct Scalar
that call existing methods of the variable value
which have the same function name and input arguments, but return SIMD output types. The function signatures of each new method should match the requirements of traits EqualityComparable
and Comparable
. Within each of these new methods, convert the return value of type SIMD into the return type defined in the trait definition. Remember, SIMD types are vectors of one or more values, while the return type of methods for traits EqualityComparable
and Comparable
are single value Bool.
2:31 PM Final prompt
Remember, test suites be organized into functions which begin with the prefix test_
. This is necessary for the mojo test
command to find tests in a given file. Evaluate and update for Mojo standard testing conventions. (sic)
🎉 Final Status
✅ Mojo Standard Compliance: Tests work with mojo test command
✅ Automatic Discovery: All 7 test functions found automatically
✅ 100% Pass Rate: All tests passing without errors
✅ Clean Code: No compiler warnings
✅ Better Organization: Logical test grouping
✅ Enhanced Documentation: Updated README and comments
✅ Maintained Compatibility: run_tests.sh still provides value
The test suite now follows Mojo best practices while maintaining the convenience and reliability of the automated test runner script!