mirror of
				https://github.com/ml-explore/mlx.git
				synced 2025-10-31 16:21:27 +08:00 
			
		
		
		
	 4f9b60dd53
			
		
	
	4f9b60dd53
	
	
	
		
			
			* Remove "using namespace mlx::core" in benchmarks/examples * Fix building example extension * A missing one in comment * Fix building on M chips
		
			
				
	
	
		
			23 lines
		
	
	
		
			499 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			23 lines
		
	
	
		
			499 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| // Copyright © 2024 Apple Inc.
 | |
| 
 | |
| #include <iostream>
 | |
| 
 | |
| #include "mlx/mlx.h"
 | |
| 
 | |
| namespace mx = mlx::core;
 | |
| 
 | |
| int main() {
 | |
|   if (!mx::distributed::is_available()) {
 | |
|     std::cout << "No communication backend found" << std::endl;
 | |
|     return 1;
 | |
|   }
 | |
| 
 | |
|   auto global_group = mx::distributed::init();
 | |
|   std::cout << global_group.rank() << " / " << global_group.size() << std::endl;
 | |
| 
 | |
|   mx::array x = mx::ones({10});
 | |
|   mx::array out = mx::distributed::all_sum(x, global_group);
 | |
| 
 | |
|   std::cout << out << std::endl;
 | |
| }
 |