Skip to content

Commit

Permalink
Cleaned up
Browse files Browse the repository at this point in the history
  • Loading branch information
braxtoncuneo committed May 6, 2024
1 parent a0070e5 commit 6254fe2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
3 changes: 2 additions & 1 deletion mcdc/adapt.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

HAS_GPU = False
except:
print("Warning: GPU capability is not available")
if mcdc.main.target == "gpu":
print("Warning: GPU capability is not available")
HAS_GPU = False

import math
Expand Down
6 changes: 0 additions & 6 deletions mcdc/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,6 @@ def get_particle(P, bank, mcdc):
return True


#! Don't touch for now
@njit
def manage_particle_banks(seed, mcdc):
# Record time
Expand Down Expand Up @@ -1038,7 +1037,6 @@ def manage_particle_banks(seed, mcdc):
mcdc["runtime_bank_management"] += time_end - time_start


#! Don't touch for now
@njit
def manage_IC_bank(mcdc):
# Buffer bank
Expand Down Expand Up @@ -1421,7 +1419,6 @@ def bank_IC(P, prog):
precursor["y"] = P["y"]
precursor["z"] = P["z"]
precursor["w"] = wp_prime / wn_prime
#! Ask Ilham about this

# Sample group
xi = rng(P) * total
Expand Down Expand Up @@ -2184,7 +2181,6 @@ def score_eddington(s, g, t, x, y, z, flux, P, score):
adapt.global_add(score["bin"], (s, g, t, x, y, z, 5), flux * uz * uz)


#! Don't touch for now
@njit
def score_reduce_bin(score, mcdc):
# Normalize
Expand All @@ -2207,7 +2203,6 @@ def score_closeout_history(score):
score["bin"].fill(0.0)


#! Don't touch for now
@njit
def score_closeout(score, mcdc):
N_history = mcdc["setting"]["N_particle"]
Expand Down Expand Up @@ -2321,7 +2316,6 @@ def eigenvalue_tally(P, distance, mcdc):
mcdc["C_max"] = C_density


#! Don't touch for now
@njit
def eigenvalue_tally_closeout_history(mcdc):
N_particle = mcdc["setting"]["N_particle"]
Expand Down
35 changes: 28 additions & 7 deletions mcdc/type_.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,34 @@
# ==============================================================================


# While CPU execution can robustly handle all sorts of Numba types, GPU
# execution requires structs to follow some of the basic properties expected of
# C-style structs with standard layout:
#
# - Every primitive field is aligned by its size, and padding is inserted
# between fields to ensure alignment in arrays and nested data structures
#
# - Every field has a unique address
#
# If these rules are violated, memory accesses made in GPUs may encounter
# problems. For example, in cases where an access is not at an address aligned
# by their size, a segfault or similar fault will occur, or information will be
# lost. These issues were fixed by providing a function, align, which ensures the
# field lists fed to np.dtype fulfill these requirements.
#
# The align function does the following:
#
# - Tracks the cumulative offset of fields as they appear in the input list.
#
# - Inserts additional padding fields to ensure that primitive fields are
# aligned by their size
#
# - Re-sizes arrays to have at least one element in their array (this ensure
# they have a non-zero size, and hence cannot overlap base addresses with
# other fields.
#


def fixup_dims(dim_tuple):
return tuple([max(d, 1) for d in dim_tuple])

Expand Down Expand Up @@ -70,9 +98,6 @@ def align(field_list):
else:
print_error("Unexpected field item type")

if multiplier == 0:
multiplier = 1

size *= multiplier

if offset % alignment != 0:
Expand Down Expand Up @@ -1188,10 +1213,6 @@ def make_type_domain_decomp(input_deck):
# ==============================================================================


def copy_global(dst, src):
pass


def make_type_global(input_deck):
global global_

Expand Down

0 comments on commit 6254fe2

Please sign in to comment.