Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CF_DPCPP_ENABLED #2133

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions conda_smithy/configure_feedstock.py
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,13 @@ def _render_ci_provider(
if pat.match(ml):
os.environ["CF_CUDA_ENABLED"] = "True"

# looking for `compiler('dpcpp')` with both quote variants;
# do not match if there is a `#` somewhere before on the line
pat = re.compile(r"^[^\#]*compiler\((\"dpcpp\"|\'dpcpp\')\).*")
for ml in meta_lines:
if pat.match(ml):
os.environ["CF_DPCPP_ENABLED"] = "True"

config = conda_build.config.get_or_merge_config(
None,
exclusive_config_file=forge_config["exclusive_config_file"],
Expand Down
3 changes: 3 additions & 0 deletions news/add_CF_DPCPP_ENABLED.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**Added:**

* Add CF_DPCPP_ENABLED variable similarly to CF_CUDA_ENABLED.
29 changes: 29 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,35 @@ def cuda_enabled_recipe(config_yaml: ConfigYAML):
)


@pytest.fixture(scope="function")
def dpcpp_enabled_recipe(config_yaml: ConfigYAML):
with open(
os.path.join(config_yaml.workdir, "recipe", config_yaml.recipe_name),
"w",
) as fh:
cuda_recipe_path = os.path.abspath(
os.path.join(
__file__,
"../",
"recipes",
"dpcpp_recipes",
config_yaml.recipe_name,
)
)
content = Path(cuda_recipe_path).read_text()
fh.write(content)

return RecipeConfigPair(
str(config_yaml.workdir),
_load_forge_config(
config_yaml.workdir,
exclusive_config_file=os.path.join(
config_yaml.workdir, "recipe", "default_config.yaml"
),
),
)


@pytest.fixture(scope="function")
def jinja_env():
tmplt_dir = os.path.join(conda_forge_content, "templates")
Expand Down
15 changes: 15 additions & 0 deletions tests/recipes/dpcpp_recipes/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package:
name: py-test
version: 1.0.0
build:
skip: True # [os.environ.get("CF_DPCPP_ENABLED") != "True"]
requirements:
build:
- {{ compiler('c') }}
- {{ compiler('dpcpp') }}
host:
- python
run:
- python
about:
home: home
15 changes: 15 additions & 0 deletions tests/recipes/dpcpp_recipes/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package:
name: py-test
version: 1.0.0
build:
skip:
- env.get('CF_DPCPP_ENABLED') != "True"

requirements:
build:
- ${{ compiler('c') }}
- ${{ compiler('dpcpp') }}
host:
- python
run:
- python
31 changes: 31 additions & 0 deletions tests/test_configure_feedstock.py
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,37 @@ def test_cuda_enabled_render(cuda_enabled_recipe, jinja_env):
del os.environ["CF_CUDA_ENABLED"]


def test_dpcpp_enabled_render(dpcpp_enabled_recipe, jinja_env):
forge_config = copy.deepcopy(dpcpp_enabled_recipe.config)
has_env = "CF_DPCPP_ENABLED" in os.environ
if has_env:
old_val = os.environ["CF_DPCPP_ENABLED"]
del os.environ["CF_DPCPP_ENABLED"]

try:
assert "CF_DPCPP_ENABLED" not in os.environ
configure_feedstock.render_azure(
jinja_env=jinja_env,
forge_config=forge_config,
forge_dir=dpcpp_enabled_recipe.recipe,
)
assert os.environ["CF_DPCPP_ENABLED"] == "True"

# this configuration should be run
assert forge_config["azure"]["enabled"]
matrix_dir = os.path.join(dpcpp_enabled_recipe.recipe, ".ci_support")
assert os.path.isdir(matrix_dir)
# single matrix entry - readme is generated later in main function
assert len(os.listdir(matrix_dir)) == 6

finally:
if has_env:
os.environ["CF_DPCPP_ENABLED"] = old_val
else:
if "CF_DPCPP_ENABLED" in os.environ:
del os.environ["CF_DPCPP_ENABLED"]


def test_conda_build_tools(config_yaml: ConfigYAML, caplog):
load_forge_config = lambda: configure_feedstock._load_forge_config( # noqa
config_yaml.workdir,
Expand Down
Loading