Skip to content

Initial Metal backend support to dcompute#5118

Draft
asindarov wants to merge 19 commits intoldc-developers:masterfrom
asindarov:metal-backend
Draft

Initial Metal backend support to dcompute#5118
asindarov wants to merge 19 commits intoldc-developers:masterfrom
asindarov:metal-backend

Conversation

@asindarov
Copy link
Copy Markdown

No description provided.

Comment thread gen/dcompute/targetMetal.cpp Outdated
@gulugulubing
Copy link
Copy Markdown
Contributor

In cmakelist, LDC_LLVM_VER was removed. Try LLVM_VERSION_MAJOR.

Comment thread gen/dcompute/targetMetal.cpp Outdated
Comment thread gen/dcompute/targetMetal.cpp Outdated
Comment thread gen/abi/metal.cpp Outdated
Comment thread gen/abi/abi.cpp Outdated
Comment thread driver/dcomputecodegenerator.cpp Outdated
Comment thread gen/dcompute/target.h Outdated
Comment thread gen/dcompute/targetMetal.cpp Outdated
Comment thread gen/dcompute/targetMetal.cpp
Comment thread runtime/druntime/src/ldc/dcompute.d
Comment thread gen/dcompute/targetMetal.cpp Outdated
Copy link
Copy Markdown
Contributor

@thewilsonator thewilsonator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good. Needs some tests.

}
};

struct DcomputeMetalScalarRewrite : ABIRewrite {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this now unused?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it still used in abi/metal.cpp file:

struct MetalABI : TargetABI {
    DComputePointerRewrite pointerRewite;
    DcomputeMetalScalarRewrite metalScalarRewrite;
.....

It is used to make scalar objects turn into a pointer in constant memory address space. Although it turns out scalars can also be stored in device level address space which will be Global in the dcompute term as I understand

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scalar arguments to kernels are just passed as parameters

Comment thread gen/dcompute/abi-rewrites.h Outdated
Comment thread driver/dcomputecodegenerator.cpp Outdated
* valid values of _version are for OpenCL 100 110 120 200 210
* and for CUDA are x*100 + y*10 for x any valid values of sm x.y
* use 0 as a wildcard to match any version.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto, also could you update the documentation here to specify what are the valid versions of Metal (e.g. 400)?

Comment thread runtime/druntime/src/ldc/dcompute.d Outdated
* arguments MUST be compiletime constants
* valid values of _version are for OpenCL 100 110 120 200 210
* and for CUDA are x*100 + y*10 for x any valid values of sm x.y
* and for Metal is 4.0.0
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bit of documentation refers to the integer parameter passed to a function, e.g. 400 for metal 4.0.0. This should also be tested

Comment thread driver/toobj.cpp

// Terminate upon errors during the LLVM passes.
if (global.errors || global.warnings) {
Logger::println("Aborting because of errors/warnings during LLVM passes");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be an error not a logger print

Comment thread driver/toobj.cpp
if (useIR2ObjCache) {
cache::cacheObjectFile(filename, moduleHash);
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitespace

Comment thread dmd/globals.h
const DString mlir_ext = "mlir";
const DString bc_ext = "bc";
const DString s_ext = "s";
const DString metallib_ext = "metallib";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems unused

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants