From a9fd264a4cb4aebe3d71dc8b5b0fa2e0db5cb3e5 Mon Sep 17 00:00:00 2001 From: 0xc30edf0147c46d0a5f79bfe9b15ce9de9b8879be Date: Thu, 15 Jan 2026 12:21:26 +0000 Subject: [PATCH] "Player 0xc30edf0147c46d0a5f79bfe9b15ce9de9b8879be submitted code influence_maximization/simple_top" --- .../src/influence_maximization/mod.rs | 3 +- .../simple_top/README.md | 23 ++++++ .../simple_top/kernels.cu | 0 .../influence_maximization/simple_top/mod.rs | 77 +++++++++++++++++++ 4 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 tig-algorithms/src/influence_maximization/simple_top/README.md create mode 100644 tig-algorithms/src/influence_maximization/simple_top/kernels.cu create mode 100644 tig-algorithms/src/influence_maximization/simple_top/mod.rs diff --git a/tig-algorithms/src/influence_maximization/mod.rs b/tig-algorithms/src/influence_maximization/mod.rs index 0949891e..0a41812d 100644 --- a/tig-algorithms/src/influence_maximization/mod.rs +++ b/tig-algorithms/src/influence_maximization/mod.rs @@ -1,4 +1,5 @@ -// c009_a001 +pub mod simple_top; +pub use simple_top as c009_a001; // c009_a002 diff --git a/tig-algorithms/src/influence_maximization/simple_top/README.md b/tig-algorithms/src/influence_maximization/simple_top/README.md new file mode 100644 index 00000000..95c7663c --- /dev/null +++ b/tig-algorithms/src/influence_maximization/simple_top/README.md @@ -0,0 +1,23 @@ +# TIG Code Submission + +## Submission Details + +* **Challenge Name:** influence_maximization +* **Algorithm Name:** simple_top +* **Copyright:** 2025 Uncharted +* **Identity of Submitter:** Uncharted +* **Identity of Creator of Algorithmic Method:** null +* **Unique Algorithm Identifier (UAI):** null + +## License + +The files in this folder are under the following licenses: +* TIG Benchmarker Outbound License +* TIG Commercial License +* TIG Inbound Game License +* TIG Innovator Outbound Game License +* TIG Open Data License +* TIG THV Game License + +Copies of the licenses can be obtained at: +https://github.com/tig-foundation/tig-monorepo/tree/main/docs/licenses diff --git a/tig-algorithms/src/influence_maximization/simple_top/kernels.cu b/tig-algorithms/src/influence_maximization/simple_top/kernels.cu new file mode 100644 index 00000000..e69de29b diff --git a/tig-algorithms/src/influence_maximization/simple_top/mod.rs b/tig-algorithms/src/influence_maximization/simple_top/mod.rs new file mode 100644 index 00000000..ec154a4a --- /dev/null +++ b/tig-algorithms/src/influence_maximization/simple_top/mod.rs @@ -0,0 +1,77 @@ +// TIG's UI uses the pattern `tig_challenges::` to automatically detect your algorithm's challenge +use crate::{seeded_hasher, HashMap, HashSet}; +use anyhow::{anyhow, Result}; +use cudarc::{ + driver::{safe::LaunchConfig, CudaModule, CudaStream, PushKernelArg}, + runtime::sys::cudaDeviceProp, +}; +use serde::{Deserialize, Serialize}; +use serde_json::{Map, Value}; +use std::sync::Arc; +use tig_challenges::influence_maximization::*; + +#[derive(Serialize, Deserialize)] +pub struct Hyperparameters { + // Optionally define hyperparameters here. Example: + // pub param1: usize, + // pub param2: f64, +} + +pub fn help() { + // Print help information about your algorithm here. It will be invoked with `help_algorithm` script + println!("No help information provided."); +} + +const MAX_THREADS_PER_BLOCK: u32 = 1024; + +pub fn solve_challenge( + challenge: &Challenge, + save_solution: &dyn Fn(&Solution) -> Result<()>, + hyperparameters: &Option>, + module: Arc, + stream: Arc, + prop: &cudaDeviceProp, +) -> anyhow::Result<()> { + let count_degrees_kernel = module.load_function("count_degrees_kernel").unwrap(); + let mut d_degrees = stream + .alloc_zeros::(challenge.num_nodes as usize) + .unwrap(); + unsafe { + stream + .launch_builder(&count_degrees_kernel) + .arg(&challenge.d_from_nodes) + .arg(&mut d_degrees) + .arg(&challenge.num_edges) + .launch(LaunchConfig { + grid_dim: ( + (challenge.num_edges as u32 + MAX_THREADS_PER_BLOCK - 1) + / MAX_THREADS_PER_BLOCK, + 1, + 1, + ), + block_dim: (MAX_THREADS_PER_BLOCK, 1, 1), + shared_mem_bytes: 0, + })?; + } + stream.synchronize().unwrap(); + + let degrees = stream.memcpy_dtov(&d_degrees).unwrap(); + let mut node_degree_pairs: Vec<(i32, i32)> = degrees + .iter() + .enumerate() + .map(|(node, °)| (node as i32, deg)) + .collect(); + node_degree_pairs.sort_by(|a, b| b.1.cmp(&a.1)); + let highest_degree_nodes: Vec = node_degree_pairs + .iter() + .step_by(2) + .take(challenge.max_starting_nodes as usize) + .map(|&(node, _)| node) + .collect(); + let _ = save_solution(&Solution { + starting_nodes: highest_degree_nodes, + }); + Ok(()) +} + +// Important! Do not include any tests in this file, it will result in your submission being rejected